Test Bench Generation
How Test Bench Generation Works
HDL Coder™ writes the DUT stimulus and reference data from
your MATLAB® or Simulink® simulation to data files (
During HDL simulation, the HDL test bench reads the saved stimulus
.dat files. The test bench compares the
actual DUT output with the expected output, which is also saved in
.dat files. After you generate code, the message window displays links
to the test bench data files.
Reference data is delayed by one clock cycle in the waveform viewer compared to default test bench generation due to the delay in reading data from files.
Test Bench Data Files
The coder saves stimulus and reference data for each DUT input
and output in a separate test bench data file (
with the following exceptions:
Two files are generated for the real and imaginary parts of complex data.
Constant DUT input data is written to the test bench as constants.
Vector input or output data is saved as a single file.
Test Bench Data Type Limitations
If you have double, single, or enumeration data types at the DUT inputs and outputs, the simulation data is generated as constants in the test bench code, instead of writing the simulation data to files.
Use Constants Instead of File I/O
You can generate test bench stimulus and reference data as constants in the test bench code instead of using file I/O. However, simulating a long running test bench that uses constants requires more memory than a test bench that uses file I/O.
Test bench generation automatically generates data as constants if your DUT inputs or outputs use data types that are not supported for file I/O. For details, see Test Bench Data Type Limitations.
To generate a test bench that uses constants instead of file I/O:
In the HDL Workflow Advisor, select the HDL Verification > Verify with HDL Test Bench task.
In the Test bench Options tab, disable the Use file I/O for test bench option.