Lecture18-RTL Combinational Components - A-E
Lecture18-RTL Combinational Components - A-E
Z. Navabi
Topic 4
Zain Navabi
8 8
A ABS w
10110010 01001110
3
Introduction to Digital System Design - Copyright Zainalabedin Navabi
Why RTL?
• Register Transfer Level is a solution
a0 s
a1
a2
a3 w0
a4 w1
0 w2
a5 w3
a6 w4
8 8 a7
A ABS w w5
w6
w7
+1 1
4
Introduction to Digital System Design - Copyright Zainalabedin Navabi
RTL View
• A functional level
Accelerator
2010+
CPU
ES Level
data_bus
dbus_on_data
dbus data_on_dbus
alu_on_dbus 8
8
2000
6
6 PC
comparator RT Level
ld_pc
inc_pc
clr_pc
ALU pass
add
6 6
ir_on_adr pc_on_adr
addr_bus 6
1980
Gate Level
1970
Transistor Level
6
Introduction to Digital System Design - Copyright Zainalabedin Navabi
What is RTL?
data_bus
dbus_on_data
dbus data_on_dbus
opcode
alu_on_dbus 8 2
8 ir on adr
Reset clr pc rd mem
wr mem
pc on adr
dbus on data pc on adr
ld_ac AC ld_ir IR data on dbus rd mem
ld ir Fetch data on dbus
6 ld ac ld ir
ld pc inc pc
Controller
6 PC
inc pc
clr pc
padd
Decode
alu on dbus
add
ld pc
ld_pc
inc_pc
clr_pc
ir on adr
ALU pass
Execute dbus on data
ld ac
add alu on dbus
6 6 wr mem
clk
reset
ir_on_adr pc_on_adr
addr_bus 6
7
Introduction to Digital System Design - Copyright Zainalabedin Navabi
What is RTL?
data_bus
dbus_on_data
dbus data_on_dbus
alu_on_dbus 8
8
ld_ac AC ld_ir IR
6
6 PC
ld_pc
inc_pc
clr_pc
ALU pass
add
6 6
ir_on_adr pc_on_adr
addr_bus 6
Combinational component
8
Introduction to Digital System Design - Copyright Zainalabedin Navabi
RTL Combinational components
5-1 RTL view
5-2 RTL combinational components
5-2-1 Decoder
5-2-2 Multiplexer
5-2-3 Mux-based design
5-2-4 Parity circuit
5-2-5 Comparator
5-2-6 Adder
5-2-7 ALU
5-2-8 Fast adders
5-3 Combinational Verilog Constructs, a review
A0 A1 I0 I1 I2 I3 A0 A1 I0 I1 I2 I3
0 0 1 0 0 0 0 0 0 1 1 1
0 1 0 1 0 0 0 1 1 0 1 1
1 0 0 0 1 0 1 0 1 1 0 1
1 1 0 0 0 1 1 1 1 1 1 0
I1
en A0 A1 I0 I1 I2 I3
I2
1 0 0 0 1 1 1
1 0 1 1 0 1 1
I3
1 1 0 1 1 0 1
1 1 1 1 1 1 0
0 - - 1 1 1 1
en
Introduction to Digital System Design - Copyright Zainalabedin Navabi 13
RTL Combinational components
Decoder (functionality and gate level)
A1 A0 A0 I0
0
I1
A1 Binary 2-to-4
1 Decoder I2
I0
en I3
I1
en A0 A1 I0 I1 I2 I3
I2
0 0 0 0 1 1 1
0 0 1 1 0 1 1
I3 0 1 0 1 1 0 1
0 1 1 1 1 1 0
1 - - 1 1 1 1
en
Introduction to Digital System Design - Copyright Zainalabedin Navabi 14
RTL Combinational components
Build a 4 to 16 binary decoder
A0 I0
0
I1
A1 Binary 2-to-4
1 Decoder I2
en I3
A0 I0
0
I1
A1 Binary 2-to-4
A0 I0
0 1 Decoder I2
I1 en I3
A1 Binary 2-to-4
1 Decoder I2
en I3
A0 I0
0
I1
A1 Binary 2-to-4
1 Decoder I2
en I3
A0 I0
0
I1
A1 Binary 2-to-4
1 Decoder I2
en I3
I2
A0 I3 I4
0 I4 0 I5
Binary 2-to-4
I5 1 Decoder
I6
A1 I6 I7
1 I7
0
A2 Binary 4-to-16 I8 Binary 2-to-4 I8
0
2 Decoder I9 Decoder I9
1 Binary 2-to-4
I10 1 Decoder I10
A3 I11 I11
3 I12
I13 I12
en I14 0 I13
Binary 2-to-4
I15 I14
1 Decoder I15
a w
a
0
w
b
b 1
w = 𝑠. 𝑎 + 𝑠. 𝑏
w= ~𝑠 ? 𝑎 ∶ 𝑏
a
0 s1
a
00 S1 S0 w
b 11 w 0 0 a b 1
c 0 1 b 0
w
22
d 1 0 c
33 1
1 1 d c
0
d 1
a
0 s1
a
b 1
0 b
w
1 c
c
0
d
d 1
16 to 1 multiplexer b
c
d
Iterative
e
Logic f
g
h
I0
0 I1
Decoder i
1 I2
I3 j
k
l
m
0
n
o
p 0
1
1 S
2
3
a w
a
0
w
b
b 1
w = 𝑜𝑒 ? ~𝑠 ? 𝑎 ∶ 𝑏 ∶ 1′ 𝑏𝑍
Multiplexer – Tri-state 0
2
2
3 w
5
6
7
S1 S0
a
b
c
d
e
f
g
h
I0
0 I1
Decoder i
1 I2
I3 j
k
l
m
0
n
o
p 1
ab
00
0 0
01 11 10
ci
Ci 1 Co
0 0 0 1 0
0 2 6 4 Ci 2
1 0 1 1 1 1 3
1 3 7 5
co
ab
00 01 11 10
ci
0 0 1 0 1 0 0
0 2 6 4
Ci 1 S
1 1 0 1 0
1 3 7 5 Ci 2
s Ci 3
1 0
ab 𝑑ҧ 1
cd 00 01 11 10
00 1 1 0 1 𝑑ҧ 2
2
1 0 1 0 𝑑 3 w
01
0 0 1 1 0 4
11
𝑑ҧ 5
10 0 1 0 1
1 6
w
𝑑 7
• Odd Parity Circuit: The output is one if odd number of inputs are 1
• Even Parity Circuit: The output is one if even number of inputs are 1
I0 I0
I1 EVEN I1
ODD I2 EVEN
I2
I3 I3 ODD
• Odd Parity Circuit: The output is one if odd number of inputs are 1
I0 I0
I1 I1
I2 I2 EVEN
EVEN
I3 ODD I3 ODD
• Odd Parity Circuit: The output is one if odd number of inputs are 1
I0
I1
I2 EVEN
I3 ODD
5 ns
5 ns
5 ns
EQ GT
5 ns 10 ns
eq gt eq gt eq gt eq gt
a3 a2 a1 a0
b3 b2 b1 b0
EQ GT EQ GT EQ GT EQ GT
a lt
4-bit
Cascadable
Comparator
Q3 Q2 Q1 Q0
4
a A
b 4 B
lt
eq
0 l gt
1 e
0 g
0 4
Max (a,b)
1
10110101
+
00101101
1 11100010
ab
00 01 11 10
ci
abci cos 0 0 1 0 1
0 2 6 4
8/ 8/ 000 00
1 1 0 1 0
001 01 1 3 7 5
010 01 s
Adder 011 10 ab
00 01 11 10
100 01 ci
8/ 101 10 0 0 1 0
Co Si 0
0 2 6 4
110 10
111 11 1 0 1 1 1
1 3 7 5
co
ab
00 01 11 10
ci
a 0 1 0 1
b Si 0
0 2 6 4
Ci 1 1 0 1 0
1 3 7 5
a s
b ab
00 01 11 10
ci
Co 0 0 1 0
Ci 0
0 2 6 4
1 0 1 1 1
1 3 7 5
co
a Full Adder
b Si Ci bi ai Half Adder
Ci
a Co
b
Co
Ci
Si
C3 C2 C1 C0=0
Cout FA FA FA FA
S3 S2 S1 S0
Incrementer
b3 b2 b1 b0 1
Cout HA HA HA HA
S3 S2 S1 S0
a3 a2 a1 a0 a3 a2 a1 a0
Cin 1
Adder Adder Cin
𝑎 − 𝑏 = 𝑎 + (−𝑏) = 𝑎 + (𝑏 + 1)
0 0 0 A+B
0 0 1 A*2
0 1 0 Max(A,B)
0 1 1 A&B
1 0 0 A|B
1 0 1 2’s complement
of input A
1 1 0 A
1 1 1 ~A
a
00
b 11 w
c
First, let’s talk about a
22 new construct in
d
33 Verilog:
The always statement
f2 f1 f0 w
0 0 0 A+B
0 0 1 A*2
0 1 0 Max(A,B)
0 1 1 A&B
1 0 0 A|B
1 0 1 A 2’s cmp
1 1 0 A
1 1 1 ~A
4
a A
b 4 B
lt
eq
0 l gt
1 e
0 g
0 4
Max (a,b)
1
• nth full adder must wait until all (n-1) full adders have completed their
operations.
• This causes a delay and makes ripple carry adder extremely slow.
• The situation becomes worst when the value of n becomes very large.
• We need a design where each cell can predict its own carry instead of
waiting for carry.
p0
g0
• Carry look ahead logic uses the concepts of generating and propagating
carries.
ci+1 = ai bi + ai ci + bi ci
si = ai bi ci
ci+1 = (ai + bi) ci + ai bi= pi ci + gi
pi = ai + bi
gi = ai bi
c1 = p0 c0 + g0
c2 = p1 c1 + g1 = p1 p0 c0 + p1 g0 + g1
c3 = p2 c2 + g2 = p2 p1 p0 c0 + p2 p1 g0 + p2 g1 + g2
c4 = p3 c3 + g3
= p3 p2 p1 p0 c0 + p3 p2 p1 g0 + p3 p2 g1 + p3 g2 + g3
8 8 8 8 8 8 8 8
8 8 8 8
8 8 8 8 8 8 8 8
8 8 8 8
P0 = p7p6p5p4p3p2p1p0
G0 = g7 + p7g6 + p7p6g5 + p7p6p5g4 + p7p6p5p4g3 + p7p6p5p4p3g2 + p7p6p5p4p3p2g1 +
p7p6p5p4p3p2p1g0
C8 = G0 + P0C0
C16 = G1 + P1C8 = G1 + P1G0 + P1P0C0
C24 = G2 + P2G1 + P2P1G0 + P2P1P0C0
C32 = G3 + P3P2G1 + P3P2P1G0 + P3P2P1P0C0
82