Instructor: Alexander Stoytchev CprE 281: Digital Logic.

Slides:



Advertisements
Similar presentations
Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design.
Advertisements

Overview Iterative combinational circuits Binary adders
Design of Arithmetic Circuits – Adders, Subtractors, BCD adders
Overview Iterative combinational circuits Binary adders
Overview Iterative combinational circuits Binary adders
CS 105 Digital Logic Design
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Logic Design CS221 1 st Term combinational circuits Cairo University Faculty of Computers and Information.
Basic Arithmetic (adding and subtracting)
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals.
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
Figure 5.1 Conversion from decimal to binary. Table 5.1 Numbers in different systems.
Logic Gates Logic gates are electronic digital circuit perform logic functions. Commonly expected logic functions are already having the corresponding.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Logic Design CS221 1 st Term combinational circuits Cairo University Faculty of Computers and Information.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
1 Lecture 14 Binary Adders and Subtractors. 2 Overview °Addition and subtraction of binary data is fundamental Need to determine hardware implementation.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
President UniversityErwin SitompulDigital Systems 7/1 Lecture 7 Digital Systems Dr.-Ing. Erwin Sitompul President University
1 Digital Logic Design (41-135) Chapter 5 Number Representation & Arithmetic Circuits Younglok Kim Dept. of Electrical Engineering Sogang University Spring.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
ELL100: INTRODUCTION TO ELECTRICAL ENGG.
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Presentation transcript:

Instructor: Alexander Stoytchev CprE 281: Digital Logic

Signed Numbers CprE 281: Digital Logic Iowa State University, Ames, IA Copyright © Alexander Stoytchev

Administrative Stuff HW 5 is due today

Administrative Stuff No homework is due next week.

Administrative Stuff Labs Next Week Mini-Project This one is worth 3% of your grade. Make sure to get all the points.

Administrative Stuff Midterm Exam #1 When: Monday Feb 24. Where: This classroom What: Chapter 1 and Chapter 2 plus number systems The exam will be open book and open notes (you can bring up to 3 pages of handwritten notes).

Topics for the Midterm Exam Binary Numbers Octal Numbers Hexadecimal Numbers Conversion between the different number systems Truth Tables Boolean Algebra Logic Gates Circuit Synthesis with AND, OR, NOT Circuit Synthesis with NAND, NOR Converting an AND/OR/NOT circuit to NAND circuit Converting an AND/OR/NOT circuit to NOR circuit SOP and POS expressions

Topics for the Midterm Exam Mapping a Circuit to Verilog code Mapping Verilog code to a circuit Multiplexers Venn Diagrams K-maps for 2, 3, and 4 variables Minimization of Boolean expressions using theorems Minimization of Boolean expressions with K-maps Incompletely specified functions (with don’t cares) Functions with multiple outputs

Quick Review

[ Figure 3.1a from the textbook ] Adding two bits (there are four possible cases)

[ Figure 3.1b from the textbook ] Adding two bits (the truth table)

[ Figure 3.1c from the textbook ] Adding two bits (the logic circuit)

[ Figure 3.1c-d from the textbook ] The Half-Adder

Bit position i Addition of multibit numbers [ Figure 3.2 from the textbook ]

Problem Statement and Truth Table [ Figure 3.3a from the textbook ][ Figure 3.2b from the textbook ]

Let’s fill-in the two K-maps [ Figure 3.3a-b from the textbook ]

Let’s fill-in the two K-maps [ Figure 3.3a-b from the textbook ]

The circuit for the two expressions [ Figure 3.3c from the textbook ]

This is called the Full-Adder [ Figure 3.3c from the textbook ]

XOR Magic (s i can be implemented in two different ways)

HA s c s c c i x i y i c i1+ s i c i x i y i c i1+ s i (a) Block diagram (b) Detailed diagram A decomposed implementation of the full-adder circuit [ Figure 3.4 from the textbook ]

HA s c s c c i x i y i c i1+ s i The Full-Adder Abstraction

FA c i x i y i c i1+ s i The Full-Adder Abstraction

FA We can place the arrows anywhere xixi yiyi sisi c i+1 cici

FA x n –1 c n c n1” y n1– s n1– FA x 1 c 2 y 1 s 1 c 1 x 0 y 0 s 0 c 0 MSB positionLSB position n-bit ripple-carry adder [ Figure 3.5 from the textbook ]

FA x n –1 c n c n1” y n1– s n1– FA x 1 c 2 y 1 s 1 c 1 x 0 y 0 s 0 c 0 MSB positionLSB position n-bit ripple-carry adder abstraction

x n –1 c n y n1– s n1– x 1 y 1 s 1 x 0 y 0 s 0 c 0 n-bit ripple-carry adder abstraction

The x and y lines are typically grouped together for better visualization, but the underlying logic remains the same x n –1 c n y n1– s n1– x 1 y 1 s 1 y 0 s 0 c 0 x 0

Math Review: Subtraction ??

Math Review: Subtraction

Math Review: Subtraction ?? ?? ??

Math Review: Subtraction

Math Review: Subtraction ?? ?? ??

Math Review: Subtraction

The problems in which row are easier to calculate? ?? ?? ?? ?? ?? ??

The problems in which row are easier to calculate? Why?

Another Way to Do Subtraction 82 – 64 = –

Another Way to Do Subtraction 82 – 64 = – = 82 + (100 – 64) - 100

Another Way to Do Subtraction 82 – 64 = – = 82 + (100 – 64) = 82 + ( – 64) - 100

Another Way to Do Subtraction 82 – 64 = – = 82 + (100 – 64) = 82 + ( – 64) = 82 + (99 – 64)

Another Way to Do Subtraction 82 – 64 = – = 82 + (100 – 64) = 82 + ( – 64) = 82 + (99 – 64) Does not require borrows

9’s Complement (subtract each digit from 9)

10’s Complement (subtract each digit from 9 and add 1 to the result) = 36

Another Way to Do Subtraction 82 – 64 = 82 + (99 – 64)

Another Way to Do Subtraction 82 – 64 = 82 + (99 – 64) ’s complement

Another Way to Do Subtraction 82 – 64 = 82 + (99 – 64) = ’s complement

Another Way to Do Subtraction 82 – 64 = 82 + (99 – 64) = ’s complement 10’s complement

Another Way to Do Subtraction 82 – 64 = 82 + (99 – 64) = ’s complement = ’s complement // add the first two

Another Way to Do Subtraction 82 – 64 = 82 + (99 – 64) = = ’s complement = = 18 10’s complement // add the first two // delete the leading 1

b n1– b 1 b 0 Magnitude MSB (a) Unsigned number b n1– b 1 b 0 Magnitude Sign (b) Signed number b n2– 0 denotes 1 denotes + –MSB Formats for representation of integers [ Figure 3.7 from the textbook ]

Sign and magnitude 1’s complement 2’s complement Negative numbers can be represented in following ways

Let K be the negative equivalent of an n-bit positive number P. Then, in 1’s complement representation K is obtained by subtracting P from 2 n – 1, namely K = (2 n – 1) – P This means that K can be obtained by inverting all bits of P. 1’s complement

Find the 1’s complement of …

Find the 1’s complement of … Just flip 1's to 0's and vice versa.

Example of 1’s complement addition () 2+ () 7+ () +

Example of 1’s complement addition [ Figure 3.8 from the textbook ] () 5–  3-  +

Example of 1’s complement addition [ Figure 3.8 from the textbook ] () 3+ () + 2– 

Example of 1’s complement addition [ Figure 3.8 from the textbook ] –  7–  + 2– 

Let K be the negative equivalent of an n-bit positive number P. Then, in 2’s complement representation K is obtained by subtracting P from 2 n, namely K = 2 n – P 2’s complement

For a positive n-bit number P, let K 1 and K 2 denote its 1’s and 2’s complements, respectively. K 1 = (2 n – 1) – P K 2 = 2 n – P Since K 2 = K 1 + 1, it is evident that in a logic circuit the 2’s complement can computed by inverting all bits of P and then adding 1 to the resulting 1’s-complement number. Deriving 2’s complement

Find the 2’s complement of …

Find the 2’s complement of …

Quick Way to find 2’s complement Scan the binary number from right to left Copy all bit that are 0 from right to left Stop at the first 1 Copy that 1 as well Invert all remaining bits

[ Table 3.2 from the textbook ] Interpretation of four-bit signed integers

Example of 2’s complement addition [ Figure 3.9 from the textbook ] () 2+ () 7+ () +

Example of 2’s complement addition [ Figure 3.9 from the textbook ] () 5–  3–  +

Example of 2’s complement addition [ Figure 3.9 from the textbook ] ignore 5+ () 3+ () + 2– 

