LectureModule 4 Verilog FA Testbenches
LectureModule 4 Verilog FA Testbenches
Introduction to Hardware
Description Languages – HDLs
Verilog Code for the Full Adder
xi yi
ci 00 01 11 10
0 1 1
ci x i y i c
i + 1
si
1 1 1
0 0 0 0 0
0 0 1 0 1 si = x i yi ci
0 1 0 0 1
0 1 1 1 0 xi yi
1 0 0 0 1
ci 00 01 11 10
1 0 1 1 0
1 1 0 1 0 0 1
1 1 1 1 1
1 1 1 1
Verilog for a Full-Adder
(a) Truth table
c = xy +xc +yc i+1 i i i i i i
xxi
yyi ssi
Cinci
Cout
ci + 1
(c) Circuit
9/6/16
© Brown, Vranesic, Patru 2
1
9/6/16
Figure 3.18. Verilog code for the full-adder using gate level primitives.
9/6/16
© Brown, Vranesic, Patru 3
2
9/6/16
9/6/16
© Brown, Vranesic, Patru 6
3
9/6/16
4
9/6/16
The circuit
9/6/16
© Dorin Patru 10
5
9/6/16
6
9/6/16
9/6/16
© Brown, Vranesic, Patru 13
7
9/6/16
9/6/16
© Dorin Patru 16
8
9/6/16
Transcript window
9/6/16
© Dorin Patru 18
9
9/6/16
9/6/16
© Dorin Patru 19
Objects window
• Allows one to select more internal signals to be
stored and viewed in the simulation waveform
window
9/6/16
© Dorin Patru 20
10
9/6/16
9/6/16
© Dorin Patru 21
Design “Bug”
• Let’s ee what happens if there is a design “bug”
or error;
• We voluntarily insert the latter as a typo: the
third AND gate becomes a NAND gate;
• The circuit that is synthesized is a perfectly valid
circuit, except for the fact that it doesn’t
implement the required function;
• The synthesis tool will not reply with an error,
BUT the testbench should!
9/6/16
© Dorin Patru 22
11
9/6/16
9/6/16
© Dorin Patru 23
9/6/16
© Dorin Patru 24
12