ECE 331 – Digital System Design

Slides:



Advertisements
Similar presentations
Lecture no 6. Two's Complement Given a negative number (N), represented using the Two's Complement representation (N*), the magnitude of the number (P)
Advertisements

Addition and Subtraction. Outline Arithmetic Operations (Section 1.2) – Addition – Subtraction – Multiplication Complements (Section 1.5) – 1’s complement.
Company LOGO Edit your slogan here DKT 122/3 DIGITAL SYSTEM 1 WEEK #3 NUMBER SYSTEMS, OPERATION & CODES (PART 2)
ECE 331 – Digital System Design
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
ECE 331 – Digital System Design
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
1.6 Signed Binary Numbers.
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
Digital Systems and Logic Design
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Summer 2012ETE Digital Electronics1 Binary Arithmetic of Signed Binary Numbers.
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
ECE 301 – Digital Electronics Representation of Negative Numbers, Binary Arithmetic of Negative Numbers, and Binary Codes (Lecture #11) The slides included.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
ECE DIGITAL LOGIC LECTURE 4: BINARY CODES Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/26/2016.
Lecture 1.2 (Chapter 1) Prepared by Dr. Lamiaa Elshenawy
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
ECE 3110: Introduction to Digital Systems Signed Number Conversions and operations.
Computer Math CPS120 Introduction to Computer Science Lecture 7.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
N 3-1 Data Types  Binary information is stored in memory or processor registers  Registers contain either data or control information l Data are numbers.
11001 / 101, / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the result.
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
Number Systems By, B. R. Chandavarkar CSE Dept., NITK, Surathkal.
Lecture 4: Digital Systems & Binary Numbers (4)
Negative Number Sign-Magnitude: left-most bit as the sign bit –16 bits –Example: 4-bit numbers is given by is given by ’s complement:
Data Representation COE 308 Computer Architecture
Cosc 2150: Computer Organization
Addition and Subtraction
ECE 2110: Introduction to Digital Systems
Lec 3: Data Representation
CS2100 Computer Organisation
Data Representation.
CHAPTER 9 COMPUTER ARITHMETIC - ALU
Number Representation
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
11001 / 101 , / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the.
Number systems and codes
Binary Arithmetic Binary arithmetic is essential in all digital computers and in many other types of digital systems. Addition, Subtraction, Multiplication,
Lecture 2 Topics Binary Arithmetic (Unsigned binary operands)
Number Systems.
Addition and Substraction
Wakerly Section 2.4 and further
Lecture 2 Topics Binary Arithmetic (Unsigned binary operands)
Complement Theory 1’s and, 2’s complement operation
Data Representation Data Types Complements Fixed Point Representation
Complement Theory 1’s and, 2’s complement operation
Unit 18: Computational Thinking
C1 Number systems.
How are negative and rational numbers represented on the computer?
2’s Complement form 1’s complement form 2’s complement form
CPS120: Introduction to Computer Science
Decimal and binary representation systems
Number Systems Rayat Shikshan Sanstha’s
Number Systems Rayat Shikshan Sanstha’s
ECE 171 Digital Circuits Chapter 2 Binary Arithmetic
Lecture No.5.
Chapter3 Fixed Point Representation
Chapter 1 (Part c) Digital Systems and Binary Numbers
Data Representation COE 308 Computer Architecture
Two’s Complement & Binary Arithmetic
Presentation transcript:

ECE 331 – Digital System Design Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #10)

Unsigned and Signed Binary Numbers ECE 331 - Digital System Design

Unsigned and Signed Numbers 10011010 8-bit Binary number. What is the decimal equivalent of this binary number? ECE 331 - Digital System Design

Unsigned and Signed Numbers 1 – Magnitude MSB (a) Unsigned number Sign (b) Signed number 2 0 denotes 1 denotes + ECE 331 - Digital System Design

Unsigned Binary Numbers ECE 331 - Digital System Design

Unsigned Binary Numbers For an n-bit unsigned binary number, all n bits are used to represent the magnitude of the number. ** Cannot represent negative numbers. ECE 331 - Digital System Design

Unsigned Binary Numbers For an n-bit binary number 0 <= D <= 2n – 1 where D = decimal equivalent value For an 8-bit binary number: 0 <= D <= 28 – 1 28 = 256 For a 16-bit binary number: 0 <= D <= 216 – 1 216 = 65536 ECE 331 - Digital System Design

ECE 331 - Digital System Design Signed Binary Numbers ECE 331 - Digital System Design

Signed Binary Numbers For an n-bit signed binary number, n-1 bits are used to represent the magnitude of the number; the leftmost bit (MSB) is, generally, used to indicate the sign of the number. 0 = positive number 1 = negative number ECE 331 - Digital System Design

Signed Binary Numbers Three representations for signed binary numbers: 1. Sign-and-Magnitude 2. One's Complement 3. Two's Complement ECE 331 - Digital System Design

Sign-and-Magnitude Representation Signed Binary Numbers Sign-and-Magnitude Representation ECE 331 - Digital System Design

ECE 331 - Digital System Design Sign-and-Magnitude For an n-bit signed binary number, The MSB (leftmost bit) is the sign bit. The remaining n-1 bits represent the magnitude. - (2n-1 - 1) <= D <= + (2n-1 – 1) Includes a representation for -0 and +0. The design of arithmetic circuits for sign-and- magnitude binary numbers is difficult. ECE 331 - Digital System Design

ECE 331 - Digital System Design Sign-and-Magnitude Example: What is the Sign-and-Magnitude binary number representation for the following decimal values, using 8 bits: + 97 - 68 ECE 331 - Digital System Design

ECE 331 - Digital System Design Sign-and-Magnitude Example: Can the following decimal numbers be represented using Sign-and-Magnitude representation and 8 bits? - 127 + 128 - 212 + 255 ECE 331 - Digital System Design

One's Complement Representation Signed Binary Numbers One's Complement Representation ECE 331 - Digital System Design

ECE 331 - Digital System Design One's Complement An n-bit positive number (P) is represented in the same way as in the Sign-and-Magnitude representation. The sign bit (MSB) = 0. The remaining n-1 bits represent the magnitude. ECE 331 - Digital System Design

ECE 331 - Digital System Design One's Complement An n-bit negative number (N) is represented using the “One's Complement” of the equivalent positive number (P). N' = One's Complement representation for the negative number N. N' = (2n – 1) – P where P = |N| The sign bit (MSB) = 1 for all negative numbers using the One's Complement representation. ECE 331 - Digital System Design

ECE 331 - Digital System Design One's Complement Example: Determine the One's Complement representation for the following negative numbers, using 8 bits: - 11 - 107 - 74 ECE 331 - Digital System Design

ECE 331 - Digital System Design One's Complement The One's Complement representation of N can also be determined using the bit-wise complement of P. N = n-bit negative number P = |N| N' = One's Complement representation of N. N' = bit-wise complement of P i.e. complement P, bit-by-bit. ECE 331 - Digital System Design

ECE 331 - Digital System Design One's Complement Example: Determine the One's Complement representation (using the bit-wise complement) for the following negative numbers, using 8 bits: - 11 - 107 - 74 ECE 331 - Digital System Design

ECE 331 - Digital System Design One's Complement For an n-bit signed binary number, - (2n-1 - 1) <= D <= + (2n-1 – 1) Includes a representation for -0 and +0. Represents an equal number of positive and negative values. ECE 331 - Digital System Design

One's Complement Given a negative number (N), represented using the One's Complement representation (N'), the magnitude of the number (P) can be determined as follows: P = (2n – 1) – N' or P = bit-wise complement of N' ECE 331 - Digital System Design

Two's Complement Representation Signed Binary Numbers Two's Complement Representation ECE 331 - Digital System Design

ECE 331 - Digital System Design Two's Complement An n-bit positive number (P) is represented in the same way as in the Sign-and-Magnitude representation. The sign bit (MSB) = 0. The remaining n-1 bits represent the magnitude. ECE 331 - Digital System Design

ECE 331 - Digital System Design Two's Complement An n-bit negative number (N) is represented using the “Two's Complement” of the equivalent positive number (P). N* = Two's Complement representation for the negative number N. N* = (2n) – P where P = |N| The sign bit (MSB) = 1 for all negative numbers using the One's Complement representation. ECE 331 - Digital System Design

ECE 331 - Digital System Design Two's Complement Example: Determine the Two's Complement representation for the following negative numbers, using 8 bits: - 11 - 107 - 74 ECE 331 - Digital System Design

ECE 331 - Digital System Design Two's Complement The Two's Complement representation is related to the One's Complement representation as follows: N' = (2n – 1) – P N* = (2n) – P N* = N' + 1 ECE 331 - Digital System Design

ECE 331 - Digital System Design Two's Complement The Two's Complement representation of N can also be determined by adding 1 to the One's Complement representation of N. N = n-bit negative number P = |N| N' = One's Complement representation of N. N' = bit-wise complement of P. N* = N' + 1 ECE 331 - Digital System Design

ECE 331 - Digital System Design Two's Complement Example: Determine the Two's Complement representation (using the One's Complement) for the following negative numbers, using 8 bits: - 11 - 107 - 74 ECE 331 - Digital System Design

ECE 331 - Digital System Design Two's Complement For an n-bit signed binary number, - (2n-1) <= D <= + (2n-1 – 1) Includes only one representation for 0. Represents an additional negative value. ECE 331 - Digital System Design

Two's Complement Given a negative number (N), represented using the Two's Complement representation (N*), the magnitude of the number (P) can be determined as follows: P = (2n) – N* or P = bit-wise complement of N* + 1 ECE 331 - Digital System Design

ECE 331 - Digital System Design Signed Binary Numbers ECE 331 - Digital System Design

ECE 331 - Digital System Design Binary Arithmetic of Signed Binary Numbers ECE 331 - Digital System Design

Two's Complement Addition Addition of n-bit signed numbers using Two's Complement addition is straightforward. Addition is carried out in the same way as the addition of n-bit positive numbers. Carry from the sign position (MSB) is ignored. Overflow occurs if the correct result (including the sign) cannot be represented in n bits. ECE 331 - Digital System Design

Two's Complement Addition Implement the addition of the following signed numbers using Two's Complement Addition: 32 + 45 -17 + 63 82 + (-29) ECE 331 - Digital System Design

Two's Complement Subtraction A – B = A + (-B) Subtraction can be implemented using addition. Determine the Two's Complement representation for the negative number -B. Use Two's Complement Addition to add A and -B. ECE 331 - Digital System Design

Two's Complement Subtraction Implement the subtraction of the following signed numbers using Two's Complement Addition: 32 - 45 -17 - 63 82 - (-29) ECE 331 - Digital System Design

One's Complement Addition Similar to the addition of n-bit numbers using Two's Complement Addition. Instead of discarding the carry from the sign position (MSB), it must be added to the least significant bit (LSB) of the n-bit sum. Referred to as an end-around carry. ECE 331 - Digital System Design

One's Complement Addition Implement the addition of the following signed numbers using One's Complement Addition: 32 + 45 -17 + 63 82 + (-29) ECE 331 - Digital System Design

ECE 331 - Digital System Design Overflow General rule for detecting overflow when adding two n-bit numbers using either One's Complement or Two's Complement Addition An overflow occurs when the addition of two positive numbers results in a negative value or the addition of two negative numbers results in a positive value. Cannot occur when adding a positive number and a negative number. ECE 331 - Digital System Design

ECE 331 - Digital System Design Binary Codes ECE 331 - Digital System Design

ECE 331 - Digital System Design Binary Codes Weighted and Unweighted Codes A weighted code is one in which each position in the code has a specific weight An unweighted code is one in which the positions in the code do not have a specific weight A 4-bit weighted code Weights: w3, w2, w1, w0 Code: a3a2a1a0 Decimal: D = a3 x w3 + a2 x w2 + a1 x w1 + a0 x w0 ECE 331 - Digital System Design

ECE 331 - Digital System Design Binary Codes Binary Coded Decimal (BCD) 4-bit binary number used to represent each decimal digit Weighted code: 8-4-2-1 The binary values 0000 .. 1001 are used to represent the decimal digits 0 .. 9 The binary values 1010 .. 1111 are not used. How do we interpret these unused codes? Very different than the binary equivalent of a decimal number. ECE 331 - Digital System Design

ECE 331 - Digital System Design Binary Coded Decimal ECE 331 - Digital System Design

ECE 331 - Digital System Design Binary Codes 6-3-1-1 Code Weighted code with w3 = 6, w2 = 3, w1 = 1, w0 = 1 Excess-3 Code Obtained from the 8-4-2-1 (weighted code). Add 3 (00112) to each of the codes. 2-out-of-5 Code Unweighted code Exactly 2 of the 5 bits are “1” for each valid code. ECE 331 - Digital System Design

ECE 331 - Digital System Design Binary Codes Gray Code(s) Unweighted code Code values for successive decimal digits differ in exactly one bit. Example: 2-bit Gray Code Decimal Binary Gray Code 0 00 00 1 01 01 2 10 11 3 11 10 Where have we seen Gray Code before? ECE 331 - Digital System Design

ECE 331 - Digital System Design 3-bit Gray Code Decimal 1 2 3 4 5 6 7 ECE 331 - Digital System Design

ECE 331 - Digital System Design Binary Code ASCII Code American Standard Code for Information Interchange Common code used for the storage and transfer of alphanumeric characters. 7-bit Weighted Code Can represent a total of 128 characters Used to represent letters, numbers and other characters (e.g. special control characters) Any word or number can be represented (and stored or transferred) using its ASCII Code. ECE 331 - Digital System Design

ECE 331 - Digital System Design Table 5.3 ECE 331 - Digital System Design