combinational logic - hacettepecelikcan/231/bolum05.pdf · for each possible input combination,...

109
1 Combinational Logic Mantıksal Tasarım – BBM231 section instructor: Ufuk Çelikcan

Upload: others

Post on 11-Sep-2019

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

1

Combinational Logic

Mantıksal Tasarım – BBM231

section instructor:Ufuk Çelikcan

Page 2: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

2

Classification1. Combinational

– no memory– outputs depend only on the present inputs– expressed by Boolean functions

2. Sequential– storage elements + logic gates– the content of the storage elements define the state of

the circuit– outputs are functions of both inputs and current state – state is a function of previous inputs– >> So outputs not only depend on the present inputs but

also the past inputs

Page 3: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

3

Combinational Circuits

n input bits 2n possible binary input combinations For each possible input combination, there is one

possible output value truth table Boolean functions (with n input variables)

Examples: adders, subtractors, comparators, decoders, encoders, multiplexers.

Combinationalcircuit

(logic gates)

n binaryinputs

m binaryoutputs

Page 4: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

4

Analysis & Design of Combinational Logic

• Analysis: to find out the function that a given circuit implements– We are given a logic circuit and– we are expected to find out

1. Boolean function(s)2. Truth table3. A possible explanation of the circuit operation

(i.e. what it does)

Page 5: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

5

Analysis of Combinational Logic

• First, make sure that the given circuit is, indeed, combinational.– Verifying the circuit is combinationalNo memory elementsNo feedback paths (connections)

• Second, obtain a Boolean function for each output or the truth table

• Finally, interpret the operation of the circuit from the derived Boolean functions or truth table– What is it the circuit doing?

• Addition, subtraction, multiplication, comparison etc.

Page 6: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

6

Obtaining Boolean Function

abc

abc

ab

ac

bc

F1

F2

T1

T2

T3

T4

Example

Page 7: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

7

Example: Obtaining Boolean Function• Boolean expressions for named wires T1 = abc T2 = a + b + c F2 = T3 = T4 = T3T2 F1 = T1 + T4

= = ==

Page 8: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

8

Example: Obtaining Boolean Function• Boolean expressions for named wires T1 = abc T2 = a + b + c F2 = ab + ac + bc T3 = F2’ = (ab + ac + bc)’ T4 = T3T2 = (ab + ac + bc)’ (a + b + c) F1 = T1 + T4

= abc + (ab + ac + bc)’ (a + b + c)= abc + ((a’ + b’)(a’ + c’)(b’ + c’)) (a + b + c)= abc + ( (a’ + a’c’ + a’b’ + b’c’)(b’ + c’) ) (a + b + c)= abc + (a’b’ + a’c’ + a’b’c’ + b’c’) (a + b + c)= abc + (a’b’ + a’c’ + b’c’) (a + b + c)

Page 9: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

9

Example: Obtaining Boolean Function

• Boolean expressions for outputs F2 = ab + ac + bc F1 = F1 = F1 = F1 =

Page 10: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

10

Example: Obtaining Boolean Function

• Boolean expressions for outputs F2 = ab + ac + bc F1 = abc + (a’b’ + a’c’ + b’c’) (a + b + c) F1 = abc + a’b’c + a’bc’ + ab’c’ F1 = a(bc + b’c’) + a’(b’c + bc’) F1 = a(b ⊕ c)’ + a’(b ⊕ c) F1 = ( a ⊕ b ⊕ c ) : Odd Function

Page 11: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

11

Example: Obtaining Truth Table

a b c T1 T2 T3 T4 F2 F1

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

sumcarryF1 = a ⊕ b ⊕ cF2 = ab + ac + bc

Page 12: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

12

Example: Obtaining Truth Table

a b c T1 T2 T3 T4 F2 F1

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

sumcarry

This is what we call full-adder (FA)

F1 = a ⊕ b ⊕ cF2 = ab + ac + bc

Page 13: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

13

Design of Combinational Logic• Design Procedure:

– We start with the verbal specification about what the resulting circuit will do for us (i.e. which function it will implement)• Specifications are often verbal, and very likely incomplete

and ambiguous (if not even faulty)• Wrong interpretations can result in incorrect circuit

– We are expected to find 1. Boolean function(s) (or truth table) to realize the desired

functionality2. Logic circuit implementing the Boolean function(s) (or the

truth table)

Page 14: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

14

Possible Design Steps

1. Find out the number of inputs and outputs2. Derive the truth table that defines the required

relationship between inputs and outputs3. Obtain a simplified Boolean function for each

output4. Draw the logic diagram (enter your design into

CAD)5. Verify the correctness of the design

Page 15: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

15

Design Constraints• From the truth table, we can obtain a variety of

simplified expressions, all realizing the same function.

• Question: which one to choose?• The design constraints may help in the selection

process• Constraints:

– number of gates– propagation time of the signal all the way from the inputs

to the outputs– number of inputs to a gate– number of interconnections– power consumption– driving capability of each gate

Page 16: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

16

Example: Design Process

• BCD-to-2421 Converter• Verbal specification:

– Given a BCD digit (i.e. {0, 1, …, 9}), the circuit computes 2421 code equivalent of the decimal number

• Step 1: how many inputs and how many outputs?– four inputs and four outputs

• Step 2:– Obtain the truth table– 0000 0000– 1001 1111– etc.

Page 17: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

17

BCD-to-2421 Converter• Truth Table

Inputs OutputsA B C D x y z t0 0 0 00 0 0 10 0 1 00 0 1 10 1 0 00 1 0 10 1 1 00 1 1 11 0 0 01 0 0 1

Page 18: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Binary coded decimal (BCD) is a system of writing numerals that assigns a four-digit binary code to each digit 0 through 9 in a decimal (base-10) numeral. The four-bit BCD code for any particular single base-10 digit is its representation in binary notation, as follows:

0 = 00001 = 00012 = 00103 = 00114 = 01005 = 01016 = 01107 = 01118 = 10009 = 1001

Numbers larger than 9, having two or more digits in the decimal system, are expressed digit by digit. For example, the BCD rendition of the base-10 number 1895is

0001 1000 1001 0101

Page 19: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

2421 Code

• a weighted code. • The weights assigned to the four digits are 2, 4, 2, and 1.

• The 2421 code is the same as that in BCD from 0 to 4; however, it differs from 5 to 9.

• For example, in this case the bit combination 0100 represents decimal 4; whereas the bit combination 1101 is interpreted as the decimal 7, as obtained from 2 ×1 + 1 ×4 + 0 ×2 + 1 ×1 = 7.

• This is also a self-complementary code, • that is, the 9’s complement of the decimal number is

obtained by changing the 1s to 0s and 0s to 1s.

Page 20: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

20

BCD-to-2421 Converter• Truth Table

Inputs OutputsA B C D x y z t0 0 0 00 0 0 10 0 1 00 0 1 10 1 0 00 1 0 10 1 1 00 1 1 11 0 0 01 0 0 1

Page 21: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

21

BCD-to-2421 Converter• Truth Table

Inputs OutputsA B C D x y z t0 0 0 0 0 0 0 00 0 0 1 0 0 0 10 0 1 0 0 0 1 00 0 1 1 0 0 1 10 1 0 0 0 1 0 00 1 0 1 1 0 1 10 1 1 0 1 1 0 00 1 1 1 1 1 0 11 0 0 0 1 1 1 01 0 0 1 1 1 1 1

Page 22: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

22

BCD-to-2421 Converter

10

11

01

00

10110100CD

AB

• Step 3: Obtain simplified Boolean expression for each output

• Output x:A B C D x

0 0 0 0 0

0 0 0 1 0

0 0 1 0 0

0 0 1 1 0

0 1 0 0 0

0 1 0 1 1

0 1 1 0 1

0 1 1 1 1

1 0 0 0 1

1 0 0 1 1

The rest X

x =

Page 23: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

23

BCD-to-2421 Converter

11

1110

0000

10

11

01

00

10110100CD

AB

• Step 3: Obtain simplified Boolean expression for each output

• Output x:A B C D x

0 0 0 0 0

0 0 0 1 0

0 0 1 0 0

0 0 1 1 0

0 1 0 0 0

0 1 0 1 1

0 1 1 0 1

0 1 1 1 1

1 0 0 0 1

1 0 0 1 1

The rest Xx x x xxx

Page 24: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

24

BCD-to-2421 Converter

11

1110

0000

10

11

01

00

10110100CD

AB

• Step 3: Obtain simplified Boolean expression for each output

• Output x:

x = BD + BC + A

A B C D x

0 0 0 0 0

0 0 0 1 0

0 0 1 0 0

0 0 1 1 0

0 1 0 0 0

0 1 0 1 1

0 1 1 0 1

0 1 1 1 1

1 0 0 0 1

1 0 0 1 1

The rest Xx x x xxx

Page 25: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

25

Boolean Expressions for OutputsCD

AB 00 01 11 1000

01

1110

CDAB 00 01 11 10

00

01

1110

• Output y:

• Output z:

A1 B C D y z

0 0 0 0 0 0

0 0 0 1 0 0

0 0 1 0 0 1

0 0 1 1 0 1

0 1 0 0 1 0

0 1 0 1 0 1

0 1 1 0 1 0

0 1 1 1 1 0

1 0 0 0 1 1

1 0 0 1 1 1

The rest X X

y =z =

Page 26: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

26

Boolean Expressions for OutputsCD

AB 00 01 11 1000 0 0 0 001 1 0 1 111 X X X X10 1 1 X X

CDAB 00 01 11 10

00 0 0 1 101 0 1 0 011 X X X X10 1 1 X X

• Output y:

• Output z:

A B C D y z

0 0 0 0 0 0

0 0 0 1 0 0

0 0 1 0 0 1

0 0 1 1 0 1

0 1 0 0 1 0

0 1 0 1 0 1

0 1 1 0 1 0

0 1 1 1 1 0

1 0 0 0 1 1

1 0 0 1 1 1

The rest X X

y =z =

Page 27: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

27

Boolean Expressions for OutputsCD

AB 00 01 11 1000 0 0 0 001 1 0 1 111 X X X X10 1 1 X X

CDAB 00 01 11 10

00 0 0 1 101 0 1 0 011 X X X X10 1 1 X X

• Output y:

• Output z:

A B C D y z

0 0 0 0 0 0

0 0 0 1 0 0

0 0 1 0 0 1

0 0 1 1 0 1

0 1 0 0 1 0

0 1 0 1 0 1

0 1 1 0 1 0

0 1 1 1 1 0

1 0 0 0 1 1

1 0 0 1 1 1

The rest X X

y = A + BD’ + BCz = A + B’C + BC’D

Page 28: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Boolean Expressions for Outputs

CDAB 00 01 11 10

00

01

1110

• Output t:A B C D T

0 0 0 0 0

0 0 0 1 1

0 0 1 0 0

0 0 1 1 1

0 1 0 0 0

0 1 0 1 1

0 1 1 0 0

0 1 1 1 1

1 0 0 0 0

1 0 0 1 1

The rest X

t =

Page 29: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

29

Boolean Expressions for Outputs

• Step 4: Draw the logic diagram

CDAB 00 01 11 10

00 0 1 1 001 0 1 1 011 X X X X10 0 1 X X

t =

x = BC + BD + Ay = A + BD’ + BCz = A + B’C + BC’D

• Output t:A B C D T

0 0 0 0 0

0 0 0 1 1

0 0 1 0 0

0 0 1 1 1

0 1 0 0 0

0 1 0 1 1

0 1 1 0 0

0 1 1 1 1

1 0 0 0 0

1 0 0 1 1

The rest X

Page 30: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

30

Boolean Expressions for Outputs

• Step 4: Draw the logic diagram

CDAB 00 01 11 10

00 0 1 1 001 0 1 1 011 X X X X10 0 1 X X

t = D

x = BC + BD + Ay = A + BD’ + BCz = A + B’C + BC’D

• Output t:A B C D T

0 0 0 0 0

0 0 0 1 1

0 0 1 0 0

0 0 1 1 1

0 1 0 0 0

0 1 0 1 1

0 1 1 0 0

0 1 1 1 1

1 0 0 0 0

1 0 0 1 1

The rest X

Page 31: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

31

Example: Logic DiagramAB

CD

x = BC + BD + A

y = A + BD’ + BC

z = A + B’C + BC’D

t = D

Page 32: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

32

Example: Verification

• Step 5: Check the functional correctness of the logic circuit

• Apply all possible input combinations • And check if the circuit generates the correct outputs

for each input combinations• For large circuits with many input combinations, this

may not be feasible.• Statistical techniques may be used to verify the

correctness of large circuits with many input combinations

Page 33: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

33

Binary Adder/Subtractor• (Arithmetic) Addition of two binary digits 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, and 1 + 1 = 10 The result has two components

• the sum (S)• the carry (C)

• (Arithmetic) Addition of three binary digits0 + 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

Page 34: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

34

Half Adder• Truth table

x y C S0 0 0 00 1 0 11 0 0 11 1 1 0

S = x’y + xy’ = x ⊕ y

C = xy

x

yS

CHAHA

Page 35: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

35

Full Adder 1/2• A circuit that performs the arithmetic sum of three

bits– Three inputs– the range of output is [0, 3]– Two binary outputs

x y z C S0 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 36: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

36

Full Adder 2/2• Karnaugh Maps

yzx 00 01 11 10

0

1

S = ?

yzx 00 01 11 10

0

1

C = ?

Two level implementation1st level: three AND gates2nd level: One OR gate

Page 37: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

37

Full Adder 2/2• Karnaugh Maps

yzx 00 01 11 10

0 0 1 0 11 1 0 1 0

S = xy’z’ + x’y’z + xyz + x’yz’= ...= ...

= x ⊕ y ⊕ z

yzx 00 01 11 10

0 0 0 1 01 0 1 1 1

C = xy + xz + yz= xyz’ + xyz + xy’z + x’yz

Two level implementation1st level: three AND gates2nd level: One OR gate

Page 38: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)
Page 39: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

39

Full Adder: Hierarchical Realization• Sum S = x ⊕ y ⊕ z = (x ⊕ y) ⊕ z

• Carry C = xyz’ + xyz + xy’z + x’yz

= xy + (xy’ + x’y) z = xy + (x ⊕ y) z

• This allows us to implement a full-adder using two half adders.

x ⊕ y ⊕ z = S

HA

z

S

C

HAx

y

S

C C

Page 40: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

40

Full Adder Using Half Adders

x

y

C

S

z

HA HA

Page 41: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

41

Integer Addition 1/2• Binary adder: A digital circuit that produces the arithmetic sum of two

binary numbers A = (an-1, an-2, …, a1, a0) B = (bn-1, bn-2, …, b1, b0)

• A simple case: 4-bit binary adder

HAx y

C

S

a0 b0

S0

C1FA

x y

zC

S

a1 b1

S1

C2FA

x y

zC

S

a2 b2

S2

C3FA

x y

zC

S

a3 b3

S3

C4

Page 42: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

42

Integer Addition 2/2

FAx y

zC

S

a0 b0

C0=0

S0

C1FA

x y

zC

S

a1 b1

S1

C2FA

x y

zC

S

a2 b2

S2

C3FA

x y

zC

S

a3 b3

S3

C4

Ripple-carry adder

Page 43: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

43

Hierarchical Design Methodology

• The design methodology we used to build carry-ripple adder is what is referred as hierarchical design.

• In classical design, we have: 9 inputs including C0. 5 outputs Truth tables with 29 = 512 entries We have to optimize five Boolean functions with 9

variables each.• Hierarchical design

– we divide our design into smaller functional blocks – connect functional units to produce the big functionality

Page 44: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Full Adder in Xilinx

44

Page 45: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Two-bit Adder in Xilinx

45

Page 46: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

46

Subtractor• Recall how we do subtraction (2’s complement)

X – Y = X + (2n – Y) = X + ~Y + 1

4-bit adder circuit

a3 b3 a2 b2 a1 b1 a0 b0

C4 C0

S3 S2 S1 S0

x3 x2 x1 x0 logic-1y3 y2 y1 y0

S3 S2 S1 S0C4

Page 47: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

47

Carry Propagation

FAx y

zC

S

a0 b0

C0=0

S0

C1FA

x y

zC

S

a1 b1

S1

C2FA

x y

zC

S

a2 b2

S2

C3FA

x y

zC

S

a3 b3

S3

C4

Ripple-carry adder

• What is the total propagation time of 4-bit ripple-carry adder?

– τFA: propagation time of a single full adder.– We have four full adders connected in cascaded fashion– Total propagation time: ??

Page 48: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

48

Carry Propagation

ai

bi

Ci+1

Pi

Gi

Si

Ci

• Propagation time of a full adder τXOR≈ 2τAND = 2τOR

τFA ≈ 2τXOR

carry-Propagate:carry-Generate:

Page 49: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Carry Propagation

49

S0

a0 b0 C0

C1S1

a1 b1

C2S2

a2 b2

C3S3

a3 b3

C4

•Carry-lookahead design

P0P1P2P3C1C2C3

Page 50: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Carry Propagation

50

S0

a0 b0 C0

C1S1

a1 b1

C2S2

a2 b2

C3S3

a3 b3

C4

• Delays• P0, P1, P2, P3: τXOR ≈ 2τAND• C1(S0): ≈ 2τAND + 2τAND ≈ 4τAND• C2(S1): ≈ 4τAND + 2τAND ≈ 6τAND• C3(S2): ≈ 6τAND + 2τAND ≈ 8τAND• C4(S3): ≈ 8τAND + 2τAND ≈ 10τAND

P0P1P2P3C1C2C3

Page 51: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

52

Decoders• A binary code of n bits

– capable of representing 2n distinct elements of coded information

– A decoder is a combinational circuit that converts binary information from n binary inputs to a maximum of 2n unique output lines

2x4 decoder

x

y

d0

d1

d2

d3

x y d0 d1 d2 d3

0 0 1 0 0 00 1 0 1 0 01 0 0 0 1 01 1 0 0 0 1

• d0 = • d1 =

• d2 = • d3 =

Page 52: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Decoder with Enable Input

2x4 decoder

x

y

d0

d1

d2

d3

e

e x y d0 d1 d2 d3

0 X X 0 0 0 01 0 0 1 0 0 01 0 1 0 1 0 01 1 0 0 0 1 01 1 1 0 0 0 1

53

Page 53: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

56

Demultiplexer• A demultiplexer is a combinational circuit

– it receives information from a single input line and directs it one of 2n output lines

– It has n selection lines as to which output will get the input

2x4 decoder

x

y

d0

d1

d2

d3

e

d0

d1

d2

d3

e

x, y