Example of 2’s complement addition [ Figure 3.9 from the textbook ] ignore 5–  7–  + 2– 

Example of 2’s complement subtraction – () 2+ () 3+ () – 1 ignore [ Figure 3.10 from the textbook ]

Example of 2’s complement subtraction [ Figure 3.10 from the textbook ] – – 1 ignore –  7–  2+ ()

Example of 2’s complement subtraction [ Figure 3.10 from the textbook ] – () 7+ () – – 

Example of 2’s complement subtraction [ Figure 3.10 from the textbook ] – – –  5–  3– 

[ Figure 3.11 from the textbook ] Graphical interpretation of four-bit 2’s complement numbers

Take Home Message Subtraction can be performed by simply adding the 2’s complement of the second number, regardless of the signs of the two numbers. Thus, the same adder circuit can be used to perform both addition and subtraction !!!

s 0 s 1 s n1– x 0 x 1 x n1– c n n-bit adder y 0 y 1 y n1– c 0 Add  Sub control [ Figure 3.12 from the textbook ] Adder/subtractor unit

XOR Tricks y control out

y 0 y XOR as a repeater

y 1 y XOR as an inverter

s 0 s 1 s n1– x 0 x 1 x n1– c n n-bit adder y 0 y 1 y n1– c 0 Add  Sub control [ Figure 3.12 from the textbook ] Addition: when control = 0

s 0 s 1 s n1– x 0 x 1 x n1– c n n-bit adder y 0 y 1 y n1– c 0 Add  Sub control [ Figure 3.12 from the textbook ] Addition: when control =

s 0 s 1 s n1– x 0 x 1 x n1– c n n-bit adder y 0 y 1 y n1– c 0 Add  Sub control [ Figure 3.12 from the textbook ] Addition: when control = y n-1 y1y1 y0y0 …

s 0 s 1 s n1– x 0 x 1 x n1– c n n-bit adder y 0 y 1 y n1– c 0 Add  Sub control [ Figure 3.12 from the textbook ] Subtraction: when control = 1

s 0 s 1 s n1– x 0 x 1 x n1– c n n-bit adder y 0 y 1 y n1– c 0 Add  Sub control [ Figure 3.12 from the textbook ] Subtraction: when control =

s 0 s 1 s n1– x 0 x 1 x n1– c n n-bit adder y 0 y 1 y n1– c 0 Add  Sub control [ Figure 3.12 from the textbook ] Subtraction: when control = y n-1 y1y1 y0y0 …

s 0 s 1 s n1– x 0 x 1 x n1– c n n-bit adder y 0 y 1 y n1– c 0 Add  Sub control [ Figure 3.12 from the textbook ] Subtraction: when control = y n-1 y1y1 y0y0 … 1 carry for the first column!

() 2+ () 9+ () () 5+ () + 2–  11 c 4 0= c 3 1= c 4 0= c 3 0= c 4 1= c 3 1= c 4 1= c 3 0= 2+ () 7–  5–  + 7–  9–  +2–  Examples of determination of overflow [ Figure 3.13 from the textbook ]

() 2+ () 9+ () () 5+ () + 2–  11 c 4 0= c 3 1= c 4 0= c 3 0= c 4 1= c 3 1= c 4 1= c 3 0= 2+ () 7–  5–  + 7–  9–  +2–  Examples of determination of overflow [ Figure 3.13 from the textbook ] Overflow occurs only in these two cases.

() 2+ () 9+ () () 5+ () + 2–  11 c 4 0= c 3 1= c 4 0= c 3 0= c 4 1= c 3 1= c 4 1= c 3 0= 2+ () 7–  5–  + 7–  9–  +2–  Examples of determination of overflow [ Figure 3.13 from the textbook ] Overflow occurs only in these two cases. Overflow = c 3 c 4 + c 3 c 4

() 2+ () 9+ () () 5+ () + 2–  11 c 4 0= c 3 1= c 4 0= c 3 0= c 4 1= c 3 1= c 4 1= c 3 0= 2+ () 7–  5–  + 7–  9–  +2–  Examples of determination of overflow [ Figure 3.13 from the textbook ] Overflow occurs only in these two cases. Overflow = c 3 c 4 + c 3 c 4 XOR

Calculating overflow for 4-bit numbers with only three significant bits

Calculating overflow for n-bit numbers with only n-1 significant bits

Another way to look at the overflow issue

If both numbers that we are adding have the same sign but the sum does not, then we have an overflow.

Questions?

THE END