Professional Documents
Culture Documents
1
Working with combinational logic
◼ Simplification
❑ two-level simplification
❑ exploiting don’t cares
❑ algorithm for simplification
◼ Logic realization
❑ two-level logic and canonical forms realized with NANDs and NORs
❑ multi-level logic, converting between ANDs and ORs
◼ Time behavior
◼ Hardware description languages
2
Design example: two-bit comparator
A B C D LT EQ GT
0 0 0 0 0 1 0
0 1 1 0 0
1 0 1 0 0
N1 A LT AB<CD 1 1 1 0 0
B 0 1 0 0 0 0 1
EQ AB=CD
C 0 1 0 1 0
N2 GT AB>CD 1 0 1 0 0
D
1 1 1 0 0
1 0 0 0 0 0 1
0 1 0 0 1
1 0 0 1 0
1 1 1 0 0
block diagram 1 1 0 0 0 0 1
and 0 1 0 0 1
1 0 0 0 1
truth table 1 1 0 1 0
3
Design example: two-bit comparator (cont’d)
A A A
0 0 0 0 1 0 0 0 0 1 1 1
1 0 0 0 0 1 0 0 0 0 1 1
D D D
1 1 0 1 0 0 1 0 0 0 0 0
C C C
1 1 0 0 0 0 0 1 0 0 1 0
B B B
A B C D
two alternative
implementations of EQ
with and without XOR
EQ
5
XY
6
X=Y
7
Design example: 2x2-bit multiplier
A2 A1 B2 B1 P8 P4 P2 P1
0 0 0 0 0 0 0 0
0 1 0 0 0 0
1 0 0 0 0 0
1 1 0 0 0 0
A1 P1 0 1 0 0 0 0 0 0
A2 P2 0 1 0 0 0 1
1 0 0 0 1 0
B1 P4 1 1 0 0 1 1
B2 P8 1 0 0 0 0 0 0 0
0 1 0 0 1 0
1 0 0 1 0 0
1 1 0 1 1 0
1 1 0 0 0 0 0 0
block diagram 0 1 0 0 1 1
and 1 0 0 1 1 0
truth table 1 1 1 0 0 1
4-variable K-map
for each of the 4
output functions
8
Design example: 2x2-bit multiplier (cont’d)
A2 A2
K-map for P8 K-map for P4
0 0 0 0 0 0 0 0
P4 = A2B2B1'
0 0 0 0 0 0 0 0
B1 + A2A1'B2 B1
0 0 1 0 0 0 0 1
B2 P8 = A2A1B2B1 B2
0 0 0 0 0 0 1 1
A1 A1
A2 A2
0 0 0 0
K-map for P2 K-map for P1 0 0 0 0
P1 = A1B1
0 0 1 1 0 1 1 0
B1 B1
0 1 0 1 0 1 1 0
B2 P2 = A2'A1B2 B2
0 1 1 0 + A1B2B1' 0 0 0 0
A1 + A2B2'B1 A1
+ A2A1'B1
9
Design example: BCD increment by 1
I8 I4 I2 I1 O8 O4 O2 O1
0 0 0 0 0 0 0 1
0 0 0 1 0 0 1 0
0 0 1 0 0 0 1 1
0 0 1 1 0 1 0 0
I1 O1 0 1 0 0 0 1 0 1
0 1 0 1 0 1 1 0
I2 O2 0 1 1 0 0 1 1 1
0 1 1 1 1 0 0 0
I4 O4 1 0 0 0 1 0 0 1
I8 O8 1 0 0 1 0 0 0 0
1 0 1 0 X X X X
1 0 1 1 X X X X
1 1 0 0 X X X X
1 1 0 1 X X X X
block diagram 1 1 1 0 X X X X
1 1 1 1 X X X X
and
truth table
4-variable K-map for each of
the 4 output functions
10
Design example: BCD increment by 1 (cont’d)
I8 I8
O8 O4
0 0 X 1 0 1 X 0
0 0 X 0 0 1 X 0
I1 I1
0 1 X X O8 = I4 I2 I1 + I8 I1' 1 0 X X
I2 O4 = I4 I2' + I4 I1' + I4’ I2 I1 I2
0 0 X X 0 1 X X
I4 O2 = I8’ I2’ I1 + I2 I1' I4
O1 = I1'
I8 I8
O2 O1
0 0 X 0 1 1 X 1
1 1 X 0 0 0 X 0
I1 I1
0 0 X X 0 0 X X
I2 I2
1 1 X X 1 1 X X
I4 I4
11
Definition of terms for two-level simplification
◼ Implicant
❑ single element of ON-set or DC-set or any group of these elements that can
be combined to form a subcube
◼ Prime implicant
❑ implicant that can't be combined with another to form a larger subcube
◼ Objective:
❑ grow implicant into prime implicants
(minimize literals per term)
❑ cover the ON-set with as few prime implicants as possible
(minimize number of product terms)
12
Examples to illustrate terms
A
0 X 1 0 6 prime implicants:
A'B'D, BC', AC, A'C'D, AB, B'CD
1 1 1 0
D
essential
1 0 1 1
C
0 0 1 1 minimum cover: AC + BC' + A'B'D
B
A
5 prime implicants: 0 0 1 0
BD, ABC', ACD, A'BC, A'C'D
1 1 1 0
D
essential 0 1 1 1
C
0 1 0 0
minimum cover: 4 essential implicants
B
13
Algorithm for two-level simplification
14
Algorithm for two-level simplification (example)
A A A
X 1 0 1 X 1 0 1 X 1 0 1
0 1 1 1 0 1 1 1 0 1 1 1
D D D
0 X X 0 0 X X 0 0 X X 0
C C C
0 1 0 1 0 1 0 1 0 1 0 1
B B B
2 primes around A'BC'D' 2 primes around ABC'D
A A A
X 1 0 1 X 1 0 1 X 1 0 1
0 1 1 1 0 1 1 1 0 1 1 1
D D D
0 X X 0 0 X X 0 0 X X 0
C C C
0 1 0 1 0 1 0 1 0 1 0 1
B B B
3 primes around AB'C'D' 2 essential primes minimum cover (3 primes)
15
Activity
0 1 X 1
D CD’ BC BD AB AC’D
0 X X 0
C
X 1 1 1
B
16
Implementations of two-level logic
◼ Sum-of-products
❑ AND gates to form product terms (minterms)
❑ OR gate to form sum
◼ Product-of-sums
❑ OR gates to form sum terms (maxterms)
❑ AND gates to form product
17
Two-level logic using NAND gates
18
Two-level logic using NAND gates (cont’d)
19
Two-level logic using NOR gates
20
Two-level logic using NOR gates (cont’d)
21
Two-level logic using NAND and NOR gates
22
Conversion between forms
A A
NAND
B B
Z NAND Z
C C
NAND
D D
23
Conversion between forms (cont’d)
A A
NAND
B B
Z NAND Z
C C
NAND
D D
Z = [ (A • B)’ • (C • D)’ ]’
= [ (A’ + B’) • (C’ + D’) ]’
= [ (A’ + B’)’ + (C’ + D’)’ ]
= (A • B) + (C • D) ✓
24
Conversion between forms (cont’d)
B
Z
C
D
\A
A NOR NOR
\B
B
Z NOR Z
C
\C
D NOR NOR
\D
Step 1 Step 2
conserve conserve
"bubbles" "bubbles"
25
Conversion between forms (cont’d)
D \C
NOR
\D
26
Multi-level logic
C
D
introduction and F
B
conservation of
A
bubbles
B
\C
C
redrawn in terms D
F
of conventional \B
NAND gates A
B
\C
28
Conversion of multi-level logic to NORs
introduction and D
F
conservation of B
bubbles A
B
\C
\C
\D
redrawn in terms F
B
of conventional
\A
NOR gates
\B
C
29
Conversion between forms
◼ Example
A A
B F B F
C X C X
D D
original circuit add double bubbles to
invert all inputs of OR gate
A
A
X
B F
C X B F
\D C \X
\D
30
Summary for multi-level logic
◼ Advantages
❑ circuits may be smaller
❑ gates have smaller fan-in
❑ circuits may be faster
◼ Disadvantages
❑ more difficult to design
❑ tools for optimization are not as good as for two-level
❑ analysis is more complex
31
AND-OR-invert gates
A A
B B
Z Z
C C
D D
& &
2x2 AOI gate + 3x2 AOI gate +
symbol symbol
& &
32
AOI: Possible Switch Implementation
A C
True
A
B B D Z
Z
C A B
D
False
AND OR Invert C D
two-input two-stack
Conversion to AOI forms
34
35
Examples of using AOI gates
◼ Example:
❑ F = A B + A C’ + B C’
❑ F = (A’ B’ + A’ C + B’ C)’
❑ Implemented by 2-input 3-stack AOI gate
❑ F = (A + B) (A + C’) (B + C’)
❑ F = [(A’ + B’) (A’ + C) (B’ + C)]’
❑ Implemented by 2-input 3-stack OAI gate
A0 high if A0 B0
&
B0 low if A0 = B0
+
&
A1 &
B1 conservation of bubbles
+
&
NOR Z
A2 &
B2 if all inputs are low
+
& then Ai = Bi, i=0,...,3
output Z is high
A3 &
B3 +
&
37
Time behavior of combinational networks
◼ Waveforms
❑ visualization of values carried on signal wires over time
❑ useful in explaining sequences of events (changes in value)
◼ Simulation tools are used to create these waveforms
❑ input to the simulator includes gates and their connections
❑ input stimulus, that is, input signal waveforms
◼ Some terms
❑ gate delay — time for change at input to cause change at output
◼ min delay – typical/nominal delay – max delay
◼ careful designers design for the worst case
❑ rise time — time for output to transition from low to high voltage
❑ fall time — time for output to transition from high to low voltage
❑ pulse width — time that an output stays high or stays low between changes
38
Momentary changes in outputs
39
Oscillatory behavior
+
◼ Another pulse shaping circuit
resistor
A B
open C
switch D
close switch
initially
open switch
undefined
40
Hardware description languages
41
HDLs
42
Verilog
43
Hello, World!!
module main;
initial
begin
$display(“Hello, World!!”);
$finish;
end
endmodule
44
Structural model
Port declarations:
external interface to the module
module xor_gate (a, b, z);
input a, b;
output z;
wire abar, bbar, t1, t2;
45
46
Simple behavioral model
◼ Continuous assignment
❑ Whenever any signal on the right hand side changes its state, the
value of z will be re-evaluated.
assign #6 z = a ^ b;
endmodule
delay from input change
to output change
47
Simple behavioral model
◼ always block
48
Test Benches
a z
x
Test bench y
b
49
Driving a simulation through a “testbench”
assign x = cnt[1];
directive to stop
assign y = cnt[0]; simulation
endmodule
50
initial begin
cnt = 0;
repeat (3) begin
#10 cnt = cnt + 1;
end
#10
$finish;
end
cnt[1]
cnt[0]
0 10 20 30 40 50
51
module both_together(z);
output z;
wire w1, w2;
52
cnt[1]
cnt[0]
0 10 20 30 40 50
53
Verilog for Combinational Logic: assign
◼ assign
❑ wire type (no reg type)
54
Comparator example
55
Verilog for Combinational Logic: case
◼ case
❑ Specify the truth table of a logic function.
❑ Must be within an always block.
❑ Output variable must be declared as a reg variable.
❑ All inputs should be included in the sensitivity list of an always block.
if (k == 0) g = x2;
else g = x1;
end
endmodule
57
More complex behavioral model
module life (n0, n1, n2, n3, n4, n5, n6, n7, self, out);
input n0, n1, n2, n3, n4, n5, n6, n7, self;
output out;
reg out;
wire [7:0] neighbors;
reg [3:0] count;
reg [3:0] i;
assign neighbors = {n7, n6, n5, n4, n3, n2, n1, n0};
endmodule
58
Verilog for Combinational Logic: casex
◼ casex
❑ Allow don’t cares (X’s) in the cases.
60
Hardware description languages and
combinational logic
◼ Modules - specification of inputs, outputs, bidirectional, and
internal signals
◼ Continuous assignment - a gate’s output is a function of its
inputs at all times (doesn’t need to wait to be "called")
◼ Propagation delay- concept of time and delay in input affecting
gate output
◼ Composition - connecting modules together with wires
◼ Hierarchy - modules encapsulate functional blocks
61
Working with combinational logic summary
◼ Design problems
❑ filling in truth tables
❑ incompletely specified functions
❑ simplifying two-level logic
◼ Realizing two-level logic
❑ NAND and NOR networks
❑ networks of Boolean functions and their time behavior
◼ Time behavior
◼ Hardware description languages
◼ Later
❑ combinational logic technologies
❑ more design case studies
62