Main Content

Start HDL Simulator for Cosimulation in Simulink

If you are using ModelSim™, VCS®, or Xcelium™ simulators, use this workflow to start the HDL simulator from the MATLAB® prompt.

If you are using the Vivado® simulator, the HDL Cosimulation block loads and executes the compiled design for cosimulation, so you do not need to separately start the HDL simulator.

Start ModelSim or Xcelium from MATLAB

Start the HDL simulator directly from MATLAB by calling the HDL Verifier™ vsim or nclaunch function.

>>vsim

If both tools (MATLAB and the HDL simulator) are not running on the same system, you must start the HDL simulator manually and load the HDL Verifier libraries yourself. See Cosimulation Libraries.

You can call vsim or nclaunch with additional parameters; see the reference pages for details.

You must make sure the HDL simulator executables — also called vsim (ModelSim) and nclaunch (Cadence® Xcelium) — are on the system path. See your system documentation for instructions on setting environment variables.

Linux Users

Make sure the HDL simulator executable is still on the system path after the shell is launched from MATLAB. If it is not, make sure the shell startup file does not remove it from the path environment variable.

When using the Vivado simulator for cosimulation, you do not need to start the HDL simulator separately, because the cosimulation executes as a single process with a shared DLL file.

Start VCS from MATLAB

Before launching VCS, you must first have a Simulink® model with an HDL Cosimulation block configured.

  1. Supply the required information to the launchVCS function to compile the HDL design and launch the VCS simulator. For example:

    launchVCS(VerilogFiles="UDelay.v", ...
              HDLTopLevelName="UDelay", ...
              RunMode="cli", ...  
              PreSimulationTcl= ...
                 ["force UDelay.clk 1 0 ns, 0 5 ns -repeat 10 ns", ...
                  "force UDelay.reset 1 0 ns, 0 5 ns"]);
  2. To establish a connection between Simulink and VCS, type the following in the VCS window that opens.

    run
  3. You can optionally use the Auto Fill button on the HDL Cosimulation block mask to obtain port information, or manually edit the port table in the block mask.

  4. To execute cosimulation, click the Run button on the Simulink Toolstrip.

  5. Once the simulation completes, you can optionally execute postsimulation commands by executing a Tcl script at the VCS prompt.

    do cosimVCS.postsim.tcl

To start another cosimulation, type restart before executing any presimulation commands, and run. For example, execute these commands at the VCS prompt:

restart
do cosimVCS.presim.tcl
run

Load Instance of HDL Module for Cosimulation

Xcelium users load an instance of the HDL module for cosimulation using the hdlsimulink function. ModelSim users do the same using the vsimulink function.

 Example of loading HDL Module instance — Xcelium users

 Example of loading HDL Module instance — ModelSim users

This command opens a simulation workspace for manchester and displays a series of messages in the HDL simulator command window as the simulator loads the packages and architectures for the HDL module.