Main Content

Prepare to Import HDL Code for Cosimulation

HDL Code Import Features

The HDL Verifier™ Cosimulation Wizard lets you take existing HDL code, from any source, and use it to create a MATLAB® component or test bench function, System object™, or Simulink® HDL Cosimulation block. You can then use one of these cosimulation interfaces for cosimulation with a supported HDL simulator. See Supported EDA Tools and Hardware.

After you finish running the wizard, you must complete some missing pieces in the generated cosimulation interface. For example, if you specified a MATLAB function, the generated script contains some simple port I/O instructions and empty routines, which you must fill in before you can run HDL cosimulation.

What You Need to Know

You are expected to understand the following about the HDL code you want to import:

  • The name of the HDL files or compilation scripts to use in creating the block or function

  • Supported Data Types in HDL/MATLAB/Simulink

  • For Simulink blocks and MATLAB System objects:

    • The name of the top module to be used for cosimulation

    • Output port types and sample times

    • Whether there are clocks and resets and which of them you want to use, and timing parameters

    • Timescale

  • For MATLAB functions:

    • Whether you want to create a component function or test bench function, or both

    • How you want to trigger the callback (rising or falling edge, repeat, sensitivity)

For Simulink blocks, you must also have a destination model to receive the generated cosimulation interface block.

What the Cosimulation Wizard Needs to Know

The Cosimulation Wizard guides you through specifying this information (some information depends on which type of cosimulation interface you want it to create):

  • Type of cosimulation (MATLAB, MATLAB System object, or Simulink)

  • Which HDL simulator to use

  • HDL files to be included and compilation instructions

  • HDL module information

  • Callback details

  • Input and output port details

  • Clock and reset information and HDL simulator start time alignment

HDL Code Import Workflows

When you are ready to begin:

  1. Close your Vivado®, ModelSim®, or Xcelium™ simulator.

  2. Open the Cosimulation Wizard from the MATLAB command prompt:


  3. Follow the workflow specific to the cosimulation interface you want to create:

Cosimulation Wizard Navigation

On each selection pane there is a status window and navigational options.

  • The status window displays the current options you have selected. Warnings are displayed here also.

  • Click Help to display this HDL Code Import topic.

  • Click Cancel to exit the Cosimulation Wizard without creating a cosimulation component.

  • Click Back and Next to navigate forwards and backwards, respectively, through the application. Note that you can move forwards only after you have provided all information for the step you are on.

The last step of the Cosimulation Wizard generates the function scripts, System objects, or blocks and launches the specified HDL simulator.

  • If you select a function or System object, the MATLAB Editor opens with the unfinished script or System object ready for editing.

  • If you select a block, Simulink opens with the new block inside an untitled model.

Cosimulation Wizard Limitations

  • When creating an HDL Cosimulation block or System object for use with Simulink, you may access only the I/O ports on the top level of the HDL design. If you want to cosimulate at multiple levels of your design, you cannot use this application to set up your HDL Cosimulation block or System object.

  • You cannot create multiple HDL Cosimulation blocks, nor can you use multiple generated HDL Cosimulation blocks in the same model. This is primarily because you can only access the top level of the HDL design. There is no need for additional blocks.