CprE 281: Digital Logic

Similar documents
CprE 281: Digital Logic

CprE 281: Digital Logic

CprE 281: Digital Logic

CprE 281: Digital Logic

CprE 281: Digital Logic

Carry Look Ahead Adders

CprE 281: Digital Logic

Chapter 5 Arithmetic Circuits

Combinational Logic. Mantıksal Tasarım BBM231. section instructor: Ufuk Çelikcan

COE 202: Digital Logic Design Combinational Circuits Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

CS 140 Lecture 14 Standard Combinational Modules

1 Short adders. t total_ripple8 = t first + 6*t middle + t last = 4t p + 6*2t p + 2t p = 18t p

Combinational Logic. By : Ali Mustafa

ARITHMETIC COMBINATIONAL MODULES AND NETWORKS

CprE 281: Digital Logic

CprE 281: Digital Logic

Module 2. Basic Digital Building Blocks. Binary Arithmetic & Arithmetic Circuits Comparators, Decoders, Encoders, Multiplexors Flip-Flops

CprE 281: Digital Logic

Combinational Logic Design Arithmetic Functions and Circuits

CprE 281: Digital Logic

Systems I: Computer Organization and Architecture

Combinational Logic. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C.

14:332:231 DIGITAL LOGIC DESIGN

Number System. Decimal to binary Binary to Decimal Binary to octal Binary to hexadecimal Hexadecimal to binary Octal to binary

Adders, subtractors comparators, multipliers and other ALU elements

Adders, subtractors comparators, multipliers and other ALU elements

Chapter 4. Combinational: Circuits with logic gates whose outputs depend on the present combination of the inputs. elements. Dr.

Digital Logic (2) Boolean Algebra

Midterm Exam Two is scheduled on April 8 in class. On March 27 I will help you prepare Midterm Exam Two.

Logic and Computer Design Fundamentals. Chapter 5 Arithmetic Functions and Circuits

Chapter 03: Computer Arithmetic. Lesson 03: Arithmetic Operations Adder and Subtractor circuits Design

Number representation

Total Time = 90 Minutes, Total Marks = 50. Total /50 /10 /18

UNIT 4 MINTERM AND MAXTERM EXPANSIONS

CprE 281: Digital Logic

CprE 281: Digital Logic

L8/9: Arithmetic Structures

CSE370 HW3 Solutions (Winter 2010)

Cs302 Quiz for MID TERM Exam Solved

Combinational Logic. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C.

Numbers and Arithmetic

Binary addition by hand. Adding two bits

Computer Architecture. ESE 345 Computer Architecture. Design Process. CA: Design process

Total Time = 90 Minutes, Total Marks = 100. Total /10 /25 /20 /10 /15 /20

UNSIGNED BINARY NUMBERS DIGITAL ELECTRONICS SYSTEM DESIGN WHAT ABOUT NEGATIVE NUMBERS? BINARY ADDITION 11/9/2018

Class Website:

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

EECS150. Arithmetic Circuits

ECE 545 Digital System Design with VHDL Lecture 1. Digital Logic Refresher Part A Combinational Logic Building Blocks

Digital Integrated Circuits A Design Perspective. Arithmetic Circuits. Jan M. Rabaey Anantha Chandrakasan Borivoje Nikolic.

CSEE 3827: Fundamentals of Computer Systems. Combinational Circuits

CSE 20 DISCRETE MATH. Fall

Overview. Arithmetic circuits. Binary half adder. Binary full adder. Last lecture PLDs ROMs Tristates Design examples

UNIVERSITI TENAGA NASIONAL. College of Information Technology

Review. EECS Components and Design Techniques for Digital Systems. Lec 18 Arithmetic II (Multiplication) Computer Number Systems

Digital System Design Combinational Logic. Assoc. Prof. Pradondet Nilagupta

Resource Efficient Design of Quantum Circuits for Quantum Algorithms

Chapter 5. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 5 <1>

Building a Computer Adder

Laboratory Exercise #10 An Introduction to High-Speed Addition

DIGITAL TECHNICS. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

