coen 212: digital systems design i lecture 7: common ...msoleyma/coen212/coen212_2020/lectuโ€ฆย ยท...

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.

Upload: others

Post on 30-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

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: