Main Content

Choose a Test Bench for Generated HDL Code

When you generate HDL code with HDL Coder™, you can optionally generate a test bench as well. The coder also generates build-and-run scripts for the HDL simulator you specify. The test bench options are:

  • HDL test bench — An HDL test bench that includes the generated HDL DUT and files containing input and output data vectors. This test bench verifies the generated HDL DUT against test vectors generated from your Simulink® model. See Test Bench Generation.

  • Cosimulation model — A Simulink model that includes an HDL Cosimulation block that runs your generated HDL code in an HDL simulator. The model also includes your original Simulink stimulus generation, your behavioral model, and any blocks for display or analysis of the output data. The model compares the output of the HDL Cosimulation block against the output of the source subsystem. See Generate a Cosimulation Model.

  • SystemVerilog DPI test bench — An HDL test bench that includes the generated HDL DUT and a generated C-language component. The C component creates input stimuli and runs a behavioral model of the DUT subsystem. The test bench uses a direct programming interface (DPI) to run the C component inside an HDL simulation. This test bench verifies the generated HDL DUT against a C representation of the source Simulink model. See Verify HDL Design Using SystemVerilog DPI Test Bench.

  • FPGA-in-the-loop — A Simulink model that includes an FPGA-in-the-Loop block that communicates with your HDL design while it runs on the FPGA board. The model also includes your original Simulink stimulus generation, your behavioral model, and any blocks for display or analysis of the output data. The model compares the output of the FPGA-in-the-Loop block against the output of the source subsystem. See FIL Simulation with HDL Workflow Advisor for Simulink (HDL Verifier).

Select test bench options in HDL Workflow Advisor under HDL Code Generation > Set Testbench Options, or in the Model Configuration Parameters dialog box, under HDL Code Generation > Test Bench. Alternatively, for command-line access, select your test bench using the properties of makehdltb.

For FPGA-in-the-loop, select the target workflow in HDL Workflow Advisor under Set Target > Set Target Device and Synthesis Tool. Then select your FPGA and synthesis tool. You can also generate an FPGA-in-the-loop model for existing HDL code by using FPGA-in-the-Loop Wizard (HDL Verifier).

Test BenchLicense RequirementsProsCons
HDL test bench 
  • Fast compile time in HDL simulator

  • Runs simulation to generate data files, which can take a long time for large data sets

  • File I/O can slow down simulation for large data sets

  • Run test in HDL simulator

  • Fixed input stimulus

Cosimulation model
  • HDL Verifier™

  • Fast compile time in HDL simulator

  • Run tests from Simulink, including changing parameters to affect input stimulus

  • Automatic test bench execution from HDL Workflow Advisor

 
SystemVerilog DPI test bench
  • HDL Verifier

  • Simulink Coder™

  • Fast generation time because the coder does not run a simulation

  • Fast simulation time for large data sets, because the stimulus comes from generated code rather than files

  • Run test in HDL simulator

  • No tunable parameters in stimulus generation

FPGA-in-the-loop
  • HDL Verifier

  • HDL Verifier Support Package for AMD FPGA and SoC Devices or HDL Verifier Support Package for Intel® FPGA Boards

  • Run tests from Simulink, including changing parameters to affect input stimulus

  • Prototype hardware implementation of your DUT

  • Long generation time due to synthesis into FPGA

  • Hardware setup

Related Topics