22
Slide 1 Department of Electrical & Computer Engineering COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common Combinational Logic Circuits (Adders and Multipliers) Instructor: Dr. Reza Soleymani, Office: EV-5.125, Telephone: 848-2424 ext.: 4103.

COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 1

Department of Electrical & Computer Engineering

COEN 212:DIGITAL SYSTEMS DESIGN I

Lecture 7: Common Combinational Logic Circuits(Adders and Multipliers)

Instructor: Dr. Reza Soleymani, Office: EV-5.125, Telephone: 848-2424 ext.: 4103.

Page 2: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 2

Department of Electrical & Computer Engineering

Lecture 7: Objectives of this lecture

β€’ In this lecture, we talk about: – Adders.– Subtractors.– Multipliers and,– Magnitude Comaparators.

β€’ In the next lecture, we will talk about:– Decoders, Encoders, Multiplexers

Page 3: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 3

Department of Electrical & Computer Engineering

Lecture 7: Reading for this lecture

β€’ Digital Design by M. Morris R. Mano and Michael D. Ciletti, 6th Edition, Pearson, 2018:– Chapter 4 (4.5 to 4.8)

Page 4: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 4

Department of Electrical & Computer Engineering

Lecture 7:Binary Adders

β€’ Binary numbers are added bit by bit. β€’ To add two bits, we need a Full Adder.β€’ It takes in two bits and a carry and outputs a sum and a carry:

β€’ A full adder can be implemented either directly or using two half adder. A half adder has two inputs and two outputs.

Full Adder: Half Adder:

Page 5: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 5

Department of Electrical & Computer EngineeringLecture 7:Addition: HA

β€’ Truth table for a half adder is:

β€’ So: 𝑆𝑆 = 𝐴𝐴′𝐡𝐡 + 𝐴𝐴𝐡𝐡′ = 𝐴𝐴⨁𝐡𝐡

𝐢𝐢 = 𝐴𝐴𝐡𝐡‒ The implementation is:

𝐴𝐴 𝐡𝐡 𝐢𝐢 𝑆𝑆0 0 0 00 1 0 11 0 0 11 1 1 0

Page 6: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 6

Department of Electrical & Computer EngineeringLecture 7:Addition: HA

β€’ Half adder can also be implemented using XOR:

β€’ Implementing a FA using two HA’s:

Page 7: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 7

Department of Electrical & Computer EngineeringLecture 7:Addition: FA implementation uisng HA’s

β€’ Half adder can also be implemented using XOR:

𝑆𝑆𝑖𝑖 = 𝐴𝐴𝑖𝑖⨁𝐡𝐡𝑖𝑖⨁𝐢𝐢𝑖𝑖‒ Also, : 𝐢𝐢𝑖𝑖+1 = 𝐴𝐴𝑖𝑖𝐡𝐡𝑖𝑖 + 𝐴𝐴𝑖𝑖𝐢𝐢𝑖𝑖 + 𝐡𝐡𝑖𝑖𝐢𝐢𝑖𝑖

= 𝐴𝐴𝑖𝑖 𝐡𝐡𝑖𝑖 + 𝐢𝐢𝑖𝑖 + 𝐡𝐡𝑖𝑖 𝐴𝐴𝑖𝑖 + 𝐢𝐢𝑖𝑖

= 𝐴𝐴𝑖𝑖 𝐡𝐡𝑖𝑖 + 𝐡𝐡𝑖𝑖′𝐢𝐢𝑖𝑖 + 𝐡𝐡𝑖𝑖 𝐴𝐴𝑖𝑖 + 𝐴𝐴𝑖𝑖′𝐢𝐢𝑖𝑖

= 𝐢𝐢𝑖𝑖 𝐴𝐴𝑖𝑖𝐡𝐡𝑖𝑖′ + 𝐴𝐴𝑖𝑖′𝐡𝐡𝑖𝑖 + 𝐴𝐴𝑖𝑖𝐡𝐡𝑖𝑖

