CSEE 3827: Fundamentals of Computer Systems

42
CSEE 3827: Fundamentals of Computer Systems Combinational Circuits

Transcript of CSEE 3827: Fundamentals of Computer Systems

Page 1: CSEE 3827: Fundamentals of Computer Systems

CSEE 3827: Fundamentals of Computer Systems

Combinational Circuits

Page 2: CSEE 3827: Fundamentals of Computer Systems

Outline (M&K 3.1, 3.3, 3.6-3.9, 4.1-4.2, 4.5, 9.4)

• Combinational Circuit Design

• Standard combinational circuits

• enabler

• decoder

• encoder / priority encoder

• Code converter

• MUX (multiplexer) & DeMux

• Addition / Subtraction

• half and full adders

• ripple carry adder

• carry lookahead adder

• Shifter

2

Page 3: CSEE 3827: Fundamentals of Computer Systems

Combinational circuits

• Combinational circuits are stateless

• The outputs are functions only of the inputs

3

Combinational circuit OutputsInputs

Page 4: CSEE 3827: Fundamentals of Computer Systems

Hierarchical design

4

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

3-4

(a)

A0 N0MX

MX

MX

MX

ME

N1

N2

N3

E

B0

A1

B1

A2

B2

A3

B3

Ai

Ni

MXBi

N0N1 E

MEN2N3

(b) (c)

Design small circuits to be used in a bigger circuit“Big”Circuit

Smaller Circuits

Page 5: CSEE 3827: Fundamentals of Computer Systems

Enabler circuits

5

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

3-15

XF

EN

(a)

ENX

F

(b)

Output is “enabled” (F=X) only when input ‘ENABLE’ signal is asserted (EN=1)

EN F

0 0

1 A

A

A EN F

0 1

1 A

Page 6: CSEE 3827: Fundamentals of Computer Systems

Decoder-based circuits

6

3:8decoder

A

B

C

ABC

ABC

ABC

ABC

ABC

ABC

ABC

ABC

Converts n-bit input to m-bit output, where n <= m <= 2n

“Standard” Decoder: ith output = 1, all others = 0,

where i is the binary representation of the input (ABC)

Page 7: CSEE 3827: Fundamentals of Computer Systems

Decoder-based circuits

7

3:8decoder

AB

C

‘A’B’C‘A’BC‘AB’C‘ABCA’B’CA’BCAB’CABC

So, if decoders produce minterms. . .

Page 8: CSEE 3827: Fundamentals of Computer Systems

Internal design of 1:2 decoder

8

1:2 decoder

x 'x

x

Page 9: CSEE 3827: Fundamentals of Computer Systems

Hierarchical design of decoder (2:4 decoder)

9

2:4 decoder

1:2

decoder

1:2

decoder

b

a

'b

b

'a

a

'b'a

'ba

b'a

ba

Page 10: CSEE 3827: Fundamentals of Computer Systems

Hierarchical design of decoder (3:8 decoder)

10

3:8 decoder

2:4 decoder

b

a

'b'a

'ba

b'a

ba

1:2 decoderc

'c

c

'c'b'a

'c'ba

'cb'a

'cba

c'b'a

c'ba

cb'a

cba

Page 11: CSEE 3827: Fundamentals of Computer Systems

Encoders

11

Inverse of a decoder: converts m-bit input to n-bit output, where n <= m <= 2n

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 3-7

TABLE 3-7Truth Table for Octal-to-Binary Encoder

Inputs Outputs

D7 D6 D5 D4 D3 D2 D1 D0 A2 A1 A0

00000001

00000010

00000100

00001000

00010000

00100000

01000000

10000000

00001111

00110011

01010101

Page 12: CSEE 3827: Fundamentals of Computer Systems

Decoder and encoder summary

12

BCD values One-hot encoding

0 0 0 0 0 0 0 0 0 0 1

0 0 1 0 0 0 0 0 0 1 0

0 1 0 0 0 0 0 0 1 0 0

0 1 1 0 0 0 0 1 0 0 0