d0 = e when x = 0 and y = 0d1 = e when x = 0 and y = 1d2 = e when x = 1 and y = 0d3 = e when x = 1 and y = 1

Page 54: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Demultiplexer

0

0

0

1

1

1

e

x1 x0

57

Page 55: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Demultiplexer

e

x2

58

0

0

0

1

1

1

0

0

0

1

1

1

0

1

x1 x0

Page 56: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Demultiplexer

59

0

0

1

1

0

0

1

1

x0

Page 57: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Combining Decoders

2x4 decoder

y

z

d0d1d2

d3e

2x4 decoder

d4d5d6

d7e

x

x y z active output0 0 00 0 10 1 00 1 11 0 01 0 11 1 01 1 1

• Decoders with enable inputs can be connected together to form a larger decoder circuit. • Figure shows two 2-to-4-line decoders with enable inputs connected to form a 3-to-8-line decoder. • When x=0, the top decoder is enabled and the other is disabled. The bottom decoder outputs are all

0’s, and the top four outputs generate minterms 000 to 011. • When x=1, the enable conditions are reversed: The bottom decoder outputs generate minterms 100 to

111, while the outputs of the top decoder are all 0’s. • This example demonstrates the usefulness of enable inputs in decoders

Page 58: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

61

nx2n

Decoder-1

x0

xn-1

d0d1

d2n

-1e

nx2n

Decoder-2e

nx2n

Decoder-2p

e

px2p

Decoder

xn

xn+p-1

Combining Decoders

d2n+p-1

-1

Page 59: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

62

Decoder as a Building Block• A decoder provides the 2n minterms of n input

variable

2x4 decoder

x

y

d0 = x’y’d1 = x’yd2 = xy’

d3 = xy

• We can use a decoder and OR gates to realize any Boolean function expressed as sum of minterms– Any combinational circuit with n inputs and m outputs can be

realized using an n-to-2n line decoder and m OR gates.

Page 60: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

63

Decoder as a Building Block-ROM

3x8 decoder

x

y

d0 = x’y’z’d1 = x’y’zd2 = x’yz’

d3 = x’yzd4 = xy’z’d5 = xy’zd6 = xyz’

d7 = xyz

z

F2 F1 F0

Page 61: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

64

Decoder as a Building Block-ROM

3x8 decoder

x

y

z

1 0 0

0 0 1

1 0 0

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

F2 F1 F0

Page 62: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

65

Example: Decoder as a Building Block• Full adder

– C = xy + xz + yz – S = x ⊕ y ⊕ z

3x8 decoder

x

y

z

012

34567

S

C

Page 63: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

66

Encoders• An encoder is a combinational circuit that

performs the inverse operation of a decoder– number of inputs: 2n

– number of outputs: n– the output lines generate the binary code

corresponding to the input value• Example: n = 2

d0 d1 d2 d3 x y

1 0 0 0 0 00 1 0 0 0 10 0 1 0 1 00 0 0 1 1 1

Page 64: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

67

Priority Encoder• Problem with a regular encoder:

– only one input can be active at any given time– the output is undefined for the case when more than

one input is active simultaneously.• Priority encoder:

– there is a priority among the inputs

1111XXX

10101XX

110001X

1000001

0XX0000

Vbad3d2d1d0

Page 65: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

68

Priority Encoder• if two or more inputs are equal to 1 at the same time, the input having

the highest priority will take precedence. • In addition to the two outputs a and b , the circuit has a third output

designated by V ; this is a valid bit indicator that is set to 1 when one or more inputs are equal to 1. If all inputs are 0, there is no valid input and V is equal to 0. The other two outputs are not inspected when V equals 0 and are specified as don’t-care conditions.

• Priority encoder:

1111XXX

10101XX

110001X

1000001

0XX0000

Vbad3d2d1d0

Page 66: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

69

4-bit Priority Encoder• In the truth table X for input variables represents both 0 and 1. Good for condensing the truth table Example: X100 (0100, 1100) This means d1 has priority over d0

d3 has the highest priority d2 has the next d0 has the lowest priority

V = ? The condition for output V is an OR function of

all the input variables.

Page 67: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

70

Maps for 4-bit Priority Encoderd2d3

d0d1 00 01 11 1000011110

a =

d2d3

d0d1 00 01 11 1000011110 b =

Page 68: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

71

Maps for 4-bit Priority Encoderd2d3

d0d1 00 01 11 1000 X 1 1 101 0 1 1 111 0 1 1 110 0 1 1 1 a =

d2d3

d0d1 00 01 11 1000 X 1 1 001 1 1 1 011 1 1 1 010 0 1 1 0

b =

Page 69: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

72

4-bit Priority Encoder: Circuit

d0

d1

d2

d3 b

a

V

a = d2 + d3

b = d1d2’ + d3

V = d0 + d1 + d2 + d3

Page 70: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

73

Multiplexers• A combinational circuit

– It selects binary information from one of the many input lines and directs it to a single output line.

– Many inputs – m– One output line– n selection lines n = ?

• Example: 2-to-1-line multiplexer 2 input lines I0, I1

1 output line Y 1 select line S

S Y

0 I0

1 I1Y = ? Function Table

Page 71: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

74

2-to-1-Line Multiplexer

• Special Symbol

S

I0

Y

I1

Y = S’I0 + SI1

I0

I1

MUX Y

S

0

1

Page 72: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

75

4-to-1-Line Multiplexer• 4 input lines: I0, I1, I2, I3• 1 output line: Y• 2 select lines: S1, S0.

11

01

10

00

YS0S1

Y = ?

Interpretation:• In case S1 = 0 and S0 = 0, Y selects I0

• In case S1 = 0 and S0 = 1, Y selects I1

• In case S1 = 1 and S0 = 0, Y selects I2

• In case S1 = 1 and S0 = 1, Y selects I3

Page 73: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

76

4-to-1-Line Multiplexer: Circuit

S0

I0

Y

I1

I2

I3

S1

I0

I1MUX Y

S1

0

1

I2

I3

2

3

S0

Y = S1’S0’I0 + S1’S0I1 + S1S0’I2 + S1S0I3

Page 74: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

77

Multiplexer with Enable Input• To select a certain building block we use enable

inputs

A

BMUX Y

S1

0

1

C

D

2

3

S0

E

E S Y1 XX0 00 A0 01 B0 10 C0 11 D

Page 75: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

78

Multiple-Bit Selection Logic 1/2• A multiplexer is also referred as a “data selector”• A multiple-bit selection logic selects a group of

bits

A =

B =

Y =

A

B

MUX Y

S

0

1

2

2

2

1

E

Page 76: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Multiple-bit Selection Logic 2/2

A

B

MUX Y

S

0

1

2

2

2

1

E

E S Y1 X all 0’s0 0 A0 1 B

MUX

0

1

y0

a0

b0

E

S

MUX

0

1

y1

a1

b1

79

Page 77: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

80

Design with Multiplexers 1/2• Reminder: design with decoders• Half adder

– C = xy = Σ(3)

– S = x ⊕ y = x’y + xy’ = Σ(1, 2)

2x4 decoder

x

y

0

1

2

3

S

C

• A closer look will reveal that a multiplexer is nothing but a decoder with OR gates

Page 78: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

81

Design with Multiplexers 2/2• 4-to-1-line multiplexer

I0

I1MUX Y

S1

0

1

I2

I3

2

3

S0

• Y = S1’S0’ I0 + S1’S0 I1 + S1S0’ I2 + S1S0 I3

• Y = x’y’ I0 + x’y I1 + xy’ I2 + xyI3

• Y =

• S1 x• S0 y• S1’S0’ = x’y’, • S1’S0 = x’y,• S1S0’ = xy’, • S1S0 = xy

Page 79: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

82

Example: Design with Multiplexers• Example: S = Σ(1, 2)

I0

I1MUX Y

S1

0

1

I2

I3

2

3

S0

=

=

=

=

x y

Page 80: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

83

Example: Design with Multiplexers• Example: S = Σ(1, 2)

I0

I1MUX Y

S1

0

1

I2

I3

2

3

S0

=

=

=

=

x y

0

1

1

0

Page 81: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

84

Design with Multiplexers Efficiently

• More efficient way to implement an n-variable Boolean function1. Use a multiplexer with n-1 selection inputs2. First (n-1) variables are connected to the

selection inputs3. The remaining variable is connected to data

inputs

• Example: Y = Σ(1, 2)= I0

= I1

Y = S’ I0 + S I1MUX

0

1

x

Y = x’ I0 + x I1

Page 82: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

85

Design with Multiplexers Efficiently

• More efficient way to implement an n-variable Boolean function1. Use a multiplexer with n-1 selection inputs2. First (n-1) variables are connected to the

selection inputs3. The remaining variable is connected to data

inputs

• Example: Y = Σ(1, 2)y = I0

y' = I1

Y = S’ I0 + S I1MUX

0

1

x

Y = x’ I0 + x I1

Page 83: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

86

Design with MultiplexersGeneral procedure for n-variable Boolean function F(x1, x2, ..., xn)1. The Boolean function is expressed in a truth table2. The first (n-1) variables are applied to the selection inputs of

the multiplexer (x1, x2, ..., xn-1)3. For each combination of these (n-1) variables, evaluate the

value of the output as a function of the last variable, xn.• 0 , 1 , xn , xn’

4. These values are applied to the data inputs in the proper order.

Page 84: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

87

