matlabtb - Schedule MATLAB test bench session for instantiated HDL module

Syntax

matlabtb <instance>
[<time-specs>]
[-socket <tcp-spec>]
[-rising <port>[,<port>...]]
[-falling <port> [,<port>,...]] 
[-sensitivity <port>[,<port>,...]]
[-mfunc <name>]
[-use_instance_obj]
[-argument]

Arguments

<instance>

Specifies the instance of an HDL module that the EDA Simulator Link MQ software associates with a MATLAB test bench function. By default, matlabtb associates the instance with a MATLAB function that has the same name as the instance. For example, if the instance is myfirfilter, matlabtb associates the instance with the MATLAB function myfirfilter (note that hierarchy names are ignored; for example, if your instance name is top.myfirfilter, matlabtb would associate only myfirfilter with the MATLAB function). Alternatively, you can specify a different MATLAB function with -mfunc.

<time-specs>

Specifies a combination of time specifications consisting of any or all of the following:

<timen>,...Specifies one or more discrete time values at which the HDL simulator calls the specified MATLAB function. Each time value is relative to the current simulation time. Even if you do not specify a time, the HDL simulator calls the MATLAB function once at the start of the simulation. Separate multiple time values by a space, for example: matlabtb vlogtestbench_top 1e6 fs 3 2e3 ps -repeat 3 ns -cancel 7ns
-repeat <time>Specifies that the HDL simulator calls the MATLAB function repeatedly based on the specified <timen>,... pattern. The time values are relative to the value of tnow at the time the HDL simulator first calls the MATLAB function.
-cancel <time>Specifies a time at which the specified MATLAB function stops executing. The time value is relative to the value of tnow at the time the HDL simulator first calls the MATLAB function. If you do not specify a cancel time, the application calls the MATLAB function until you finish the simulation, quit the session, or issue a nomatlabtb call.

All time specifications for the matlabtb functions appear as a number and, optionally, a time unit:

-socket <tcp_spec>

Specifies TCP/IP socket communication for the link between the HDL simulator and MATLAB. For TCP/IP socket communication on a single computer, the <tcp_spec> can consist of just a TCP/IP port number or service name (alias). If you are setting up communication between computers, you must also specify the name or Internet address of the remote host that is running the MATLAB server (hdldaemon). See Specifying TCP/IP Values for some valid tcp_spec examples.

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

If you run the HDL simulator and MATLAB on the same computer, 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.

-rising <signal>[, <signal>...]

Indicates that the application calls the specified MATLAB function on the rising edge (transition from '0' to '1') of any of the specified signals. Specify -rising with the path names of one or more signals defined as a logic type.

-falling <signal>[, <signal>...]

Indicates that the application calls the specified MATLAB function whenever any of the specified signals experiences a falling edge—changes from '1' to '0'. Specify -falling with the path names of one or more signals defined as a logic type.

-sensitivity <signal>[, <signal>...]

Indicates that the application calls the specified MATLAB function whenever any of the specified signals changes state. Specify -sensitivity with the path names of one or more signals. Signals of any type can appear in the sensitivity list and can be positioned at any level of the HDL design.

-mfunc <name>

The name of the associated MATLAB function. If you omit this argument, matlabtb associates the HDL module instance to a MATLAB function that has the same name as the HDL instance. For example, if the HDL module instance is myfirfilter, matlabtb associates the HDL module instance with the MATLAB function myfirfilter. If you omit this argument and matlabtb does not find a MATLAB function with the same name, the command generates an error message.

-use_instance_obj (Beta Feature)

Instructs the function specified with the argument -mfunc to use an HDL instance object passed by EDA Simulator Link MQ to the m-function. The -use_instance_obj argument is called with matlabtb in the following format:

matlabtb modelname -mfunc funcname -use_instance_obj

When you call matlabcp with the use_instance_obj argument, the m-function has the following signature:

function MyFunctionName(hdl_instance_obj)

The HDL instance object (hdl_instance_obj) has the fields shown in the following table.

FieldRead/Write AccessDescription
tnextWrite only

Used to schedule a callback during the set time value. This field is equivalent to old tnext. For example:

hdl_instance_obj.tnext = hdl_instance_obj.tnow + 5e-9

will schedule a callback at time equals 5 nanoseconds from tnow.

userdataRead/WriteStores state variables of the current matlabtb instance. You can retrieve the variables the next time the callback of this instance is scheduled.
simstatusRead only

Stores the status of the HDL simulator. The EDA Simulator Link MQ software sets this parameter to 'Init' during the first callback for this particular instance and to 'Running' thereafter. simstatus is a read-only property.

