Documentation

vsim

Start and configure ModelSim for use with HDL Verifier

Syntax

vsim('PropertyName', 'PropertyValue'...)

Description

vsim('PropertyName', 'PropertyValue'...) starts and configures the ModelSim® simulator (vsim) for use with the MATLAB® and Simulink® features of HDL Verifier™. The first folder in ModelSim matches your MATLAB current folder.

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

  • vsimmatlab: link to MATLAB from ModelSim

  • vsimulink: link to Simulink from ModelSim

  • vmatlabsysobj: link to MATLAB System object™ from ModelSim.

You can use these new ModelSim commands in place of the ModelSim vsim command. These commands are used to load instances of VHDL entities or Verilog modules for simulations that use MATLAB or Simulink for verification

The property name/property value pair settings allow you to customize the Tcl commands used to start ModelSim, the vsim executable to be used, the path and name of the DO file that stores the start commands, and for Simulink applications, details about the mode of communication to be used by the applications.

    Tip   Use pingHdlSim to add a pause between the call to vsim and the call to actually run the simulation when you are attempting to automate the cosimulation.

Property Name/Property Value Pairs

'libdir'

Specifies the path to HDL Verifier HDL libraries

  • folder

    Folder containing the libraries for ModelSim to communicate with MATLAB when ModelSim runs on a machine that does not have MATLAB.

If this property is not set, the default path in the MATLAB installation is used.

'libfile'

Specifies a particular library file

  • library_file_name

    . This value defaults to the version of the library file that was built using the same compiler that MATLAB itself uses. If the HDL simulator links other libraries, including SystemC libraries, that were built using a compiler supplied with the HDL simulator, you can specify an alternate library file with this property. See HDL Verifier Libraries for versions of the library built using other compilers.

    Do not include the OS-specific library extension in library_file_name.

'pingTimeout'

Time to wait, in seconds, for the HDL simulator to start.

  • seconds

    Specify 0 (the default) to immediately return without waiting.

'rundir'

Specifies where to run the HDL simulator

  • dirname

    By default, the function uses the current working folder.

    The following conditions apply to this name/value pair:

    • If the value of dirname is "TEMPDIR", the function creates a temporary folder in which it runs ModelSim.

    • If you specify dirname and the folder does not exist, you will get an error.

'runmode'

Specifies how to start the HDL simulator.

  • mode

    You can set run mode to one of the following values:

    • 'Batch': Start the HDL simulator in the background with no window (Linux®) or in a non-interactive command window (Windows®).

    • 'CLI': Start the HDL simulator in an interactive terminal window.

    • 'GUI': Start the HDL simulator with the ModelSim graphical user interface.

    This value defaults to 'GUI'.

'socketmatlabsysobj'

Specifies TCP/IP socket communication for links between ModelSim and MATLAB.

  • tcp_spec

    For TCP/IP socket communication on a single computing system, the tcp_spec can consist of just a TCP/IP 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.

    For more information on choosing TCP/IP socket ports, see TCP/IP Socket Ports

    If ModelSim and MATLAB run on the same computing system, you have the option of using shared memory for communication. Shared memory is the default mode of communication and takes effect if you do not specify -socket <tcp-spec> on the command line.

      Note:   The function applies the communication mode specified by this property to all invocations of MATLAB from ModelSim.

'socketsimulink'

Specifies TCP/IP socket communication for links between ModelSim and Simulink.

  • tcp_spec

    For TCP/IP socket communication on a single computing system, the tcp_spec can consist of just a TCP/IP 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.

    For more information on choosing TCP/IP socket ports, see TCP/IP Socket Ports

    If ModelSim and Simulink run on the same computing system, you have the option of using shared memory for communication. Shared memory is the default mode of communication and takes effect if you do not specify -socket <tcp-spec> on the command line.

      Note:   The function applies the communication mode specified by this property to all invocations of Simulink from ModelSim.

'startms'

Determines whether ModelSim is launched from vsim.

  • yes | no

    This property defaults to yes, which launches ModelSim and creates a startup Tcl file. If startms is set to no, ModelSim does not launch, but the HDL simulator still creates a startup Tcl file.

    This 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 HDL Verifier Libraries.

'startupfile'

Specifies Tcl script for startup

  • pathname

    Each invocation of vsim creates a Tcl script that is applied during HDL simulator startup. By default, this function generates the filename of compile_and_launch.tcl in the folder specified by rundir. With this property, you can specify the name and location of the generated Tcl script. If the file name already exists, that file's 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

'tclstart'

Specifies one or more Tcl commands to execute during ModelSim startup

  • tcl_commands

    Specify a command string or a cell array of command strings, with each entry being a Tcl command. These commands are appended to the startup file.

'vsimdir'

Specifies the path name to the folder with the ModelSim simulator executable (vsim.exe) to be started.

  • pathname

    By default, the function uses the first version of vsim.exe that it finds on the system path (defined by the path variable) . Use this option to start different versions of the ModelSim simulator or if the version of the simulator you want to run does not reside on the system path.

Examples

The following function call sequence changes the folder location to VHDLproj and then calls the function vsim. Because the call to vsim omits the 'vsimdir' and 'startupfile' properties, vsim uses the default vsim executable and creates a temporary DO file in a temporary folder. The 'tclstart' property specifies a Tcl command that loads an instance of a VHDL entity for MATLAB verification:

  • The vsimmatlab command loads an instance of the VHDL entity parse in the library work for MATLAB verification.

  • The matlabtb command begins the test bench session for an instance of entity parse, using TCP/IP socket communication on port 4449 and a test bench timing value of 10 ns.

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

The following function call sequence changes the folder location to VHDLproj and then calls the function vsim.

  • Because the call to vsim omits the 'vsimdir' and 'startupfile' properties, vsim uses the default vsim executable and creates a DO file in a temporary folder.

  • The 'tclstart' property specifies a Tcl command that loads the VHDL entity parse in the library work for cosimulation between vsim and Simulink.

  • The 'socketsimulink' property specifies that TCP/IP socket communication on the same computer is to be used for links between Simulink and ModelSim, using socket port 4449.

>>cd VHDLproj  % Change folder to ModelSim project folder
>>vsim('tclstart','vsimulink work.parse','socketsimulink','4449')
 
Was this topic helpful?