Main Content

vsim

R2026b

Start and configure ModelSim for use with HDL Verifier

Description

vsim starts and configures the ModelSim™ simulator for use with the MATLAB® or Simulink® cosimulation.

vsim creates a startup (or .do) file that adds these Tcl commands to ModelSim:

You can use these ModelSim Tcl commands instead of the ModelSim vsim command. These commands load instances of VHDL® entities or Verilog® modules for simulations that use MATLAB or Simulink for verification.

Tip

When attempting to automate the cosimulation, use pingHdlSim to add a pause between the call to vsim and the call to run the simulation.

example

vsim(Name=Value) configures the ModelSim simulator using options specified by one or more name-value pair arguments.

example

Examples

collapse all

Change the folder location to the ModelSim project folder, and then call the vsim function using the default executable. The function creates a temporary .do file in a temporary folder.

Specify the Tcl command vsimmatlab by using the 'tclstart' name-value pair argument. Specify to load an instance of the VHDL entity parse in the library work for MATLAB verification.

Begin the testbench session for an instance of the entity parse by using the matlabtb command. Specify TCP/IP socket communication on port 4449 and a testbench timing value of 10 ns.

cd VHDLproj  % Change folder to ModelSim project folder
vsim(tclstart='vsimmatlab work.parse; matlabtb parse 10 ns -socket 4449')

Change the folder location to the ModelSim project folder, and then call the vsim function. Specify the use of TCP/IP socket communication on the same computer for links between Simulink and ModelSim by using the 'socketsimulink' name-value pair argument. Specify using socket port 4449.

cd VHDLproj  % Change folder to ModelSim project folder
vsim(tclstart='vsimulink work.parse',socketsimulink='4449')
 

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: vsim(tclstart='vsimulink work.parse',socketsimulink='4449') specifies executing the vsimulink command during startup and using port number 4449 for socket communication between ModelSim and Simulink.

Path to the HDL Verifier HDL libraries, specified as a folder name. The folder contains the libraries that enable ModelSim to communicate with MATLAB when ModelSim runs on a machine that does not have MATLAB installed.

If this property is not specified, the function uses the default path in the MATLAB installation.

Location to run the HDL simulator, specified as a folder name.

If the value is “TEMPDIR”, the function creates a temporary directory to run ModelSim. By default, the function uses the current folder.

Run mode for the HDL simulator, specified as one of the values in this table.

Value

Description

'GUI'

Start the HDL simulator with the ModelSim graphical user interface.

'CLI'

Start the HDL simulator in an interactive terminal window.

'Batch'

Start the HDL simulator in the background with no window (Linux®) or in a noninteractive command window (Windows®).

TCP/IP socket communication for links between ModelSim and MATLAB, specified as a port number or service name. If you are setting up communication between computing systems, you must also specify the internet address or name of the remote host.

Note

  • If ModelSim and MATLAB are running on the same computer, you can use shared memory for communication.

  • When this argument is not specified, the function uses shared memory communication. For more information on choosing TCP/IP socket ports, see TCP/IP Socket Ports.

TCP/IP socket communication for links between ModelSim and Simulink, specified as a port number or service name. If you are setting up communication between computing systems, you must also specify the name or internet address of the remote host.

Note

  • If ModelSim and MATLAB are running on the same computer, you can use shared memory for communication.

  • When this argument is not specified, the function uses shared memory communication. For more information on choosing TCP/IP socket ports, see TCP/IP Socket Ports.

Specify yes to create a startup Tcl file and launch ModelSim from vsim. Specify no to create a startup Tcl file without launching ModelSim.

The startup Tcl file contains pointers to MATLAB libraries. To run ModelSim on a machine without MATLAB, copy the startup Tcl file and MATLAB library files to the remote machine and start ModelSim manually. See Cosimulation Libraries.

Name and location of the generated Tcl file, specified as a path name. Each invocation of vsim creates a Tcl script that is applied during HDL simulator startup. By default, vsim generates the file name compile_and_launch.tcl in the folder specified by rundir. If the file name already exists, the file contents are overwritten. You can edit and use the generated file in a regular shell outside of MATLAB. For example:

sh> vsim -gui -do compile_and_launch.tcl

Tcl commands to execute during ModelSim startup, specified as one of these values:

  • vsimmatlab

  • vsimulink

  • vsimmatlabsysobj

The function appends these commands to the startup file.

Path to the ModelSim executable folder, specified as a path name. By default, the function uses the first version of vsim.exe that it finds on the system path (defined by the path variable).

Specify this name-value pair argument if you want to start a different version of the ModelSim simulator, or if the version of the simulator you want to run is not on the system path.

Version History

Introduced in R2008a

expand all