EECS150 - Digital Design Lecture 10 - Combinational Logic Circuits Part 1

Homework 4 due today Quiz #4 today In class (80min) final exam on April 29 Project reports due on May 4. Project presentations May 5, 1-4pm

COE 202: Digital Logic Design Sequential Circuits Part 4. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

Solutions for Appendix C Exercises

Design of Sequential Circuits

ECE 2300 Digital Logic & Computer Organization

ECE380 Digital Logic. Positional representation

2 Application of Boolean Algebra Theorems (15 Points - graded for completion only)

Floating Point Representation and Digital Logic. Lecture 11 CS301

Review for Test 1 : Ch1 5

Numbers & Arithmetic. Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University. See: P&H Chapter , 3.2, C.5 C.

EECS150 - Digital Design Lecture 19 - Combinational Logic Circuits : A Deep Dive

Fundamentals of Digital Design

Module half adder module half_adder(output S,C,input x,y); xor(s,x,y); and(c,x,y); endmodule

A B OUT_0 OUT_1 OUT_2 OUT_

ECE 2300 Digital Logic & Computer Organization

Digital Design for Multiplication

CMPUT 329. Circuits for binary addition

Numbers and Arithmetic

Hakim Weatherspoon CS 3410 Computer Science Cornell University

EECS 427 Lecture 8: Adders Readings: EECS 427 F09 Lecture 8 1. Reminders. HW3 project initial proposal: due Wednesday 10/7

UNIT II COMBINATIONAL CIRCUITS:

Lecture 10: Synchronous Sequential Circuits Design

Arithmetic Building Blocks

Review Problem 1. should be on. door state, false if light should be on when a door is open. v Describe when the dome/interior light of the car

IT T35 Digital system desigm y - ii /s - iii

Bit-Sliced Design. EECS 141 F01 Arithmetic Circuits. A Generic Digital Processor. Full-Adder. The Binary Adder

ECE 341. Lecture # 3

Sample Test Paper - I

WORKBOOK. Try Yourself Questions. Electrical Engineering Digital Electronics. Detailed Explanations of

Hardware Design I Chap. 4 Representative combinational logic

EECS150 - Digital Design Lecture 24 - Arithmetic Blocks, Part 2 + Shifters

14:332:231 DIGITAL LOGIC DESIGN. 2 s-complement Representation

CSE140: Components and Design Techniques for Digital Systems. Decoders, adders, comparators, multipliers and other ALU elements. Tajana Simunic Rosing

Combina-onal Logic Chapter 4. Topics. Combina-on Circuit 10/13/10. EECE 256 Dr. Sidney Fels Steven Oldridge

Digital Integrated Circuits A Design Perspective. Arithmetic Circuits. Jan M. Rabaey Anantha Chandrakasan Borivoje Nikolic.

SAMPLE ANSWERS MARKER COPY

CSE140: Components and Design Techniques for Digital Systems. Logic minimization algorithm summary. Instructor: Mohsen Imani UC San Diego

ECE 645: Lecture 2. Carry-Lookahead, Carry-Select, & Hybrid Adders

Transcription:

CprE 281: Digital Logic Instructor: Alexander Stoytchev http://www.ece.iastate.edu/~alexs/classes/

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

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

Quick Review

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

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

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

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 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 c i y i x i c i+1

Another Way to Draw the Full-Adder Circuit 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 c i y i s i x i c i+1

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

Another Way to Draw the Full-Adder Circuit c i+1 = x i y i + (x i + y i )c i g i p i c i y i s i x i c i+1

Another Way to Draw the Full-Adder Circuit c i+1 = x i y i + (x i + y i )c i g i p i c i y i s i x i p i g i c i+1

Yet Another Way to Draw It (Just Rotate It) x i y i g i p i c i c i+1 s i

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

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

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

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

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 g i p i 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 x 1 y 1 x 0 y 0 x 0 y 0 g 1 p 1 g 0 p 0 c 0 c 2 c 1 s 1 s 0 [ Figure 3.15 from the textbook ]