Example: Design with Multiplexers• F(x, y, z) = Σ(1, 2, 6, 7) F = x’y’z + x’yz’ + xyz’ + xyz Y = S1’S0’ I0 + S1’S0 I1 + S1S0’ I2 + S1S0 I3

I0 = I1 = I2 = I3 =

111

011

101

001

110

010

100

000

Fzyx

F =

F =

F =

F =

Page 85: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

88

Example: Design with Multiplexers• F(x, y, z) = Σ(1, 2, 6, 7) F = x’y’z + x’yz’ + xyz’ + xyz Y = S1’S0’ I0 + S1’S0 I1 + S1S0’ I2 + S1S0 I3

I0 = z I1 = z’ I2 = 0 I3 = 1

1111

1011

0101

0001

0110

1010

1100

0000

Fzyx

F =z

F =z’

F =0

F =1

Page 86: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

89

Example: Design with Multiplexers

MUX

0

1

2

3

x y

F = x’y’z + x’yz’ + xy

F = x’y’z + x’yz’ + xyz’ + xyz

F = z when x = 0 and y = 0F = z’ when x = 0 and y = 1F = 0 when x = 1 and y = 0F = 1 when x = 1 and y = 1

z

z'

0

1

Page 87: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Design with Multiplexers

MUX

0

1

2

3

x y

I0

I1

I2

I3

x‘y’(I0) + x‘y(I1) + xy’(I2) + xy(I3)

F=x‘y’(0) + x‘y(1) + xy’(1) + xy(0)

F=x‘y’(z) + x‘y(z’) + xy’(0) + xy(1)

F=x‘y’(P(z,t,q,w)) + x‘y(Q(z,t,q,w)) + xy’(R(z,t,q,w)) + xy(S(z,t,q,w))

90

F

Page 88: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Design with Multiplexers

MUX

0

1

2

3

x y

I0

I1

I2

I3

F=x‘y’(P(z,t,q,w)) + x‘y(Q(z,t,q,w)) + xy’(R(z,t,q,w)) + xy(S(z,t,q,w))

91

z

t

q

w

Combinational Circuit F

Page 89: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

92

Combining Multiplexers

MUX

0

1

2

3

MUX

0

1

2

3

S2 S1MUX

0

1

S2 S1

S0

Page 90: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Example

MUX0

1

X0

MUX0

1

X1

MUX0

1

X1X0

MUX0

1

X2

MUX0

1

X2X0

MUX0

1

X2X1

MUX0

1

X2X1X0

C0

C1

C2C3 C4

C5C6

C7

93

Page 91: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Example- 2 Level ROM

p x2n ROM0

z0 z1 zp-1

p x2n ROM1

z0 z1 zp-1

p x2n ROM2k-1

z0 z1 zp-1

x0x1

xn-1

xnXn+1

Xn+k-1

0 1 2k-1 0 1 2k-1 0 1 2k-1

z0 z1 zp-1

94

MUX MUX MUX

Page 92: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Example- 2 Level ROM

p x2n ROM0

z0 z1 zp-1

p x2n ROM1

z0 z1 zp-1

p x2n ROM2k-1

z0 z1 zp-1

x0x1

xn-1

xnXn+1

Xn+k-1

0 1 2k-1 0 1 2k-1 0 1 2k-1

z0 z1 zp-1

95

MUX MUX MUX

Page 93: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Example- 2 Level ROM

p x2n ROM0

z0 z1 zp-1

p x2n ROM1

z0 z1 zp-1

p x2n ROM2k-1

z0 z1 zp-1

x0x1

xn-1

xnXn+1

Xn+k-1

0 1 2k-1 0 1 2k-1 0 1 2k-1

z0 z1 zp-1

96

MUX MUX MUX

Page 94: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Example- 2 Level ROM

p x2n ROM0

z0 z1 zp-1

p x2n ROM1

z0 z1 zp-1

p x2n ROM2k-1

z0 z1 zp-1

x0x1

xn-1

XnXn+1

Xn+k-1

0 1 2k-1 0 1 2k-1 0 1 2k-1

z0 z1 zp-1

0 1 1

97

MUX MUX MUX

0 1 • • • • • 1

Page 95: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Example- 2 Level ROM

p x2n ROM0

z0 z1 zp-1

p x2n ROM1

z0 z1 zp-1

p x2n ROM2k-1

z0 z1 zp-1

x0x1

xn-1

xnXn+1

Xn+k-1

0 1 2k-1 0 1 2k-1 0 1 2k-1

z0 z1 zp-1

1 0 098

MUX MUX MUX

1 0 • • • • • 0

Page 96: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Example- 2 Level ROM

p x2n ROM0

z0 z1 zp-1

p x2n ROM1

z0 z1 zp-1

p x2n ROM2k-1

z0 z1 zp-1

x0x1

xn-1

xnXn+1

Xn+k-1