= 𝐢𝐢𝑖𝑖 𝐴𝐴𝑖𝑖⨁𝐡𝐡𝑖𝑖 + 𝐴𝐴𝑖𝑖𝐡𝐡𝑖𝑖

Page 8: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 8

Department of Electrical & Computer EngineeringLecture 7:Addition: FA direct implementation

β€’ Truth Table of FA: K-map of S

𝑆𝑆 = π‘₯π‘₯′𝑦𝑦′𝑧𝑧 + π‘₯π‘₯′𝑦𝑦𝑧𝑧𝑧 + π‘₯π‘₯𝑦𝑦′𝑧𝑧𝑧 + π‘₯π‘₯𝑦𝑦𝑧𝑧

K-map of C

𝐢𝐢 = π‘₯π‘₯𝑦𝑦 + π‘₯π‘₯𝑧𝑧 + 𝑦𝑦𝑧𝑧

𝐱𝐱 𝐲𝐲 𝐳𝐳 𝐂𝐂 𝐒𝐒

0 0 0 0 00 0 1 0 10 1 0 0 10 1 1 1 01 0 0 0 11 0 1 1 01 1 0 1 01 1 1 1 1

Page 9: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 9

Department of Electrical & Computer EngineeringLecture 7:Addition: FA direct implementation

β€’ The implementation for 𝑆𝑆

𝑆𝑆 = π‘₯π‘₯′𝑦𝑦′𝑧𝑧 + π‘₯π‘₯′𝑦𝑦𝑧𝑧𝑧 + π‘₯π‘₯𝑦𝑦′𝑧𝑧𝑧 + π‘₯π‘₯𝑦𝑦𝑧𝑧

β€’ The implementation for 𝐢𝐢

𝐢𝐢 = π‘₯π‘₯𝑦𝑦 + π‘₯π‘₯𝑧𝑧 + 𝑦𝑦𝑧𝑧

Page 10: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 10

Department of Electrical & Computer EngineeringLecture 7:Binary adders/carry propagationβ€’ Four-bit adder: Delay 2m = 2 Γ— 4 = 8

β€’ Carry Lookahead

Page 11: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 11

Department of Electrical & Computer EngineeringLecture 7:Binary adders/carry Lookaheadβ€’ Note that 𝐺𝐺𝑖𝑖 generates a carry when both the inputs 𝐴𝐴𝑖𝑖 and 𝐡𝐡𝑖𝑖

are 1 regardless of the value of 𝐢𝐢𝑖𝑖. β€’ 𝐺𝐺𝑖𝑖 is called a carry generator.β€’ 𝑃𝑃𝑖𝑖 decides whether a carry will propagate from stage 𝑖𝑖 to

stage 𝑖𝑖 + 1. It is called a carry propagator.β€’ Note that 𝑃𝑃𝑖𝑖 and 𝐺𝐺𝑖𝑖 are generated from 𝐴𝐴𝑖𝑖 and 𝐡𝐡𝑖𝑖 in one gate

delay. β€’ Now, let’s consider the example of 4-bit adder.β€’ 𝐢𝐢0 = the input carryβ€’ 𝐢𝐢1 = 𝐺𝐺0 + 𝑃𝑃0𝐢𝐢0β€’ 𝐢𝐢2 = 𝐺𝐺1 + 𝑃𝑃1𝐢𝐢1 = 𝐺𝐺1 + 𝑃𝑃1 𝐺𝐺0 + 𝑃𝑃0𝐢𝐢0 = 𝐺𝐺1 + 𝑃𝑃1𝐺𝐺0 + 𝑃𝑃1𝑃𝑃0𝐢𝐢0β€’ 𝐢𝐢3 = 𝐺𝐺2 + 𝑃𝑃2𝐢𝐢2 = 𝐺𝐺2 + 𝑃𝑃2𝐺𝐺1 + 𝑃𝑃2𝑃𝑃1𝐺𝐺0 + 𝑃𝑃2𝑃𝑃1𝑃𝑃0𝐢𝐢0

Page 12: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 12

Department of Electrical & Computer EngineeringLecture 7:Binary adders/carry Lookahead

