Docsity

Test Benches - Computer Science - Lecture Slides, Slides of Computer Science

Toggle sidebar
bg1
Test Benches
โ€ขTesting a design by simulation
โ€ขUse a test bench model
โ€“an architecture body that includes an instance
of the design under test
โ€“applies sequences of test values to inputs
โ€“monitors values on output signals
โ€ขeither using simulator
โ€ขor with a process that verifies correct operation
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Test Benches - Computer Science - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Test Benches

โ€ข Testing a design by simulation

โ€ข Use a test bench model

โ€“ an architecture body that includes an instance

of the design under test

โ€“ applies sequences of test values to inputs

โ€“ monitors values on output signals

โ€ข either using simulator

โ€ข or with a process that verifies correct operation

Test Bench Example

entity test_bench is end entity test_bench;

architecture test_reg4 of test_bench is

signal d0, d1, d2, d3, en, clk, q0, q1, q2, q3 : bit;

begin

dut : entity work.reg4(behav) port map ( d0, d1, d2, d3, en, clk, q0, q1, q2, q3 ); stimulus : process is begin d0 <= โ€™1โ€™; d1 <= โ€™1โ€™; d2 <= โ€™1โ€™; d3 <= โ€™1โ€™; wait for 20 ns; en <= โ€™0โ€™; clk <= โ€™0โ€™; wait for 20 ns; en <= โ€™1โ€™; wait for 20 ns; clk <= โ€™1โ€™; wait for 20 ns; d0 <= โ€™0โ€™; d1 <= โ€™0โ€™; d2 <= โ€™0โ€™; d3 <= โ€™0โ€™; wait for 20 ns; en <= โ€™0โ€™; wait for 20 ns; โ€ฆ wait ; end process stimulus;

end architecture test_reg4;

What Is The VHDL Test Bench (TB)?

VHDL test bench (TB) is a piece of VHDL code, which

purpose is to verify the functional correctness of HDL

model.

The main objectives of TB is to:

  • Instantiate the design under test (DUT)
  • Generate stimulus waveforms for DUT
  • Generate reference outputs and compare them with the

outputs of DUT

  • Automatically provide a pass or fail indication

Test bench is a part of the circuits specification.

Its a good idea to design the test bench before the

DUT, why?

Stimulus and Response

Three ways how TB can generate the stimulus:

  • Generate them โ€œon-the-flyโ€
  • Read vectors stored as constants in an array
  • Read vectors stored in a separate system file

Response is produced in the test bench.

Response can be stored into file for further processing.

Example:

  • Stimulus can be generated with Matlab and TB feeds it

into DUT.

  • DUT generates the response and TB stores it into file.
  • Result can be compared to Matlab simulations.
  • Simple Test Bench
    • Only the DUT is instantiated into test bench.
    • Stimulus is generated inside the test bench
    • Poor reusability.
    • Suitable only for relatively simple designs.