1 0 0 0 0 0 1 0 0 0 0

1 0 1 0 0 1 0 0 0 0 0

1 1 0 0 1 0 0 0 0 0 0

1 1 1 1 0 0 0 0 0 0 0

Decoder

Encoder

n}2n{

n{ n}2

Note: for Encoders - input is assumed to be just one 1, the rest 0’s

Page 13: CSEE 3827: Fundamentals of Computer Systems

Priority Encoder

13

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

T 3-8

Inputs Outputs

D3 D2 D1 D0 A1 A0 V

00001

0001X

001XX

01XXX

X0011

X0101

01111

TABLE 3-8Truth Table of Priority Encoder

Like a regular encoder, but designed for any combination of inputs.

Page 14: CSEE 3827: Fundamentals of Computer Systems

General code conversion

14

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

3-3

(a) Segment designation

a

bf

e cg

d(b) Numeric designation for display

Page 15: CSEE 3827: Fundamentals of Computer Systems

Code conversion for the “a”

15

a

bf

e

d

cg

Val W X Y Z 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

A 1 0 1 0 1 1 1 0 1 1 1

b 1 0 1 1 0 0 1 1 1 1 1

C 1 1 0 0 1 0 0 1 1 1 0

d 1 1 0 1 0 1 1 1 1 0 1

E 1 1 1 0 1 0 0 1 1 1 1

F 1 1 1 1 1 0 0 0 1 1 1

Input Output

Page 16: CSEE 3827: Fundamentals of Computer Systems

Multiplexers

• Combinational circuit that selects binary information from one of many input lines and directs it to one output line

16

2 inputsn

n selection bitsindicate (in binary) which input feeds to the output

1 output

Page 17: CSEE 3827: Fundamentals of Computer Systems

Truth table for a 4:1 mux

17

i0i1i2i3

s1 s0

o

Page 18: CSEE 3827: Fundamentals of Computer Systems

Internal mux organization

18

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

3-26

S1Decoder

S0

Y

S1Decoder

S0

Y

S1Decoder

4 2 AND-ORS0

Y

I2

I3

I1

I0

Selector LogicEnabler logic

Only 1 AND gate passes “1” throughAND gates “zero out” unselected Ii

Or gate “passes through” the non-

zeroed out Ii

Page 19: CSEE 3827: Fundamentals of Computer Systems

In class exercise

How would you implement an 8:1 mux using two 4:1 muxes?

19

Page 20: CSEE 3827: Fundamentals of Computer Systems

Multiplexer truth table

20

Mux

2^n inputs n-bit BCD value 1 output

a x x x x x x x 0 0 0 a

x b x x x x x x 0 0 1 b

x x c x x x x x 0 1 0 c

x x x d x x x x 0 1 1 d

x x x x e x x x 1 0 0 e

x x x x x f x x 1 0 1 f

x x x x x x g x 1 1 0 g

x x x x x x x h 1 1 1 h

n2 {

{

n

Page 21: CSEE 3827: Fundamentals of Computer Systems

Demultiplexers

21

Demux

1 input n-bit BCD value 2^n outputs

a 0 0 0 a 0 0 0 0 0 0 0

b 0 0 1 0 b 0 0 0 0 0 0

c 0 1 0 0 0 c 0 0 0 0 0

d 0 1 1 0 0 0 d 0 0 0 0

e 1 0 0 0 0 0 0 e 0 0 0

f 1 0 1 0 0 0 0 0 f 0 0

g 1 1 0 0 0 0 0 0 0 g 0

h 1 1 1 0 0 0 0 0 0 0 h

n}2

{

n

Page 22: CSEE 3827: Fundamentals of Computer Systems

Muxes and demuxes called “steering logic”

22

Mux

“merge” “fork”

Demux

Page 23: CSEE 3827: Fundamentals of Computer Systems

Decimal v. binary addition

23

4 3 5 8 2+ 2 2 5 7 3

6 6 1 5 5

110 1 0 1 1

+ 0 0 1 0 11 0 0 0 0

11 11

adder

a4

b4

adder

a3

b3

adder

a2

b2

adder

a1

b1

adder

a0

b0

s0s1s2s3s4

Page 24: CSEE 3827: Fundamentals of Computer Systems

Ripple carry adder

24

adder

a4

b4

adder

a3

b3

adder

a2

b2

adder

a1

b1

adder

a0

b0

s0s1s2s3s4

halffullfullfullfull

a b c s

0 0

0 1

1 0

1 1

a b cin cout s

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

Page 25: CSEE 3827: Fundamentals of Computer Systems

0

0000

-8

1000

4

0100

-4

1100

1

0001

2

0010

3

0011

5

0101

6

0110

7

0111

-7

1001

-5

1011

-6

1010

-1

1111

-2

1110

-3

1101

Subtraction w. twos complement representation

25

Can be accomplished with a twos-complementor and an adder

Page 26: CSEE 3827: Fundamentals of Computer Systems

In class exercise: designing an adder-subtractor

26

Page 27: CSEE 3827: Fundamentals of Computer Systems

Adder/subtractor for #’s in 2’s complement form

27

© 2008 Pearson Education, Inc.M. Morris Mano & Charles R. KimeLOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

4-7

FA FA FA FA

S

B3

C3

S2 S1 S0S3C4

C2 C1 C0

A3 B2 A2 B1 A1 B0 A0

Page 28: CSEE 3827: Fundamentals of Computer Systems

Handling overflow

28

0

0000

-8

1000

4

0100

-4

1100

1

0001

2

0010

3

0011

5

0101

6

0110

7

0111

-7

1001

-5

1011

-6

1010

-1

1111

-2

1110

-3

1101

0111(5) 0101(3) 0011 1000 (-8)

1111(-5) 1011(-3) 1101 1000 (-8)

1000(-6) 1010(-3) 1101 0111 (7)

0010(-6) 1010(3) 0011 1101 (-3)

twos-complement

Page 29: CSEE 3827: Fundamentals of Computer Systems

Handling overflow

29

a3 b3 c3 c4 s3 overflow?0 0 0 0 0

0 0 1 0 1

0 1 0 0 1

0 1 1 1 0

1 0 0 0 1

1 0 1 1 0

1 1 0 1 0

1 1 1 1 1

c4 c3 c2 c1 c0 a3 a2 a1 a0 b3 b2 b1 b0 s3 s2 s1 s0

Page 30: CSEE 3827: Fundamentals of Computer Systems

Overflow computation in adder/subtractor

For 2’s complement, overflow if 2 most significant carries differ

30

FAFAC3C4

Page 31: CSEE 3827: Fundamentals of Computer Systems

Ripple carry adder delay analysis

• Assume unit delay for all gates

• S = A ⊕ B ⊕ Cin

• [ S ready _______ units after A,B and Cin ready]

• Cout = AB + ACin + BCin

• [ Cout ready _______ units after A,B and Cin ready]

31

adder

a4

b4

adder

a3

b3

adder

a2

b2

adder

a1

b1

adder

a0

b0

s0s1s2s3s4

Page 32: CSEE 3827: Fundamentals of Computer Systems

Carry lookahead adder (CLA)

• Goal: produce an adder of less circuit depth

• Start by rewriting the carry function

32

ci+1 = aibi + aici + bici

ci+1 = aibi + ci (ai+bi)ci+1 = gi + ci (pi)

carry propagatepi = ai + bi

carry generategi = aibi

Page 33: CSEE 3827: Fundamentals of Computer Systems

Carry lookahead adder (CLA) (2)

• Can recursively define carries in terms of propagate and generate signals

• ith carry has i+1 product terms, the largest of which has i+1 literals

• If AND, OR gates can take unbounded inputs: total circuit depth is 2 (SoP form)

• If gates take 2 inputs, total circuit depth is 1 + log2 k for k-bit addition

33

c1 = g0 + c0p0

c2 = g1 + c1p1

= g1 + (g0 + c0p0)p1

= g1 + g0p1 + c0p0p1

c3 = g2 + c2p2

= g2 + (g1 + g0p1 + c0p0p1)p2

= g2 + g1p2 + g0p1p2 + c0p0p1p2

Page 34: CSEE 3827: Fundamentals of Computer Systems

Carry lookahead adder (CLA) (3)

34

c0 = 0 s0 = a0 ⊕ b0 ⊕ c0

c1 = g0 + c0p0 s1 = a1 ⊕ b1 ⊕ c1

c2 = g1 + g0p1 + c0p0p1 s2 = a2 ⊕ b2 ⊕ c2

c3 = g2 + g1p2 + g0p1p2 + c0p0p1p2 s3 = a3 ⊕ b3 ⊕ c3

Page 35: CSEE 3827: Fundamentals of Computer Systems

Contraction

35

Contraction is the simplification of a circuit through constant input values.

Page 36: CSEE 3827: Fundamentals of Computer Systems

Contraction example: adder to incrementer

36

adder

a4

b4

adder

a3

b3

adder

a2

b2

adder

a1

b1

adder

a0

b0

s0s1s2s3s4

1000

• What is the hardware and delay savings of implementing an incrementer using contraction?

Can be reduced to half-adders

Incrementer circuit

a0 S C

0 1 0

1 0 1S0=a0, C0=a0

Page 37: CSEE 3827: Fundamentals of Computer Systems

Multi-wire notation

• Useful when running a bunch of bits in parallel to the same (similar place)

37

C1 C2

O0

O1

Ok-1Ok

I0I1

Ik-1Ik

... ... ... C1 C2k

k

k w

ires

k

k w

ires

Page 38: CSEE 3827: Fundamentals of Computer Systems

Shifter Circuit

• Shifts bits of a word:

• Various types of shifters

• Barrel: selector bits indicate (in binary) how “far” bits shift

• selector value = j, then Bi = Ai-j

• bits can “wraparound” Bi (mod 2n) = Ai-j (mod 2n) or rollout (Bi=0 for i<j)

• L/R with enable: n=2, high bit enables, low bit indicates direction (e.g., 0=left [Bi = Ai-1], 1=right [Bi = Ai+1])

38

Shifter

Bk-1Bk-2...B2B1B0

Ak-1Ak-2...A2A1A0

n selector bits

k

k

n

Page 39: CSEE 3827: Fundamentals of Computer Systems

Barrel Shifter Design with wraparound (using MUXs)

• Basic form of design: Each Ai feeds into each MUX connecting to Bj into input (j-i) mod 4

39

MUXMUX MUX MUX3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0

B3

A3 A2 A1 A0

B2 B1 B0

S1S0

Page 40: CSEE 3827: Fundamentals of Computer Systems

Barrel Shifter Design with wraparound (using MUXs)

• Basic form of design: Each Ai feeds into each MUX connecting to Bj into input (j-i) mod 4

• Selector is 10 (i.e., 2 binary): each MUX entry 2 is selected

40

MUXMUX MUX MUX3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0

B3

A3 A2 A1 A0

B2 B1 B0

10

Page 41: CSEE 3827: Fundamentals of Computer Systems

L/R Shift w/ Rollout

• Basic form of design:

• 0 & 1 MUX selectors (S1 = 0) feed Ai to Bi

• 2 MUX selector feeds from left (Bi = Ai-1), 3 MUX from right (Bi = Ai+1)

• Note 0 feeds (0’s roll in when bits rollout)

41

MUXMUX MUX MUX3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0

B3

A3 A2 A1 A0

B2 B1 B0

S1S0

0

Page 42: CSEE 3827: Fundamentals of Computer Systems

L/R Shift w/ Rollout

• Basic form of design:

• 0 & 1 MUX selectors (S1 = 0) feed Ai to Bi

• 2 MUX selector feeds from left (Bi = Ai-1), 3 MUX from right (Bi = Ai+1)

• Note 0 feeds (0’s roll in when bits rollout)

42

MUXMUX MUX MUX3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0

B3

A3 A2 A1 A0

B2 B1 B0

11

0