β€’ carry lookahead generator:

Page 13: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 13

Department of Electrical & Computer EngineeringLecture 7:Binary adders/carry Lookahead

β€’ carry lookahead generator:

Page 14: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 14

Department of Electrical & Computer Engineering

Lecture 7:Subtraction:

β€’ Adder/Subtractor:

β€’ When 𝑀𝑀 = 0, we get 𝐴𝐴+𝐡𝐡.β€’ When 𝑀𝑀 = 1, we get A-B.β€’ V=1 flags an overflow.

Page 15: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 15

Department of Electrical & Computer Engineering

Lecture 7:Subtraction: Example

β€’ Example: 8-bit adder.β€’ Numbers are from -127 to +127 (from 11111111 to 01111111).β€’ The result may fall out of range.β€’ Example: Adding +60 and +70 = 130 > 127

+60 00111100 +70 01000110

+130 10000010 β†’ -2

β€’ Subtraction +70 from -60-60 11000100-70 10111010-130 1 01111110 β†’ +1

sign bit

overflow

Page 16: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 16

Department of Electrical & Computer Engineering

Lecture 7:BCD Adder

β€’ Adding two decimal digits and a carry, we get a number between 0 and 19.

Page 17: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 17

Department of Electrical & Computer Engineering

Lecture 7:BCD Adder

β€’ 𝐢𝐢 = 1 whenever 𝐾𝐾 = 1 or 𝑍𝑍8 = 1.β€’ 𝐢𝐢 = 0 when 𝑍𝑍8 = 1 and both 𝑍𝑍4 and 𝑍𝑍2 are zero. β€’ So,

𝐢𝐢 = 𝐾𝐾 + 𝑍𝑍8 𝑍𝑍2 + 𝑍𝑍4 = 𝐾𝐾 + 𝑍𝑍8𝑍𝑍4 + 𝑍𝑍8𝑍𝑍2β€’ When 𝐢𝐢 = 1, we need to add 6 (0110) to 𝑍𝑍8𝑍𝑍4𝑍𝑍2𝑍𝑍1 to get

𝑆𝑆8𝑆𝑆4𝑆𝑆2𝑆𝑆1.

Page 18: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 18

Department of Electrical & Computer Engineering

Lecture 7:Binary multiplication

β€’ 𝐢𝐢 = 1 whenever 𝐾𝐾 = 1 or 𝑍𝑍8 = 1.

β€’ 2-by-2 multiplier:

multiplying 𝐡𝐡1𝐡𝐡0 by 𝐴𝐴1and shifting the result

multiplying 𝐡𝐡1𝐡𝐡0 by 𝐴𝐴0

Page 19: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 19

Department of Electrical & Computer Engineering

Lecture 7:Binary multiplication

β€’ Example: 4-bit by 3-bit multiplier

𝐡𝐡3 𝐡𝐡2 𝐡𝐡1 𝐡𝐡0

𝐴𝐴2 𝐴𝐴1 𝐴𝐴0

𝐴𝐴0𝐡𝐡3 𝐴𝐴0𝐡𝐡2 𝐴𝐴0𝐡𝐡1 𝐴𝐴0𝐡𝐡0

𝐴𝐴1𝐡𝐡3 𝐴𝐴1𝐡𝐡2 𝐴𝐴1𝐡𝐡1 𝐴𝐴1𝐡𝐡0

𝐴𝐴2𝐡𝐡3 𝐴𝐴2𝐡𝐡2 𝐴𝐴2𝐡𝐡1 𝐴𝐴2𝐡𝐡0

𝐢𝐢6 𝐢𝐢5 𝐢𝐢4 𝐢𝐢3 𝐢𝐢2 𝐢𝐢1 𝐢𝐢0

Page 20: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 20

Department of Electrical & Computer Engineering

Lecture 7:Magnitude Comparator

