| EDA Simulator Link™ MQ | ![]() |
The EDA Simulator Link MQ software offers flexibility in how you start and control an HDL model test bench or component session with MATLAB software. A MATLAB link session is the application of a matlabtb, matlabtbeval, or matlabcp function.
To start and control the execution of a simulation in the MATLAB environment, perform the following steps:
Place MATLAB link function on the MATLAB search path.
Load an HDL model in the HDL simulator for simulation and verification with MATLAB.
Decide on how you want to schedule invocations of the MATLAB test bench function.
The MATLAB function associated with an HDL component must be on the MATLAB search path or reside in the current working directory (see the MATLAB cd function). To verify whether the function is accessible, use the MATLAB which function. The following call to which checks whether the function MyVhdlFunction is on the MATLAB search path:
which MyVhdlFunction D:\work\modelsim\MySym\MyVhdlFunction.m
If the specified function is on the search path, which displays the complete path to the function's M-file. If the function is not on the search path, which informs you that the file was not found.
To add a MATLAB function to the MATLAB search path, open the Set Path window by clicking File > Set Path, or use the addpath command. Alternatively, for temporary access, you can change the MATLAB working directory to a desired location with the cd command.
Start the MATLAB server as follows:
Start MATLAB.
In the MATLAB Command Window, call the hdldaemon function with property name/property value pairs that specify whether the EDA Simulator Link MQ software is to perform the following tasks:
Use shared memory or TCP/IP socket communication
Return time values in seconds or as 64-bit integers
Use the following syntax:
hdldaemon('PropertyName', PropertyValue...)
For example, the following command specifies using socket communication on port 4449 and a 64-bit time resolution format for the MATLAB function's output ports.
hdldaemon('socket', 4449, 'time', 'int64')See hdldaemon reference documentation for when and how to specify property name/property value pairs and for more examples of using hdldaemon.
Note
The communication mode that you specify (shared memory or TCP/IP
sockets) must match what you specify for the communication mode when
you initialize the HDL simulator for use with a MATLAB link session
using the matlabtb or matlabtbeval HDL
simulator command. In addition, if you specify TCP/IP socket mode,
the socket port that you specify with this function and the HDL simulator
command must match. For more information on modes of communication,
see Choosing TCP/IP Socket Ports. |
The MATLAB server can service multiple simultaneous HDL simulator modules and clients. However, your M-code must track the I/O associated with each entity or client.
Note You cannot begin an EDA Simulator Link MQ transaction between MATLAB and the HDL simulator from MATLAB. The MATLAB server simply responds to function call requests that it receives from the HDL simulator. |
The first step to starting an HDL simulator and MATLAB test bench session is to check the MATLAB server's link status. Is the server running? If the server is running, what mode of communication and, if applicable, what TCP/IP socket port is the server using for its links? You can retrieve this information by using the MATLAB function hdldaemon with the 'status' option. For example:
hdldaemon('status')
The function displays a message that indicates whether the server is running and, if it is running, the number of connections it is handling. For example:
HDLDaemon socket server is running on port 4449 with 0 connections
If the server is not running, the message reads
HDLDaemon is NOT running
See "Link Status" in the hdldaemon reference documentation for information on determining the mode of communication and the TCP/IP socket in use.
Start the HDL simulator directly from MATLAB by calling the MATLAB function vsim. See Starting the HDL Simulator for instructions on using vsim.
After you establish a link between the HDL simulator and MATLAB, you can then apply stimuli to the test bench environment. One way of applying stimuli is through the iport parameter of the linked MATLAB function. This parameter forces signal values by deposit.
Other ways to apply stimuli include issuing force commands in the ModelSim main window or using the Edit > Clock option in the ModelSim Signals window.
For example, consider the following sequence of force commands:
VSIM n> force clk 0 0 ns, 1 5 ns -repeat 10 ns VSIM n> force clk_en 1 0 VSIM n> force reset 0 0
These commands drive the following signals:
The clk signal to 0 at 0 nanoseconds after the current simulation time and to 1 at 5 nanoseconds after the current HDL simulation time. This cycle repeats starting at 10 nanoseconds after the current simulation time, causing transitions from 1 to 0 and 0 to 1 every 5 nanoseconds, as the following diagram shows.
![]()
For example,
force /foobar/clk 0 0, 1 5 -repeat 10
The clk_en signal to 1 at 0 nanoseconds after the current simulation time.
The reset signal to 0 at 0 nanoseconds after the current simulation time.
These steps describe a typical sequence for running a simulation interactively from the main HDL simulator window:
Start the simulation by entering the HDL simulator run command.
The run command offers a variety of options for applying control over how a simulation runs. For example, you can specify that a simulation run for several time steps.
The following command instructs the HDL simulator to run the loaded simulation for 50000 time steps:
run 50000
Set breakpoints in the HDL and MATLAB code to verify and analyze simulation progress and correctness.
How you set breakpoints in the HDL simulator will vary depending on what simulator application you are using. In MATLAB, there are several ways you can set breakpoints; for example, by using the Set/Clear Breakpoint button on the toolbar.
Step through the simulation and examine values.
How you step through the simulation in the HDL simulator will vary depending on what simulator application you are using. In MATLAB, there are several ways you can step through code; for example, by clicking theStep toolbar button.
When you block execution of the MATLAB function, the HDL simulator also blocks and remains blocked until you clear all breakpoints in the function's M-code.
Resume the simulation, as needed.
How you resume the simulation in the HDL simulator will vary depending on what simulator application you are using. In MATLAB, there are several ways you can resume the simulation; for example, by clicking the Continue toolbar button.
The following HDL simulator command resumes a simulation:
run -continue
For more information on HDL simulator and MATLAB debugging features, see the appropriate HDL simulator documentation and MATLAB online help or documentation.
Because the HDL simulator issues the service requests during a MATLAB test bench session, you must restart a test bench session from the HDL simulator. To restart a session, perform the following steps:
Make the HDL simulator your active window, if your input focus was not already set to that application.
Reload HDL design elements and reset the simulation time to zero.
Reissue the matlabtb command.
Note To restart a simulation that is in progress, issue a break command and end the current simulation session before restarting a new session. |
When you are ready to stop a test bench session, it is best to do so in an orderly way to avoid possible corruption of files and to ensure that all application tasks shut down appropriately. You should stop a session as follows:
Make the HDL simulator your active window, if your input focus was not already set to that application.
Halt the simulation. You must quit the simulation at the HDL simulator side or MATLAB may hang until the simulator is quit.
Close your project.
Exit the HDL simulator, if you are finished with the application.
Quit MATLAB, if you are finished with the application. If you want to shut down the server manually, stop the server by calling hdldaemon with the 'kill' option:
hdldaemon('kill')
For more information on closing HDL simulator sessions, see the HDL simulator documentation.
![]() | Associating a MATLAB Link Function with an HDL Module | MATLAB and ModelSim Tutorial | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |