LectureModule 5 VHDL FA Testbenches
LectureModule 5 VHDL FA Testbenches
Introduction to Hardware
Description Languages – HDLs
Module 5 – VHDL STD_LOGIC, Full
Adder (FA) Functional Code,
Testbenches
1
9/8/16
0, 1, and Z
9/8/16
© Dorin Patru 3
2
9/8/16
Caution!
VHDL is a strongly type-checked language, i.e.
LeftHandSide-DataObjectType ==
RightHandSide-DataObjectType
• For example, the compiler will not allow the
assignment:
BIT ß//à STD_LOGIC,
although the values of BIT are inxifact
yi a subset of
the values of STD_LOGIC ci 00 01 11 10
0 1 1
ci x i y i c
i + 1
si
9/8/16 1 1 1
© Brown, Vranesic, Patru 5
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
VHDL 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/8/16
© Brown, Vranesic, Patru 6
3
9/8/16
4
9/8/16
Testbench Architecture
5
9/8/16
Testbench Architecture
• The process tb applies over time eight input combinations to the inputs of the
UUT
• After each combination is applied, the process waits 20 ns (equivalent
simulation steps) before verifying the outputs and applying the next input
combination
• The WAIT period is determined from design specifications
9/8/16
© Brown, Vranesic, Patru 12
6
9/8/16
• The ASSERT statement verifies that the UUT’s outputs have their expected values
• If there is a difference è an error message is displayed
• A testbench:
– Should be written for every design/circuit
– Can be written before or in parallel with the circuit description
9/8/16
© Brown, Vranesic, Patru 13
9/8/16
© Brown, Vranesic, Patru 14
7
9/8/16
9/8/16
© Dorin Patru 15
9/8/16
© Dorin Patru 16
8
9/8/16
9/8/16
© Dorin Patru 17
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/8/16
© Dorin Patru 18
9
9/8/16
9/8/16
© Dorin Patru 19
9/8/16
© Dorin Patru 20
10