It takes 3 gate delays to generate c 1 x 1 y 1 x 0 y 0 x 0 y 0 g 1 p 1 g 0 p 0 c 0 c 2 c 1 s 1 s 0

It takes 3 gate delays to generate c 2 x 1 y 1 x 0 y 0 x 0 y 0 g 1 p 1 g 0 p 0 c 0 c 2 c 1 s 1 s 0

The first two stages of a carry-lookahead adder x 1 y 1 x 0 y 0 x 0 y 0 g 1 p 1 g 0 p 0 c 0 c 2 c 1 s 1 s 0

It takes 4 gate delays to generate s 1 x 1 y 1 x 0 y 0 x 0 y 0 g 1 p 1 g 0 p 0 c 0 c 2 c 1 s 1 s 0

It takes 4 gate delays to generate s 2 x 1 y 1 x 0 y 0 x 0 y 0 g 1 p 1 g 0 p 0 c 0 c 2 c 1 s 2 s 1 s 0

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 i+1 = g i + p i c i c 1 = g 0 + p 0 c 0 c 2 = g 1 + p 1 g 0 + p 1 p 0 c 0 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 i+1 = g i + p i c i c 1 = g 0 + p 0 c 0 c 2 = g 1 + p 1 g 0 + p 1 p 0 c 0 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 Even this takes only 3 gate delays + 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

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

A hierarchical carry-lookahead adder x 31 24 y 31 24 x 15 8 y 15 8 x 7 0 y 7 0 Block 3 c 24 Block 1 Block 0 c 0 G 3 P 3 G 1 P 1 G 0 P 0 s 31 24 s 15 8 s 7 0 c 32 c 16 c 8 Second-level lookahead [ Figure 3.17 from the textbook ]

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 G 0 + 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 P 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 G 0 + 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 P 0 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

A hierarchical carry-lookahead adder x 31 24 y 31 24 x 15 8 y 15 8 x 7 0 y 7 0 Block 3 c 24 Block 1 Block 0 c 0 G 3 P 3 G 1 P 1 G 0 P 0 s 31 24 s 15 8 s 7 0 c 32 c 16 c 8 Second-level lookahead [ Figure 3.17 from the textbook ]

Hierarchical CLA Adder Carry Logic Block 2 P1 P0 c0 p7 x7 y7 g7 x6 y6 p7g6 g6 p7p6g5 p7p6p5g4 Block 1 p7p6p5p4g3 p7p6p5p4p3g2 p7p6p5p4p3p2g1 p7p6p5p4p3p2p1g0 P0 c0 C8 5 gate delays C16 5 gate delays C24 5 Gate delays C32 5 Gate delays SECOND LEVEL HIERARCHY c16 G1 P1 G0 P0 c0 c8 P1 G0 G0 P1 P0 c0 Block 3 Block 2 Block 1 c0 p17 c17 p9 c9 p0 c1 g17 g9 g0 FIRST LEVEL HIERARCHY

Hierarchical CLA Critical Path Block 2 p7 x7 y7 g7 x6 y6 p7g6 g6 p7p6g5 p7p6p5g4 Block 1 p7p6p5p4g3 p7p6p5p4p3g2 p7p6p5p4p3p2g1 p7p6p5p4p3p2p1g0 G1 G0 P0 c0 c8 P1 P1 G0 G0 P1 P0 c0 c16 P1 P0 c0 P0 c0 C9 7 gate delays C17 7 gate delays C25 7 Gate delays SECOND LEVEL HIERARCHY Block 3 Block 2 Block 1 c0 p17 c17 p9 c9 p0 c1 g17 g9 g0 FIRST LEVEL HIERARCHY

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 = 40 542 x 10 = 5420 1245 x 10 = 12450

Decimal Multiplication by 10 What happens when we multiply a number by 10? 4 x 10 = 40 542 x 10 = 5420 1245 x 10 = 12450 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 = 54 1240 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 =? 110011 times 2 =?

Binary Multiplication by 2 What happens when we multiply a number by 2? 011 times 2 = 0110 101 times 2 = 1010 110011 times 2 = 1100110 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 =? 110011 times 4 =?

Binary Multiplication by 4 What happens when we multiply a number by 4? 011 times 4 = 01100 101 times 4 = 10100 110011 times 4 = 11001100 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 110011 times 4 = 11001100 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 =? 110011 divides by 2 =?

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

Decimal Multiplication By Hand [http://www.ducksters.com/kidsmath/long_multiplication.php]

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 3.35. A 4x4 multiplier circuit.

Figure 3.35. A 4x4 multiplier circuit.

Positive Multiplicand Example [Figure 3.36a in the textbook]

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

Negative Multiplicand Example [Figure 3.36b in the textbook]

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

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 The result is greater than 9, which is not a valid BCD number [Figure 3.38a in the textbook]

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

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

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

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

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? 7-0111 8-1000 9-1001 10-1010 11-1011 12-1100 13-1101 14-1110 15-1111

A four-variable Karnaugh map x1 x2 x3 x4 0 0 0 0 m0 0 0 0 1 m1 0 0 1 0 m2 0 0 1 1 m3 0 1 0 0 m4 0 1 0 1 m5 0 1 1 0 m6 0 1 1 1 m7 1 0 0 0 m8 1 0 0 1 m9 1 0 1 0 m10 1 0 1 1 m11 1 1 0 0 m12 1 1 0 1 m13 1 1 1 0 m14 1 1 1 1 m15 x 1 x 2 x 3 x 4 00 01 11 10 x 3 00 01 11 10 m 0 m 1 m 5 m 3 m 2 m 6 m 4 m 12 x 2 m 13 m 7 m 15 m 14 x 1 m 8 m 9 m 11 m 10 x 4

How to check if the number is > 9? z3 z2 z1 z0 0 0 0 0 m0 0 0 0 1 m1 0 0 1 0 m2 0 0 1 1 m3 0 1 0 0 m4 0 1 0 1 m5 0 1 1 0 m6 0 1 1 1 m7 1 0 0 0 m8 1 0 0 1 m9 1 0 1 0 m10 1 0 1 1 m11 1 1 0 0 m12 1 1 0 1 m13 1 1 1 0 m14 1 1 1 1 m15 z 3 z z 2 1 z 0 00 01 11 10 00 01 11 10 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 1

How to check if the number is > 9? z3 z2 z1 z0 0 0 0 0 m0 0 0 0 1 m1 0 0 1 0 m2 0 0 1 1 m3 0 1 0 0 m4 0 1 0 1 m5 0 1 1 0 m6 0 1 1 1 m7 1 0 0 0 m8 1 0 0 1 m9 1 0 1 0 m10 1 0 1 1 m11 1 1 0 0 m12 1 1 0 1 m13 1 1 1 0 m14 1 1 1 1 m15 z 3 z z 2 1 z 0 00 01 11 10 00 0 0 1 0 01 0 0 1 0 11 0 0 1 1 10 0 0 1 1 f = z 3 z 2 + z 3 z 1

How to check if the number is > 9? z3 z2 z1 z0 0 0 0 0 m0 0 0 0 1 m1 0 0 1 0 m2 0 0 1 1 m3 0 1 0 0 m4 0 1 0 1 m5 0 1 1 0 m6 0 1 1 1 m7 1 0 0 0 m8 1 0 0 1 m9 1 0 1 0 m10 1 0 1 1 m11 1 1 0 0 m12 1 1 0 1 m13 1 1 1 0 m14 1 1 1 1 m15 z 3 z z 2 1 z 0 00 01 11 10 00 0 0 1 0 01 0 0 1 0 11 0 0 1 1 10 0 0 1 1 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

Verilog code for a one-digit BCD adder module bcdadd(cin, X, Y, S, Cout); input Cin; input [3:0] X, Y; output reg [3:0] S; output reg Cout; reg [4:0] Z; always @ (X, Y, Cin) begin Z = X + Y + Cin; if (Z < 10) {Cout, S} = Z; else {Cout, S} = Z + 6; end endmodule [Figure 3.40 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 1 1 1 1 [Figure 3.41 in the textbook]

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

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

Questions?

THE END