Title: EEL 3705 / 3705L Digital Logic Design
1EEL 3705 / 3705LDigital Logic Design
- Fall 2006Instructor Dr. Michael FrankModule
6 Modular Combinational Logic(Thanks to Dr.
Perry for the slides)
2Note to Self
- There are still way too many slides in this
module! - Need to keep working on making it shorter and
more concise
3Wednesday, October 10, 2006
- Administrivia
- This weeks lab
- Finish Top secret code display (w. K-maps),
finish project - Design project 1 Due this Friday!!
- Test your designs during a lab period, or in TA
office hours - Dont delay writing the large required amount of
documentation! - Homework assignment 3
- Due next Monday (October 16th)
- Plan for today
- Show Ping-Pong videogame example, in progress
- See module 99, Designs (v.3) for slides
- Start next lecture topic Modular Combinational
Logic
4Modular Combinational Logic
- Original slides by Dr. Reginald Perry
- With modifications additions by Mike Frank
5Decoders
- General form n-to-2n decoder
- n inputs, 2n outputs
- For each input pattern, one and only one output
line will be active. - Uses
- Minterm generator
- Bit/word-line (memory access) circuit
- Code conversion
- Demultiplexing (routing) of data
61-to-2 Decoder
- Truth table shown at right
- This one can be implementedby just a simple
fan-out andan inverter
x y0 y1
0 1 0
1 0 1
y0
y0
x
x
y1
y1
Circuit schematic
Icon
7Recursive Contruction of n-to-2n Decoder out of
1-to-2 and (n-1)-to-2n-1 Decoders
w0
plus 2n AND gates
w1
w2
xn-1..1
xn-1..0
2n-1 ANDgates
2n-1
n-1
2n
2n-1 ANDgates
z0
x0
z1
81-to-2, 2-to-4 and 3-to-8 Decodersusing
recursive design style in Quartus
This is really 4 AND gates in parallel
This is really 8 AND gates in parallel
9add a slide on the other recursive composition of
2k-to-(2(2k)) decoders
102 to 4 Decoder Truth Table
X1 X0 Y0 Y1 Y2 Y3
0 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1
112 to 4 Decoder Equations
122 to 4 Decoder Circuit
132 to 4 Decoder Block Symbol
Symbol
Circuit
143 to 8 Decoder Truth Table
x2 x1 x0 y0 y1 y2 y3 y4 y5 y6 y7
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 1
153 to 8 Decoder Equations
163 to 8 Decoder Circuit
173 to 8 Decoder Block Symbol
Symbol
Circuit
18Design Example
- Using only a 3x8 decoder and two-input OR gates,
design a logic circuit which implements the
following Boolean equation
19Solution
m2
m4
m5
202 to 4 Decoder with Enable
212x4 Decoder with Enable
- Enable is abbreviated as EN
- EN is called a Control Signal
- Control Signals can be
- Active High Signal
- EN 1 Turns ON Decoder
- Active Low Signal
- EN0 Turns ON Decoder
222 x 4 Decoder with Active High Enable Truth
Table
En x1 x0 y3 y2 y1 y0
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 1 0 0 0 0 0
0 1 1 0 0 0 0
1 0 0 0 0 0 1
1 0 1 0 0 1 0
1 1 0 0 1 0 0
1 1 1 1 0 0 0
232 to 4 Decoder with Enable Equations
242 to 4 Decoder with Enable Circuit
252 to 4 Decoder with Enable Symbol
262 x 4 Decoder with Active High Enable Truth
Table (Short hand notation)
En x1 x0 y3 y2 y1 y0
0 d d 0 0 0 0
1 0 0 0 0 0 1
1 0 1 0 0 1 0
1 1 0 0 1 0 0
1 1 1 1 0 0 0
d dont care
En has highest priority. If En0, we dont
care about x1 or x0 because Y0
272 x 4 Decoder with Active Low Enable Truth
Table (Short hand notation)
EnL x1 x0 y3 y2 y1 y0
1 d d 0 0 0 0
0 0 0 0 0 0 1
0 0 1 0 0 1 0
0 1 0 0 1 0 0
0 1 1 1 0 0 0
d dont care
En has highest priority. If En1, we dont
care about x1 or x0 because Y0
282 to 4 Decoder with Active Low Enable Circuit
29Design Example
- Design a 3x8 decoder using only 2x4 decoders and
NOT gates.
30Solution
On when A0
On when A1
31Encoders
- Opposite of a decoder
- 2n to n encoder
- 2n inputs
- n outputs
- For each input, the circuit will produce an
encoded output
32Example 4 to 2 Binary EncoderTruth Table
X3 X2 X1 X0 Y1 Y0
0 0 0 1 0 0
0 0 1 0 0 1
0 1 0 0 1 0
1 0 0 0 1 1
Assume only one input high at a time!!
334 to 2 Encoder Equations
34Problems with initial design
- Q How do we tell the difference between an input
of all 0s (i.e. X0) and X1? - A Add another output (IA) that indicates that
the input is valid. Lets make IA active low.
35Problems with initial design
- If IA 1 gt all lines are 0
- If IA 0 gt at least one line is 1
- Q What happens if more than one input is high at
the same time? - A Design a priority encoder that will encode
the input with the highest priority. - Lets set X3 with the highest priority, followed
by X2, X1, and X0
36Example 4 to 2 Priority Binary EncoderTruth
Table
X3 X2 X1 X0 Y1 Y0
0 0 0 1 0 0
0 0 1 d 0 1
0 1 d d 1 0
1 d d d 1 1
37Solution
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Y1
Y0
384 to 2 Priority Encoder Equations
39Monday, October 16, 2006
- Administrivia
- This weeks lab
- Electronic Device Test PO(2/b), experiment
- Design projects are being graded this week
- Homework assignment 3 is due tonight
- Plan for today
- Finish current topic
- Modular Combinational Logic MUXes, ALUs
40Multiplexer/Data Selectors
- MUX
- Very Important Module!!!
41Multiplexer(MUX)/Data Selector
- N to 1 multiplexer (or multiplexor)
- N2k data input lines, D0..(N-1)
- klog2(N) control inputs, S(k-1)..0
- Binary encoding of index of selected data
- One output
- This circuit will connect just the selected
input to the output. - The selected input is specified by decoding the
control inputs.
42The Simplest Multiplexer
- 2-to-1 multiplexer truth table?
- Output is a copy of
- D0 if S00
- D1 if S01
D0 D1 S0 F
D0 d 0 D0
d D1 1 D1
Schematic,using 1-to-2Decoder module
example 2-to-1 MUX Icon
43General Construction of a 2k-to-1 MUX from a
k-to-2k decoder, ANDs, and an OR
- This is just a direct generalization of the
schematic on the previous slide.
F
bussedOR gate
2k
2k
2k
This means 2k ANDgates in parallel
k
S(k-1)..0
44Recursive Construction of 2k-to-1 muxfrom two
2k-1-to-1 muxes ( a 2-to-1 mux)
2k-1
k-1
F
2k
2k-1
Sk-1
S(k-2)..0
k-1
S(k-1)..0
k
454-to-1 MUX from three2-to-1 MUXes
- Try building some larger sizes for yourself
46Example 4 to 1 MUX Truth Table
Control Inputs
Output
Data Inputs
D0 D1 D2 D3 S1 S0 F
D0 d d d 0 0 D0
d D1 d d 0 1 D1
d d D2 d 1 0 D2
d d d D3 1 1 D3
d dont care / Di data on input i
474 to 1 MUX Equation
Ds are the DATA inputs, AB are control inputs
and called the select lines.
484 to 1 MUX Circuit
Control Inputs
Data Inputs
Output
2x4 Decoder
Only a single AND gate will be ON at a time.
494 to 1 MUX Symbol
A more common, and more mnemonic MUX symbol
D0
Data Inputs
D1
F
Output
D2
Control Inputs
S1..0
D3
50Logic with multiplexers
- You can implement any n-input logic function with
a single 2n-to-1 multiplexer, by feeding
appropriate constants into the MUXs data inputs. - Namely, the list of the functions output values
from its truth table - The multiplexer implements a lookup table
- it simply looks up the function result from the
indicated row of the truth table - Of course, this is generally not the most
hardware-efficient way to implement a given
function.
51MUX Application Example
- Using a 4x1 MUX, design a logic circuit which
implements
We have,
Y
52Example
- Using a 4x1 MUX, design a logic circuit which
implements
a b Y Dn
0 0 0 D0
0 1 1 D1
1 0 1 D2
1 1 0 D3
53Solution
54Multi-bit Multiplexers
d0
d1
J bits deep
d2
J bits deep
F
dn-1
sel
log2n
j0 to 3
This is just J separate nx1 multiplexers
55Example 4-bit 4x1 MUX
D03..0
D03..0
D13..0
D13..0
F3..0
F3..0
4 bits deep
D23..0
D23..0
D33..0
D33..0
A B
A
B
j0 to 3
This is just 4 separate 4x1 muxes
56Example
Bit 0
Bit 1
Bit 2
Bit 3
57Example 4 bit 4x1 MUX
- For the jth output, we have
D0j
D1j
Fj
D2j
D3j
A
B
58Example 4 bit 4x1 MUX
- For the bit 0 output, we have
D00
D10
F0
D20
D30
A
B
59Example 4 bit 4x1 MUX
- For the bit 1 output, we have
D01
D11
F1
D21
D31
A
B
60Example 4 bit 4x1 MUX
- For the bit 2 output, we have
D02
D12
F2
D22
D32
A
B
61Example 4 bit 4x1 MUX
- For the bit 3 output, we have
D03
D13
F3
D23
D33
A
B
62Example 4 bit 4x1 Mux
Complete Circuit
F0
Bit 0
F1
Bit 1
F2
Bit 2
F3
Bit 3
63Example 4 bit 4x1 MUX
64Design Example
- Using a 4bit 4x1 MUX, design a 8bit
- 4x1 MUX
65Solution
66DeMultiplexers/Data Distributors
67Demultiplexer/Data Distributor
- Opposite of a multiplexer
- 1 to N demultiplexer
- 1 data input
- N data outputs
- Log2(n) control inputs
- This circuit will connect a data input to one
and only one output. The selected output is
specified by a decoding of the control inputs.
68Example 1 to 4 DeMUX Truth Table
D A B F0 F1 F2 F3
D 0 0 D 0 0 0
D 0 1 0 D 0 0
D 1 0 0 0 D 0
D 1 1 0 0 0 D
d dont care / Di data on input i
691 to 4 DeMUX Equations
D is the DATA inputs, AB are control inputs and
called the select lines.
701 to 4 DEMUX Circuit
Only one F will be active
2x4 Decoder
Only 1 AND gate will be ON
711 to 4 DEMUX Symbol
Selected Lines
Outputs
Data Input
72Example
- Design a 3x8 decoder using only 2x4 decoders and
NOT gates.
73Solution
On when A0
On when A1
74Basic Arithmetic Elements
75Half Adder-Truth Table
A B S1 S0
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
76Half Adder Circuit
77Full Adder-Truth Table
A B C S1 S0
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
78Full Adder
You can show!!!
79Synthesis
Logic Equation
Logic Circuit
80Synthesis
Logic Equation
Logic Circuit
81Synthesis Full Adder Circuit
A
S(0)
B
C
S(1)
S(0)
S(1)
Simulation
82Full Adder from Two Half Adders
- Given bits a,b,c, computes (s1s0)2 a b c.
- Can build it using two half adders to compute the
low-order bit of the sum as s0 (a?b)?c. - Plus an extra OR gate needed to combine the
carries.
83Ripple Carry Adder
84Conceptualization
1
1
1
1111 1111
11110
For the worst case we need to add three bits to
generate a single output bit with a possible
carry out. Can we use our single bit adder for
this?
85Ripple Carry Adder
- We can cascade several full adders to create a
ripple carry adder - The circuit gets its name because the carry bit
ripples from one bit position to the next
86Conceptualization
First, lets look at two bits
A(1)
B(1)
Sum(1)
A(0)
B(0)
Sum(0)
What about the carry?
87Conceptualization
Lets connect the two full adders
A(1)
B(1)
S(1)
Cin
Cout
A(0)
B(0)
S(0)
0
Set carry in for first bit to 0. Why?
88Analysis
Lets test this for a few cases
0
0
0
Correct!!!
Rule of thumb Always test simple cases first!!
89Analysis
Lets test this for the a few cases
1
1
1
Correct!!!
90Analysis
Lets test this for the a few cases
0
0
0
1
1
1
1
1
0
0
Correct!!!
91Four Bit Ripple Adder
Carry out
Carry in
928-bit Ripple Carry Adder
9316-bit Ripple Carry Adder
94Subtraction Circuit
95Subtraction Circuit
- Calculate 2s complement of B
- Add B to A
96Add/Sub Circuit
97Add/Sub Circuit Module
98Function Table for Add/Sub Module
Add Functional Result
0 SAB
1 SA-B
Add is a control input. It is active low. This
means that the module will compute AB when
Add0. It will compute A-B when Add1.
99Add/Sub Circuit
100Add/Sub Circuit
101Add/Sub Circuit
Add operation. Add0
0
0
102Add/Sub Circuit
Sub operation. Add1
1
1
103Wednesday, October 18, 2006
- Administrivia
- This weeks lab
- Electronic Device Test PO(2/b), experiment
- Next weeks lab
- Midterm Practical Exam
- Design projects are being graded this week
- Homework assignment 4 will be out soon!
- Plan for today
- Finish current topic
- Modular Combinational Logic Comparators, ALUs
104Comparators
105Equal Comparator
- Design a logic circuit which will compute
- F0 (A B)
1062-bit Equal Comparator Truth Table
b1 b0 a1 a0 F0
0 0 0 0 1
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 0
0 1 1 1 0
1072-bit Equal Comparator Truth Table
b1 b0 a1 a0 F0
1 0 0 0 0
1 0 0 1 0
1 0 1 0 1
1 0 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 1
108Solution
You can show,
109N-bit Equal Comparator
110Not Equal Comparator
- Design a logic circuit which will compute
- F (A ltgt B)
F (A B)
i.e. Just invert our Equal Comparator circuit
111Magnitude Comparator
- Design a logic circuit which will compute
- F2 (AgtB)
- F1 (AltB)
Lets develop a truth table for 2-bits
1122-bit Magnitude (unsigned) Comparator Truth Table
b1 b0 a1 a0 F2 F1
0 0 0 0 0 0
0 0 0 1 1 0
0 0 1 0 1 0
0 0 1 1 1 0
0 1 0 0 0 1
0 1 0 1 0 0
0 1 1 0 1 0
0 1 1 1 1 0
1132-bit Magnitude (unsigned) Comparator Truth Table
b1 b0 a1 a0 F2 F1
1 0 0 0 0 1
1 0 0 1 0 1
1 0 1 0 0 0
1 0 1 1 1 0
1 1 0 0 0 1
1 1 0 1 0 1
1 1 1 0 0 1
1 1 1 1 0 0
114You can show
115Arithmetic Logic Units (ALUs)
116Arithmetic Logic Unit (ALU)
A,B are data inputs of n bits each in depth S is
a control input. We have 2m operations F is the
output
117Example
- Let n4,m3
- We have A3..0 and B3..0
- With m3, we have 23 8 operations
- Lets look at a possible function table
118Function Table
s2 s1 s0 Function
0 0 0 FAB
0 0 1 FAB (logical OR)
0 1 0 FNOT A
0 1 1 FA XOR B
1 0 0 FAB (Arithmetic)
1 0 1 FA-B
1 1 0 FA 1
1 1 1 FA - 1
119Design using a Truth Table
- How large is the truth table?
- 2n from data inputs A and B
- Example n8, we have 16 data inputs
- A7..0 and B7..0
- 3 control inputs
- Total of 2n3 inputs
- N8, we have 19 inputs
- Our truth table will have
- 192 (361) rows and 8 outputs
- Too complex. Lets explore another alternative
using a system or modular approach
120Design using Modules
- Note
- For S20, we have logic operations
- For S21, we have arithmetic operations
- So, lets use S2 to control a 2x1 MUX
- to select between logic and arithmetic
operations, so our top level design would look
like
121ALU Design
122ALU Design S20
With S20, F is the output from the logic module
123ALU Design S21
With S21, F is the output from the arithmetic
module
124Logic Module Design
125Function Table for Logic Module
s2 s1 s0 Function
0 0 0 FAB
0 0 1 FAB (logical OR)
0 1 0 FNOT A
0 1 1 FA XOR B
We can use a 4x1 mux to implement this module
126Logic Module Design
127Logic Module Design
FAB
AND Operation S1..000
0 0
128Logic Module Design
FAB
OR Operation S1..001
0 1
129Logic Module Design
FA
NOT Operation S1..010
1 0
130Logic Module Design
FA XOR B
XOR Operation S1..011
1 1
131What do these logic moduleslook like?
132AND Module
133OR Module
134NOT Module
A
F
135XOR Module
136Arithmetic Module
- Lets use our ADD/SUB Module
137Add/Sub Circuit Module
138Function Table for Arithmetic Ops
s2 s1 s0 Function
1 0 0 FAB (Arithmetic)
1 0 1 FA-B
1 1 0 FA 1
1 1 1 FA - 1
Note S0 can be use to indicate Addition or
Subtraction. S1 can be use to indicate the B data
input
139Arithmetic Module Design
140Arithmetic Module Design
FAB
S1..000
0
0
141Arithmetic Module Design
FA-B
S1..001
1
0
142Arithmetic Module Design
FA1
S1..010
0
1
143Arithmetic Module Design
FA-1
S1..011
1
1
144Overall Design
145ALU Design
146Logic Module Design
147Arithmetic Module Design
148Total Design
Logic Module
Arithmetic Module
149End of Chapter 4