0 1 2k-1 0 1 2k-1 0 1 2k-1

99

MUX MUX MUX

1 1 • • • • 1 0

z0 z1 zp-1

1 1 0

Page 97: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

100

Three-State Buffers• A different type of logic element

– Instead of two states (i.e. 0, 1), it exhibits three states (0, 1, Z)

– Z (Hi-Z) is called high-impedance– When in Hi-Z state the circuit behaves like an open

circuit (the output appears to be disconnected, and the circuit has no logic significance)

A

C

Y = A if C = 1Y = Hi-Z if C = 0

input

controlinput

Page 98: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

101

3-State Buffers• Remember that we cannot connect the outputs of

other logic gates.• We can connect the outputs of three-state buffers

– provided that no two three-state buffers drive the same wire to opposite 0 and 1 values at the same time.

C A Y

0 X Hi-Z

1 0 0

1 1 1

Page 99: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Example- 3 State MUX

n x2n

Decoderz0 z1 z2

n-1

x0x1

xn-1

y0

y1

y2n

-1

Y

102

Page 100: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

103

Multiplexing with 3-State BuffersA

S

B

TA

TB

Y

11Z1X1

00Z0X1

1Z1X10

0Z0X00

YTBTABAS

It is, in fact, a 2-to-1-line MUX

Page 101: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

104

Two Active Outputs - 1A

C1

B

TA

TB

Y

C0

What will happen if C1 = C0 = 1?

11111

00011

1011

0111

YBAC0C1

ZXX00

11X01

00X01

1X110

0X010

Page 102: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

105

Design Principle with 3-State Buffers• Designer must be sure that only one control input

must be active at a time.– Otherwise the circuit may be destroyed by the large

amount of current flowing from the buffer output at logic-1 to the buffer output at logic-0.

2x4 decoder

S1

S0

E

x

y

w

z

t

Page 103: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Example- 3 State Buffer & ROMp x2n ROM

1z0 z1 zp-1

p x2n ROM2

z0 z1 zp-1

p x2n ROM2k

z0 z1 zp-1

x0x1

xn-1

106

k x2

kRO

Mxnxn+1

xn+k-1

z0 z1 zp-1

Page 104: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

107

Busses with 3-State Buffers• There are important uses of three-state buffers

CPU Memory

I/O Device

Page 105: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Design with Verilog• Gate Level Design

108

module decoder_2x4_gates(D, A, B, e);output [0:3] D;input A, B, e;wire A_n, B_n;

not G1(A_n, A);not G2 (B_n, B);

and G3(D[0], e, A_n, B_n);

and G4(D[1], e, A_n, B);

and G5(D[2], e, A, B_n);

and G6(D[3], e, A, B);

endmodule;

D0 = eA’B’D1 = eA’BD2 = eAB’D3 = eAB

G1

G2

G3

G4

G5

G6

A

B

e

D0

D1

D2

D3

A_nB_n

Page 106: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Dataflow Modeling

109

G1

G2

G3

G4

G5

G6

A

B

e

D0

D1

D2

D3

D0 = eA’B’D1 = eA’BD2 = eAB’D3 = eAB

module decoder_2x4_dataflow(output [0:3] D, input A, B,

e);assign D[0] = e & ~A & ~B;assign D[1] = e & ~A & B;assign D[2] = e & A & ~B;assign D[3] = e & A & B;

endmodule;

• Dataflow modeling uses a number of operators that act on operands– About 30 different operators

Page 107: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Dataflow Modeling

• Data type “net”– Represents a physical connection between circuit

elements– e.g., “wire”, “output”, “input”.

• Continuous assignment “assign”– A statement that assigns a value to a net– e.g., assign D[0] = e & ~A & ~B;– e.g., assign A_lt_B = A < B;

• Bus type– wire [0:3] T;– T[0], T[3], T[1..2];

110

Page 108: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Behavioral Modeling• Represents digital circuits at a functional and

algorithmic level– Mostly used to describe sequential circuits– Can also be used to describe combinational circuits

111

module mux_2x1_beh(m, A, B, S);output m; input A, B, S;reg m;always @(A or B or S);

if(S == 1) m = A;else m = B;

endmodule;

Page 109: Combinational Logic - Hacettepecelikcan/231/bolum05.pdf · For each possible input combination, there is one possible output value truth table Boolean functions (with n input variables)

Behavioral Modeling• Output must be declared as “reg” data type• “always” block

– Procedural assignment statements are executed every time there is a change in any of the variables listed after the “@” symbol (i.e., sensitivity list).

112

module mux_4x1_beh(output reg m, input I0, I1, I2, I3;input [1:0] S);always @(I0 or I1 or I2 or I3 or S);

case (S)2’b00: m = I0;2’b01: m = I1;2’b10: m = I2;2’b11: m = I3;

endcaseendmodule;