Starting the HDL Simulator

Starting the HDL Simulator from MATLAB

Start the ModelSim HDL simulator simulator directly from MATLAB or Simulink by calling the MATLAB function vsim. This function starts and configures the HDL simulator for use with the EDA Simulator Link MQ software. By default, the function starts the first version of the simulator executable (vsim.exe) that it finds on the system path (defined by the path variable), using a temporary DO file that is overwritten each time the HDL simulator starts.

To start the HDL simulator from MATLAB, enter vsim at the MATLAB command prompt:

>> vsim

You can customize the DO startup file and communication mode to be used between MATLAB or Simulink and the HDL simulator by specifying the call to vsim with property name/property value pairs. Refer to vsim reference documentation for specific information regarding the property name/property value pairs.

See Examples of Starting the ModelSim Simulator from MATLAB for examples of using vsim with various property/name value pairs and other parameters.

When you specify a communication mode using vsim, the function applies the specified communication mode to all MATLAB or Simulink/HDL simulator sessions.

Examples of Starting the ModelSim Simulator from MATLAB

The following example changes the directory location to VHDLproj and then calls the function vsim. Because the command line omits the 'vsimdir' and 'startupfile' properties, vsim creates a temporary DO file. The 'tclstart' property specifies Tcl commands that load and initialize the HDL simulator for test bench instance modsimrand.

cd VHDLproj
vsim('tclstart',...
 'vsimmatlab modsimrand; matlabtb modsimrand 10 ns -socket 4449')

The following example changes the directory location to VHDLproj and then calls the function vsim. Because the function call omits the 'vsimdir' and 'startupfile' properties, vsim creates a temporary DO file. The 'tclstart' property specifies a Tcl command that loads the VHDL entity parse in library work for cosimulation between vsim and Simulink. The 'socketsimulink' property specifies TCP/IP socket communication on the same computer, using socket port 4449.

cd VHDLproj
vsim('tclstart', 'vsimulink work.parse', 'socketsimulink', '4449')

The following example has the HDL compilation and simulation commands run automatically when you start the ModelSim software from MATLAB.

vsim('tclstart', …
        {'vlib work', 'vlog +acc clocked_inverter.v hdl_top.v', 'vsim +acc hdl_top' });

This next example loads the HDL simulation just as in the previous example but it also loads in the Link to Simulink library, uses socket number 5678 to communicate with cosimulation blocks in Simulink models, and uses an HDL time precision of 10 ps.

vsim('tclstart', …
             {'vlib work', 'vlog -novopt clocked_inverter.v hdl_top.v', …
              'vsimulink hdl_top -socket 5678 -t 10ps'});

Or

vsim('tclstart', …
             {'vlib work', 'vlog -novopt clocked_inverter.v hdl_top.v', …
               'vsimulink hdl_top -t 10ps'}, …
               'socketsimulink', 5678);

Starting the ModelSim Software from a Shell

To start the HDL simulator from a shell and include the EDA Simulator Link MQ libraries, you need to first run the configuration script. See Setting Up the HDL Simulator for Use with the Link Software.

After you have the configuration files, you can start the ModelSim software from the shell by typing:

% vsim -f matlabconfigfile modelname

matlabconfigfile should be the name of the MATLAB configuration file you created either with the guided script (Linux/UNIX) or by creating the file yourself (Windows). If you are connecting to Simulink, this should be the name of the Simulink configuration file. Either way, you must also specify the path to the configuration file if it does not reside in the same directory as vsim.exe.

The configuration file mainly defines the -foreign option to vsim which in turn loads the EDA Simulator Link MQ shared library and specifies its entry point.

You can also specify any other existing configuration files you may also be using with this call.

If you are performing this step manually, the following use of -foreign with vsim loads the EDA Simulator Link MQ client shared library and specifies its entry point:

% vsim -foreign matlabclient /path/library

where path is the path to this particular EDA Simulator Link MQ library. See Using the EDA Simulator Link MQ Libraries to find the correct library name for your machine.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS