The objectives of a TB are:
The GU (generation unit) is written as a separate entity at the top of the testbench; it contains no input or output ports.
Content: embedded test, test vector generation, clock signals, dense test vectors, random test vectors, array constants for test vectors, using files, complete test bench, exercises
warning
error
failure
potential problem
condition that will cause an error
condition that will cause a disastrous error
The use of loop statement allows the designer to generate any complex and periodic test sequence. For example the following entity generates a 16-bit Gray-code pattern. The provided test vectors have only one bit changes between the adjacent values in the sequence. This may be very usefull for an extensive test coverage.
The input vector test file inpvect.sv:
and the results of simulation with the input vectors read from the inpvect.sv file:
The algorithm operates by continually subtracting the smaller of the two numbers. If a becomes smaller than b, it swaps the values and continues until a or b equals zero. The VHDL model integrates two files one for the input test and reference vectors and one for the verification results. The input file is called gcd_test.sv; the output file is called gcd_res.sv.
For example the gcd_test.sv file contains: