CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone:...

26
CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324

Transcript of CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone:...

Page 1: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

CS221: Digital Logic DesignCombinational Circuits

Dr. Ahmad AlmulhemEmail: ahmadsm AT kfupm

Phone: 860-7554Office: 22-324

Page 2: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Objectives

• BCD to Excess-3

• BCD to 7-Segments• Arithmetic Circuits

• 2-bit numbers Multiplier

• Big Adders• Parallel Adder = Ripple Carry Adder

• Carry Look-ahead Adder

Page 3: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

BCD to Excess-3 Code Converter

• Code converters convert from one code to another (BCD to Excess-3 in this example)

• The inputs are defined by the code that is to be converted (BCD in this example)

• The outputs are defined by the converted code (Excess-3 in this example)

• Recall Excess-3 code is a decimal digit plus three converted into binary, i.e. 0 is 0011, 1 is 0100, etc.

Page 4: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

BCD Input Excess 3 Output

Decimal A B C D W X Y Z Decimal

0 0 0 0 0 0 0 1 1 3

1 0 0 0 1 0 1 0 0 4

2 0 0 1 0 0 1 0 1 5

3 0 0 1 1 0 1 1 0 6

4 0 1 0 0 0 1 1 1 7

5 0 1 0 1 1 0 0 0 8

6 0 1 1 0 1 0 0 1 9

7 0 1 1 1 1 0 1 0 10

8 1 0 0 0 1 0 1 1 11

9 1 0 0 1 1 1 0 0 12

10-15 All other inputs x x x x --

Ahmad Almulhem, KFUPM 2010

BCD to Excess-3 Code Converter

Step 1 (Specification)

4-bit BCD input (A,B,C,D)

4-bit E-3 output (W,X,Y,Z)

Step 2 (Formulation)

Obtain Truth table

Page 5: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

src: online CD

src: Mano’s book

BCD to Excess-3 Code Converter

Step 3 (Optimization): 4 different functions/outputs ... utilize don’t cares

Page 6: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

BCD-to-Seven-Segment Decoder

• A seven-segment display is digital readout found in electronic devices like clocks, mobiles, monitors, TVs, etc.

• Made of seven light-emitting diodes (LED) segments; each segment is controlled separately.

• A BCD-to-Seven-Segment decoder is a combinational circuit• Accepts a decimal digit in BCD (input)

• Generates appropriate outputs for the segments to display the input decimal digit (output)

Ahmad Almulhem, KFUPM

2010

src: Mano’s book

Page 7: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

BCD-to-Seven-Segment Decoder

Step 1 (Specification):• 4 inputs (A, B, C, D)

• 7 outputs (a, b, c, d, e, f, g)

Ahmad Almulhem, KFUPM

2010

BCD-to-Seven-SegmentDecoder

A B C D

a b c d e f g

Page 8: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

BCD Input 7 Segment Decoder

Decimal A B C D a b c d e f g

0 0 0 0 0 1 1 1 1 1 1 0

1 0 0 0 1 0 1 1 0 0 0 0

2 0 0 1 0 1 1 0 1 1 0 1

3 0 0 1 1 1 1 1 1 0 0 1

4 0 1 0 0 0 1 1 0 0 1 1

5 0 1 0 1 1 0 1 1 0 1 1

6 0 1 1 0 1 0 1 1 1 1 1

7 0 1 1 1 1 1 1 0 0 0 0

8 1 0 0 0 1 1 1 1 1 1 1

9 1 0 0 1 1 1 1 0 0 1 1

10-15 All Other Inputs 0 0 0 0 0 0 0

Ahmad Almulhem, KFUPM 2010

BCD-to-Seven-Segment DecoderStep 2 (Formulation)

Invalid BCD

codes=

No Light

Page 9: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Ahmad Almulhem, KFUPM

2010

BCD-to-Seven-Segment Decoder

a b c d

e f g

Step 3 (Optimization)

Page 10: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

a = A’C + A’BD + AB’C’ + B’C’D’

b = A’B’ + A’C’D’ + A’CD + B’C’

c = A’B + B’C’ + A’C’ + A’D

d = A’CD’ + A’B’C + B’C’D’+AB’C’+A’BC’D

e = A’CD’ + B’C’D’

f = A’BC’ + A’C’D’ + A’BD’ + AB’C’

g = A’CD’ + A’B’C + A’BC’ + AB’C’

Ahmad Almulhem, KFUPM

2010

BCD-to-Seven-Segment Decoder

Exercise: Draw the circuit (Atanua?)

Step 3 (Optimization) (cont.)

BCD-to-Seven-SegmentDecoder

A B C D

a b c d e f g

Page 11: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Binary Multiplication

Similar to decimal multiplication

Multiplying 2 bits will generate 1 if both bits are equal to 1, and will be 0 otherwise. Resembles an AND operation

Multiplying two 2-bit numbers is done as follows:

B1 B0

x A1 A0

----------------

A0B1 A0B0

A1B1 A1B0 +

----------------------------------

C3 C2 C1 C0

This operation is an addition, requires an

ADDER

Page 12: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Binary Multiplication