>> hdl_instance_obj.simstatus

ans=
      Init
instanceRead only

Stores the full path of the Verilog/VHDL instance associated with the callback. instance is a read-only property. The value of this field equals that of the module instance specified with the function call. For example:

In the HDL simulator:

hdlsim> matlabtb osc_top -mfunc oscfilter use_instance_obj

In MATLAB:

>> hdl_instance_obj.instance

ans=
		osc_top
argumentRead onlyStores the argument set by the -argument option of matlabtb. For example:
matlabtb osc_top -mfunc oscfilter -use_instance_obj -argument foo
The link software supports the -argument option only when it is used with -use_instance_obj, otherwise the argument is ignored. argument is a read-only property.
>> hdl_instance_obj.argument

ans= 
    	foo
portinfoRead onlyStores information about the VHDL and Verilog ports associated with this instance. portinfo is a read-only property, which has a field structure that describes the ports defined for the associated HDL module. For each port, the portinfo structure passes information such as the port's type, direction, and size. For more information on port data, see Gaining Access to and Applying Port Information.
hdl_instance_obj.portinfo.field1.field2.field3

    Note   When you use use_instance_obj, you access tscale through the HDL instance object. If you do not use use_instance_obj, you can still access tscale through portinfo.

tscaleRead onlyStores the resolution limit (tick) in seconds of the HDL simulator. tscale is a read-only property.
>> hdl_instance_obj.tscale

ans=
	1.0000e-009

    Note   When you use use_instance_obj, you access tscale through the HDL instance object. If you do not use use_instance_obj, you can still access tscale through portinfo.

tnowRead onlyStores the current time. tnow is a read-only property.
hdl_instance_obj.tnext = hld_instance_obj.tnow + fastestrate;
portvaluesRead/WriteStores the current values of and sets new values for the output and input ports for a matlabtb instance. For example:
>> hdl_instance_obj.portvalues

ans =
Read/Write Input ports:
	clk_enable: []
	clk: []
	reset: []
Read Only Output ports:
	sine_out: [22x1 char]
For example, you can set the reset port to 1 by calling hdl_instance_obj.portvalues.reset = '1'.
linkmodeRead onlyStores the status of the callback. The EDA Simulator Link MQ software sets this parameter to 'testbench' if the callback is associated with matlabtb and 'component' if the callback is associated with matlabcp. linkmode is a read-only property.
>> hdl_instance_obj.linkmode

ans=
	testbench

-argument (Beta Feature)

Used to pass user-defined arguments from the matlabtb instantiation on the HDL side to the M-function callbacks. Supported with -use_instance_obj only. See the field listing for argument under the -use_instance_obj property.

Description

The matlabtb command has the following characteristics:

MATLAB test bench functions mimic stimuli passed to entities in the HDL model. You force stimulus from MATLAB or HDL scheduled with matlabtb.

Examples

The following examples demonstrate some ways you might use the matlabtb function.

Using matlabtb with the -socket Argument and Time Parameters

The following command starts the HDL simulator client component of EDA Simulator Link MQ, associates an instance of the entity, myfirfilter, with the MATLAB function myfirfilter, and begins a local TCP/IP socket-based test bench session using TCP/IP port 4449. Based on the specified test bench stimuli, myfirfilter.m executes 5 nanoseconds from the current time, and then repeatedly every 10 nanoseconds:

hdlsim> matlabtb myfirfilter 5 ns -repeat 10 ns -socket 4449

Applying Rising Edge Clocks and State Changes with matlabtb

The following command starts the HDL simulator client component of EDA Simulator Link MQ, and begins a remote TCP/IP socket-based session using remote MATLAB host compb and TCP/IP port 4449. Based on the specified test bench stimuli, myfirfilter.m executes 10 nanoseconds from the current time, each time the signal /top/fclk experiences a rising edge, and each time the signal /top/din changes state.

hdlsim> matlabtb /top/myfirfilter 10 ns –rising /top/fclk –sensitivity /top/din 
      –socket 4449@computer123

Specifying a MATLAB M-Function Name and Sensitizing Signals with matlabtb

The following command starts the HDL simulator client component of the EDA Simulator Link MQ software. The '-mfunc' option specifies the m-function to connect to and the '-socket' option specifies the port number for socket connection mode. '-sensitivity' indicates that the test bench session is sensitized to the signal sine_out.

hdlsim> matlabtb osc_top -sensitivity /osc_top/sine_out
      -socket 4448 -mfunc hosctb
  


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