Instructor: Alexander Stoytchev CprE 281: Digital Logic.

Slides:



Advertisements
Similar presentations
Lecture Adders Half adder.
Advertisements

Parallel Adder Recap To add two n-bit numbers together, n full-adders should be cascaded. Each full-adder represents a column in the long addition. The.
Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design.
1 CS 140 Lecture 14 Standard Combinational Modules Professor CK Cheng CSE Dept. UC San Diego Some slides from Harris and Harris.
Chapter 6 Arithmetic. Addition Carry in Carry out
ECE 301 – Digital Electronics
Chapter 5 Arithmetic Logic Functions. Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR,
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 4 – Arithmetic Functions Logic and Computer.
Arithmetic Operations and Circuits
CS 105 Digital Logic Design
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
Logical Circuit Design Week 8: Arithmetic Circuits Mentor Hamiti, MSc Office ,
+ CS 325: CS Hardware and Software Organization and Architecture Combinational Circuits 1.
Digital Arithmetic and Arithmetic Circuits
IKI a-Combinatorial Components Bobby Nazief Semester-I The materials on these slides are adopted from those in CS231’s Lecture Notes.
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.
1 Combinational Logic Logic and Digital System Design - CS 303 Erkay Savaş Sabancı University.
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Operations on Bits Arithmetic Operations Logic Operations
COE 202: Digital Logic Design Combinational Circuits Part 2 KFUPM Courtesy of Dr. Ahmad Almulhem.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev
Combinational Circuits
CS221: Digital Logic Design Combinational Circuits
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
ECE 331 – Digital System Design Multi-bit Adder Circuits, Adder/Subtractor Circuit, and Multiplier Circuit (Lecture #12)
CS/EE 3700 : Fundamentals of Digital System Design Chris J. Myers Lecture 5: Arithmetic Circuits Chapter 5 (minus 5.3.4)
1 Chapter 4 Combinational Logic Logic circuits for digital systems may be combinational or sequential. A combinational circuit consists of input variables,
C-H1 Lecture Adders Half adder. C-H2 Full Adder si is the modulo- 2 sum of ci, xi, yi.
CPEN Digital System Design
Addition, Subtraction, Logic Operations and ALU Design
1 ECE 545—Digital System Design with VHDL Lecture 1 Digital Logic Refresher Part A – Combinational Logic Building Blocks.
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.
Addition and multiplication1 Arithmetic is the most basic thing you can do with a computer, but it’s not as easy as you might expect! These next few lectures.
Gunjeet Kaur Dronacharya Group of Institutions. Binary Adder-Subtractor A combinational circuit that performs the addition of two bits is called a half.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev
Reference: Moris Mano 4th Edition Chapter 4
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Chapter 5 – Number Representation and Arithmetic Circuits
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

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

Administrative Stuff HW 6 is out It is due on Monday Oct 4pm

Quick Review

The Full-Adder Circuit [ Figure 3.3c from the textbook ]

The Full-Adder Circuit [ Figure 3.3c from the textbook ] Let's take a closer look at this.

yiyi xixi cici c i+1 = x i y i + (x i + y i )c i Another Way to Draw the Full-Adder Circuit

Decomposing the Carry Expression c i+1 = x i y i + x i c i + y i c i

Decomposing the Carry Expression c i+1 = x i y i + x i c i + y i c i c i+1 = x i y i + (x i + y i )c i

Decomposing the Carry Expression yiyi xixi c i+1 cici c i+1 = x i y i + x i c i + y i c i c i+1 = x i y i + (x i + y i )c i

Another Way to Draw the Full-Adder Circuit yiyi xixi cici c i+1 sisi c i+1 = x i y i + x i c i + y i c i c i+1 = x i y i + (x i + y i )c i

Another Way to Draw the Full-Adder Circuit yiyi xixi cici c i+1 sisi c i+1 = x i y i + (x i + y i )c i

Another Way to Draw the Full-Adder Circuit c i+1 = x i y i + (x i + y i )c i yiyi xixi cici c i+1 sisi gigi pipi

Another Way to Draw the Full-Adder Circuit c i+1 = x i y i + (x i + y i )c i yiyi xixi cici c i+1 sisi gigi pipi gigi pipi

Yet Another Way to Draw It (Just Rotate It) cici c i+1 sisi xixi yiyi pipi gigi

x 1 y 1 g 1 p 1 s 1 Stage 1 x 0 y 0 g 0 p 0 s 0 Stage 0 c 0 c 1 c 2 Now we can Build a Ripple-Carry Adder [ Figure 3.14 from the textbook ]

x 1 y 1 g 1 p 1 s 1 Stage 1 x 0 y 0 g 0 p 0 s 0 Stage 0 c 0 c 1 c 2 Now we can Build a Ripple-Carry Adder [ Figure 3.14 from the textbook ]

x 1 y 1 g 1 p 1 s 1 Stage 1 x 0 y 0 g 0 p 0 s 0 Stage 0 c 0 c 1 c 2 The delay is 5 gates (1+2+2)

x 1 y 1 g 1 p 1 s 1 Stage 1 x 0 y 0 g 0 p 0 s 0 Stage 0 c 0 c 1 c 2 n-bit ripple-carry adder: 2n+1 gate delays...

Decomposing the Carry Expression c i+1 = x i y i + x i c i + y i c i c i+1 = x i y i + (x i + y i )c i gigi pipi c i+1 = g i + p i c i c i+1 = g i + p i (g i-1 + p i-1 c i-1 ) = g i + p i g i-1 + p i p i-1 c i-1

Carry for the first two stages c 1 = g 0 + p 0 c 0 c 2 = g 1 + p 1 g 0 + p 1 p 0 c 0

The first two stages of a carry-lookahead adder [ Figure 3.15 from the textbook ]

It takes 3 gate delays to generate c 1

It takes 3 gate delays to generate c 2

The first two stages of a carry-lookahead adder 2 c

It takes 4 gate delays to generate s 1 2 c

It takes 4 gate delays to generate s 2

N-bit Carry-Lookahead Adder It takes 3 gate delays to generate all carry signals It takes 1 more gate delay to generate all sum bits Thus, the total delay through an n-bit carry-lookahead adder is only 4 gate delays!

Expanding the Carry Expression c 1 = g 0 + p 0 c 0 c 2 = g 1 + p 1 g 0 + p 1 p 0 c 0 c i+1 = g i + p i c i c 3 = g 2 + p 2 g 1 + p 2 p 1 g 0 + p 2 p 1 p 0 c 0 c 8 = g 7 + p 7 g 6 + p 7 p 6 g 5 + p 7 p 6 p 5 g 4 + p 7 p 6 p 5 p 4 g 3 + p 7 p 6 p 5 p 4 p 3 g 2 + p 7 p 6 p 5 p 4 p 3 p 2 g 1 + p 7 p 6 p 5 p 4 p 3 p 2 p 1 g 0 + p 7 p 6 p 5 p 4 p 3 p 2 p 1 p 0 c 0...

Expanding the Carry Expression c 1 = g 0 + p 0 c 0 c 2 = g 1 + p 1 g 0 + p 1 p 0 c 0 c i+1 = g i + p i c i c 3 = g 2 + p 2 g 1 + p 2 p 1 g 0 + p 2 p 1 p 0 c 0 c 8 = g 7 + p 7 g 6 + p 7 p 6 g 5 + p 7 p 6 p 5 g 4 + p 7 p 6 p 5 p 4 g 3 + p 7 p 6 p 5 p 4 p 3 g 2 + p 7 p 6 p 5 p 4 p 3 p 2 g 1 + p 7 p 6 p 5 p 4 p 3 p 2 p 1 g 0 + p 7 p 6 p 5 p 4 p 3 p 2 p 1 p 0 c 0... Even this takes only 3 gate delays

Block x 3124– c 32 c 24 y 3124– s 3124– x 158– c 16 y 158– s 8– c 8 x 70– y 70– s 70– c 0 3 Block 1 0 A hierarchical carry-lookahead adder with ripple-carry between blocks [ Figure 3.16 from the textbook ]

[ Figure 3.17 from the textbook ] A hierarchical carry-lookahead adder

The Hierarchical Carry Expression c 8 = g 7 + p 7 g 6 + p 7 p 6 g 5 + p 7 p 6 p 5 g 4 + p 7 p 6 p 5 p 4 g 3 + p 7 p 6 p 5 p 4 p 3 g 2 + p 7 p 6 p 5 p 4 p 3 p 2 g 1 + p 7 p 6 p 5 p 4 p 3 p 2 p 1 g 0 + p 7 p 6 p 5 p 4 p 3 p 2 p 1 p 0 c 0

The Hierarchical Carry Expression c 8 = g 7 + p 7 g 6 + p 7 p 6 g 5 + p 7 p 6 p 5 g 4 + p 7 p 6 p 5 p 4 g 3 + p 7 p 6 p 5 p 4 p 3 g 2 + p 7 p 6 p 5 p 4 p 3 p 2 g 1 + p 7 p 6 p 5 p 4 p 3 p 2 p 1 g 0 + p 7 p 6 p 5 p 4 p 3 p 2 p 1 p 0 c 0

The Hierarchical Carry Expression c 8 = g 7 + p 7 g 6 + p 7 p 6 g 5 + p 7 p 6 p 5 g 4 + p 7 p 6 p 5 p 4 g 3 + p 7 p 6 p 5 p 4 p 3 g 2 + p 7 p 6 p 5 p 4 p 3 p 2 g 1 + p 7 p 6 p 5 p 4 p 3 p 2 p 1 g 0 + p 7 p 6 p 5 p 4 p 3 p 2 p 1 p 0 c 0 G0G0 P0P0

The Hierarchical Carry Expression c 8 = g 7 + p 7 g 6 + p 7 p 6 g 5 + p 7 p 6 p 5 g 4 + p 7 p 6 p 5 p 4 g 3 + p 7 p 6 p 5 p 4 p 3 g 2 + p 7 p 6 p 5 p 4 p 3 p 2 g 1 + p 7 p 6 p 5 p 4 p 3 p 2 p 1 g 0 + p 7 p 6 p 5 p 4 p 3 p 2 p 1 p 0 c 0 G0G0 P0P0 c 8 = G 0 + P 0 c 0

The Hierarchical Carry Expression c 8 = G 0 + P 0 c 0 c 16 = G 1 + P 1 c 8 = G 1 + P 1 G 0 + P 1 P 0 c 0 c 24 = G 2 + P 2 G 1 + P 2 P 1 G 0 + P 2 P 1 P 0 c 0 c 32 = G 3 + P 3 G 2 + P 3 P 2 G 1 + P 3 P 2 P 1 G 0 + P 3 P 2 P 1 P 0 c 0

[ Figure 3.17 from the textbook ] A hierarchical carry-lookahead adder

Hierarchical CLA Adder Carry Logic C8 – 5 gate delays C16 – 5 gate delays C24 – 5 Gate delays C32 – 5 Gate delays

Hierarchical CLA Critical Path C9 – 7 gate delays C17 – 7 gate delays C25 – 7 Gate delays

Total Gate Delay Through a Hierarchical Carry-Lookahead Adder Is 8 gates  3 to generate all Gj and Pj  +2 to generate c8, c16, c24, and c32  +2 to generate internal carries in the blocks  +1 to generate the sum bits (one extra XOR)

Decimal Multiplication by 10 What happens when we multiply a number by 10? 4 x 10 = ? 542 x 10 = ? 1245 x 10 = ?

Decimal Multiplication by 10 What happens when we multiply a number by 10? 4 x 10 = x 10 = x 10 = 12450

Decimal Multiplication by 10 What happens when we multiply a number by 10? 4 x 10 = x 10 = x 10 = You simply add a zero as the rightmost number

Decimal Division by 10 What happens when we divide a number by 10? 14 / 10 = ? 540 / 10 = ? 1240 x 10 = ?

Decimal Division by 10 What happens when we divide a number by 10? 14 / 10 = 1 //integer division 540 / 10 = x 10 = 124 You simply delete the rightmost number

Binary Multiplication by 2 What happens when we multiply a number by 2? 011 times 2 = ? 101 times 2 = ? times 2 = ?

Binary Multiplication by 2 What happens when we multiply a number by 2? 011 times 2 = times 2 = times 2 = You simply add a zero as the rightmost number

Binary Multiplication by 4 What happens when we multiply a number by 4? 011 times 4 = ? 101 times 4 = ? times 4 = ?

Binary Multiplication by 4 What happens when we multiply a number by 4? 011 times 4 = times 4 = times 4 = add two zeros in the last two bits and shift everything else to the left

Binary Multiplication by 2 N What happens when we multiply a number by 2 N ? 011 times 2 N = 01100…0 // add N zeros 101 times 4 = 10100…0 // add N zeros times 4 = …0 // add N zeros

Binary Division by 2 What happens when we divide a number by 2? 0110 divided by 2 = ? 1010 divides by 2 = ? divides by 2 = ?

Binary Division by 2 What happens when we divide a number by 2? 0110 divided by 2 = divides by 2 = divides by 2 = You simply delete the rightmost number

Decimal Multiplication By Hand [

Binary Multiplication By Hand [Figure 3.34a from the textbook]

Binary Multiplication By Hand [Figure 3.34b from the textbook]

Binary Multiplication By Hand [Figure 3.34c from the textbook]

Figure A 4x4 multiplier circuit.

Positive Multiplicand Example [Figure 3.36a in the textbook]

Positive Multiplicand Example [Figure 3.36a in the textbook] add an extra bit to avoid overflow

Negative Multiplicand Example [Figure 3.36b in the textbook]

Negative Multiplicand Example [Figure 3.36b in the textbook] add an extra bit to avoid overflow but now it is 1

What if the Multiplier is Negative? Convert both to their 2's complement version This will make the multiplier positive Then Proceed as normal This will not affect the result Example: 5*(-4) = (-5)*(4)= -20

Binary Coded Decimal

Table of Binary-Coded Decimal Digits

Addition of BCD digits [Figure 3.38a in the textbook]

Addition of BCD digits [Figure 3.38a in the textbook] The result is greater than 9, which is not a valid BCD number

Addition of BCD digits [Figure 3.38a in the textbook] add 6

Addition of BCD digits [Figure 3.38b in the textbook]

Addition of BCD digits [Figure 3.38b in the textbook] The result is 1, but it should be 7

Addition of BCD digits [Figure 3.38b in the textbook] add 6

Why add 6? Think of BCD addition as a mod 16 operation Decimal addition is mod 10 operation

BCD Arithmetic Rules Z = X + Y If Z <= 9, then S=Z and carry-out = 0 If Z < 9, then S=Z+6 and carry-out =1

Block diagram for a one-digit BCD adder [Figure 3.39 in the textbook]

How to check if the number is > 9?

x1x2x3x4 0000m0 0001m1 0010m2 0011m3 0100m4 0101m5 0110m6 0111m7 1000m8 1001m9 1010m m m m m m15 A four-variable Karnaugh map

z3z2z1z0 0000m0 0001m1 0010m2 0011m3 0100m4 0101m5 0110m6 0111m7 1000m8 1001m9 1010m m m m m m15 How to check if the number is > 9? z 3 z 2 z 1 z

z3z2z1z0 0000m0 0001m1 0010m2 0011m3 0100m4 0101m5 0110m6 0111m7 1000m8 1001m9 1010m m m m m m15 How to check if the number is > 9? z 3 z 2 z 1 z f = z 3 z 2 + z 3 z 1

z3z2z1z0 0000m0 0001m1 0010m2 0011m3 0100m4 0101m5 0110m6 0111m7 1000m8 1001m9 1010m m m m m m15 How to check if the number is > 9? z 3 z 2 z 1 z f = z 3 z 2 + z 3 z 1 In addition, also check if there was a carry f = carry-out + z 3 z 2 + z 3 z 1

modulebcdadd(Cin,X,Y,S, Cout); inputCin; input[3:0] X,Y; outputreg [3:0] S; outputreg Cout; reg[4:0] Z; (X,Y,Cin) begin Z=X+Y+Cin; if(Z<10) {Cout,S}=Z; else {Cout,S}=Z+6; end endmodule Verilog code for a one-digit BCD adder [Figure 3.40 in the textbook]

[Figure 3.41 in the textbook] Circuit for a one-digit BCD adder

[Figure 3.41 in the textbook] Circuit for a one-digit BCD adder carry-out + z 3 z 2 + z 3 z 1

[Figure 3.41 in the textbook] Circuit for a one-digit BCD adder 1

[Figure 3.41 in the textbook] Circuit for a one-digit BCD adder

[Figure 3.41 in the textbook] Circuit for a one-digit BCD adder

[Figure 3.41 in the textbook] Circuit for a one-digit BCD adder add 6 implicit 0

Questions?

THE END