Therefore, for multiplying two 2-bit numbers, AND gates and ADDERS will be sufficient

Half Adders

Page 13: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Bigger Adders

• How to build an adder for n-bit numbers?• Example: 4-Bit Adder

• Inputs ?

• Outputs ?

• What is the size of the truth table?

• How many functions to optimize?

Page 14: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Bigger Adders

• How to build an adder for n-bit numbers?• Example: 4-Bit Adder

• Inputs ? 9 inputs (Carry-in from previous circuit!)

• Outputs ? 5 outputs

• What is the size of the truth table? 512 rows!

• How many functions to optimize? 5 functions

Page 15: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Binary Parallel Adder

1 0 0 0

0 1 0 1

+ 0 1 1 0

1 0 1 1

To add n-bit numbers:

• Use n Full-Adders in parallel

• The carries propagates as in addition by hand

• This is an example of a hierarchical design• The circuit is broken into small blocks

Carry in

Page 16: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Binary Parallel Adder

To add n-bit numbers:

• Use n Full-Adders in parallel

• The carries propagates as in addition by hand

This adder is called ripple carry adder

Src: Mano’s Book

Page 17: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Ripple Adder Delay

• Assume gate delay = T

• 8 T to compute the last carry

• 1 delay form first full adder

• Total delay = 8 + 1 = 9T

• Delay = (2n+1)T

Ahmad Almulhem, KFUPM 2010

Src: Course CD

How to improve?

Page 18: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Carry Look-ahead Adder

• How to reduce propagation delay of ripple carry adders?

• Carry look-ahead adder: All carries are computed as a function of C0 (independent of n !)

• It works on the following standard principles:

• A carry bit is generated when both input bits Ai and Bi are 1, or

• When one of input bits is 1, and a carry-in bit exists

Cn Cn-1…….Ci……….C2C1C0

An-1…….Ai……….A2A1A0

Bn-1…….Bi……….B2B1B0

Sn Sn-1…….Si……….S2S1S0

Carry Out

Carry bits

Page 19: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Carry Look-ahead AdderAi

Bi Si

Ci+1

Ci

Pi

Gi

The internal signals (1st H.A.) are given by:

Pi = Ai Bi Sum

Gi = Ai.Bi Carry

Page 20: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Carry Look-ahead AdderAi

Bi Si

Ci+1

Ci

Pi

Gi

Carry-Generate Gi = (new carry from Ai,Bi)Ci+1 = 1 when Gi = 1, regardless of the input carry Ci

The internal signals (1st H.A.) are given by:

Pi = Ai Bi Sum

Gi = Ai.Bi Carry

Page 21: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Carry Look-ahead AdderAi

Bi Si

Ci+1

Ci

Pi

Gi

Carry-Propagate Pi : Propagates Ci to Ci+1

Note: Pi and Gi depend only on Ai and Bi !

The internal signals (1st H.A.) are given by:

Pi = Ai Bi Sum

Gi = Ai.Bi Carry

Page 22: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Carry Look-ahead Adder

The output signals (2nd H.A.) are given by:

Si = Pi Ci Sum

Ci+1 = Gi + PiCi Carry

Ai

Bi

Ci+1

Ci

Pi

Gi

Si

The internal signals (1st H.A.) are given by:

Pi = Ai Bi Sum

Gi = Ai.Bi Carry

Page 23: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Carry Look-ahead Adder

The carry outputs for various stages can be written as: Ci+1 = Gi + Pi.Ci

C1 = G0 + P0C0

C2 = G1 + P1C1 = G1 + P1(G0 + P0C0) = G1 + P1G0 + P1P0C0

C3 = G2 + P2C2 = G2 + P2(G1 + P1G0 + P1P0C0) = G2 + P2G1 + P2P1G0 + P2P1P0C0

C4 = G3 + P3C3 = G3 + P3G2 + P3P2G1 + P3P2P1G0 + P3P2P1P0C0

Ai

Bi

Ci+1

Ci

Pi

Gi

Si

Page 24: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Carry Look-ahead Adder

Conclusion: Each carry bit can be expressed in terms of the input carry C0, and not based on its preceding carry bit

Each carry bit can be expressed as a SoP, and can be implemented using a two-level circuit, i.e. a gate delay of 2T

Page 25: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Carry Look-ahead AdderA0

B0

A1

B1

A2

B2

A3

B3

P0

G0

P1

P2

G2

G3

G1

C0

C1

C2

C3P3

C4 C4

S0

S1

S2

S3

Carry Look-ahead Block

Page 26: CS221: Digital Logic Design Combinational Circuits Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: 22-324.

Carry Look-ahead AdderSteps of operation:- All P and G signals are initially generated. Since both XOR

and AND can be executed in parallel. Delay = 1T- The Carry Look-ahead block will generate the four carry

signals C4, C3, C2, C1. Delay = 2T- The four XOR gates will generate the Sums. Delay = 1T

Total delay before the output can be seen = 4T

Compared with the Ripple Adder delay of 9T, this is an improvement of more than 100%

CLA adders are implemented as 4-bit modules, that can together be used for implementing larger circuits