β€’ It compares two numbers 𝐴𝐴 = 𝐴𝐴3𝐴𝐴2𝐴𝐴1𝐴𝐴0 and 𝐡𝐡 = 𝐡𝐡3𝐡𝐡2𝐡𝐡1𝐡𝐡0 and decides whether 𝐴𝐴 = 𝐡𝐡,𝐴𝐴 > 𝐡𝐡 or 𝐴𝐴 < 𝐡𝐡.

β€’ 𝐴𝐴 = 𝐡𝐡 if and only if 𝐴𝐴3 = 𝐡𝐡3,𝐴𝐴2 = 𝐡𝐡2,𝐴𝐴1 = 𝐡𝐡1,𝐴𝐴0 = 𝐡𝐡0.β€’ 𝐴𝐴3 = 𝐡𝐡3 if 𝑋𝑋3 = 𝐴𝐴3𝐡𝐡3 + 𝐴𝐴3β€² 𝐡𝐡3β€² .β€’ Similarly 𝑋𝑋𝑖𝑖 = 𝐴𝐴𝑖𝑖𝐡𝐡𝑖𝑖 + 𝐴𝐴𝑖𝑖′𝐡𝐡𝑖𝑖′ , 𝑖𝑖 = 0, 1, 2, 3 shows 𝐴𝐴𝑖𝑖 = 𝐡𝐡𝑖𝑖.β€’ So: 𝐴𝐴 = 𝐡𝐡 = 𝑋𝑋3𝑋𝑋2𝑋𝑋1𝑋𝑋0.β€’ Case of: 𝐴𝐴 > 𝐡𝐡: 𝐴𝐴 > 𝐡𝐡‒ If 𝐴𝐴3 is equal to 1 and 𝐡𝐡3 = 0. So, if 𝐴𝐴3𝐡𝐡3β€² = 1, then 𝐴𝐴 > 𝐡𝐡. β€’ If 𝐴𝐴3 = 𝐡𝐡3, i.e., if 𝑋𝑋3 = 1 and 𝐴𝐴2 = 1 and 𝐡𝐡2 = 0, i.e., if 𝑋𝑋3𝐴𝐴2𝐡𝐡2β€² = 1.β€’ if 𝑋𝑋3𝑋𝑋2𝐴𝐴1𝐡𝐡1β€² = 1 or 𝑋𝑋3𝑋𝑋2𝑋𝑋1𝐴𝐴0𝐡𝐡0β€² = 1.

𝐴𝐴 > 𝐡𝐡 = 𝐴𝐴3𝐡𝐡3β€² + 𝑋𝑋3𝐴𝐴2𝐡𝐡2β€² + 𝑋𝑋3𝑋𝑋2𝐴𝐴1𝐡𝐡1β€² + 𝑋𝑋3𝑋𝑋2𝑋𝑋1𝐴𝐴0𝐡𝐡0β€²

and𝐴𝐴 < 𝐡𝐡 = 𝐴𝐴3β€² 𝐡𝐡3 + 𝑋𝑋3𝐴𝐴2β€² 𝐡𝐡2 + 𝑋𝑋3𝑋𝑋2𝐴𝐴1β€² 𝐡𝐡1 + 𝑋𝑋3𝑋𝑋2𝑋𝑋1𝐴𝐴0β€² 𝐡𝐡0

Page 21: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 21

Department of Electrical & Computer Engineering

Lecture 7:Magnitude Comparator

β€’ 4-bit Magnitude Comparator:

Page 22: COEN 212: DIGITAL SYSTEMS DESIGN I Lecture 7: Common ...msoleyma/COEN212/COEN212_2020/Lectu… · Lecture 7: Binary adders/carry Lookahead β€’ Note that 𝐺𝐺 𝑖𝑖 generates

Slide 22

Department of Electrical & Computer Engineering

Lecture 7:Knowledge Check

β€’ Question 1: To add two 8-bit numbers, the number of Half-Adders needed is:

β€’ a) 8, b) 15, c) 16, d) 17β€’ Question 2: If the gate delay is 10 ns (nano seconds), what

would be the delay in adding two 8 bit numbers using carry look ahead?

β€’ a) 40 ns, b) 160 ns, c) 80 ns, d) 20 ns

β€’ Question 3: