matlabcp
Associate MATLAB component function with instantiated HDL design
Description
Note
Enter this command in the HDL simulator, not in MATLAB®.
matlabcp
performs these actions: instance
Starts the HDL simulator client component of the HDL Verifier™ software.
Associates a specified instance of an HDL design created in the HDL simulator with a MATLAB function.
Creates a process that schedules invocations of the specified MATLAB function.
Cancels any pending events scheduled by a previous
matlabcp
command that specified the same instance. For example, if you issue the commandmatlabcp
for instancefoo
,matlabcp
cancels all previously scheduled events initiated bymatlabcp
onfoo
.Issue this command in the HDL simulator.
MATLAB component functions simulate the behavior of modules in an HDL model. A stub module (providing port definitions only) in the HDL model passes its input signals to the MATLAB component function. The MATLAB component processes this data and returns the results to the outputs of the stub module. A MATLAB component typically provides some functionality (such as a filter) that is not yet implemented in the HDL code. For more information about MATLAB component functions, see Create a MATLAB Component Function.
Note
The communication mode that you specify for
matlabcp
must match the communication mode you specified forhdldaemon
when you established the server connection.For socket communications, specify the port number that you selected for
hdldaemon
when you issue a link request with thematlabcp
command in the HDL simulator.
matlabcp
adds time specifications for scheduling the specified MATLAB function.instance
time-specs
matlabcp
specifies one or more additional specifications as pairs consisting of a valid specification
name and its value. For example, instance
___ pair1 ... pairN
-mfunc vlogmatlabc
specifies for the
MATLAB function vlogmatlabc
to be associated with the specified
HDL module. You can specify these pairs with or without
time-specs
.
Examples
Use matlabcp
with -mfunc
Option to Associate HDL Component with MATLAB Function of Different Name
Associate the Verilog® module vlogtestbench_top.u_matlab_component
with the
MATLAB function vlogmatlabc
by using the
-mfunc
option. The -socket
option specifies to use
socket communication on port 4449.
hdlsim>matlabcp vlogtestbench_top.u_matlab_component -mfunc vlogmatlabc -socket 4449
Use matlabcp
with Explicit Times and -cancel
Option
Associate the Verilog module vlogtestbench_top
with the MATLAB function vlogtestbench_top
, specifying explicit times
with the -cancel
option.
hdlsim>matlabcp vlogtestbench_top 1e6 fs 3 2e3 ps -repeat 3 ns -cancel 7ns
Use matlabcp
with Rising and Falling Edges
Associate the Verilog module vlogtestbench_top
with the MATLAB function vlogtestbench_top
, specifying rising and falling
edges.
hldsim> matlabcp vlogtestbench_top 1 2 3 4 5 6 7 -rising outclk3 -falling u_matlab_component/inoutclk
Input Arguments
instance
— Instance of HDL module
character vector | string scalar
Instance of an HDL module that is associated with a MATLAB function, specified as a character vector or string scalar that indicates
an HDL module instance. By default, the matlabcp
command associates
the instance to a MATLAB function that has the same name as the instance. For example, if the
instance is myfirfilter
, matlabcp
associates the
instance with the MATLAB function myfirfilter
The command ignores hierarchy
names. For example, if the instance is top.myfirfilter
, the
matlabcp
command associates only myfirfilter
with the MATLAB function. To associate the specified instance with a MATLAB function that differs from the instance name, use the
-mfunc
specification as in the pair1 ...
pairN
argument.
Note
If you specify an instance of an HDL module that is already associated with a
MATLAB function (via matlabcp
or
matlabtb
) the new association overwrites the existing
one.
Data Types: char
| string
time-specs
— Schedule execution of MATLAB function
space-separated list of one or more time specifications
Space-separated list of one or more time specifications, specified as a space-separated list of one or more time specifications listed in this table.
Time Specification | Description |
---|---|
time_1
time_2 ...
time_n | Specify one or more discrete times at which the HDL simulator calls the specified MATLAB function. The specified times are relative to the current simulation time. If you do not specify a time, the HDL simulator calls the MATLAB function once at the start of the simulation. Each time_i consists of a number indicating the time value and an optional time unit of:
If you do not specify a time unit, the command treats the time value as a value of HDL simulation ticks. Separate each time_i by a space. For example, this code specifies for the MATLAB
function matlabcp vlogmodel_top 10 ns, 10 ms, 10 sec |
-repeat <time> | Specify that the HDL simulator calls the MATLAB function repeatedly based on the specified times. The time values
are relative to the value of tnow at the time the HDL
simulator first calls the MATLAB function. |
-cancel <time> | Specify a single time at which the specified MATLAB function stops executing. The time value is relative to the
value of Note The |
Note
Place time specifications after the matlabcp
instance and
before any additional command arguments; otherwise the time specifications are
ignored.
pair1 ... pairN
— Additional specifications
space-separated list of one or more specification pairs
Additional specifications, specified as a space-separated list of one or more specification pairs. A specification pair consists of a name and value. This table shows valid name and value options for these pairs.
Specification Pairs
Name | Value | Description |
---|---|---|
-socket | Communication mode that matches the communication mode issued with the
hdldaemon command | Specify for HDL Verifier to use TCP/IP sockets to communicate between the HDL simulator
and MATLAB. Shared memory is the default mode of communication and takes
effect if you do not specify For more information on choosing TCP/IP socket ports, see TCP/IP Socket Ports. |
-rising | Comma-separated list of one or more signal names | Specify
Note When specifying signals with the |
-falling | Comma-separated list of one or more signal names | Specify the path names of one or more signals defined as a logic type
( For determining signal transition in:
Note When specifying signals with the |
-sensitivity | Comma-separated list of one or more signal names | Specify the path names of one or more signals. This pair indicates that the application calls the specified MATLAB function whenever any of the specified signals change state. Signals of any type can appear in the sensitivity list and can be positioned at any level in the HDL model hierarchy. Note When specifying signals with the |
-mfunc | MATLAB function name | Specify the name of the MATLAB function that is associated with the HDL module instance you
specify for |
-use_instance_obj | Structure with fields as described in the table in -use_instance_obj Fields | This pair Instructs the function specified with the argument
|
-argument | HDL instance argument | Pass user-defined arguments from the |
-use_instance_obj
Fields
Field | Read or Write Access | Description |
---|---|---|
tnext | Write-only | Schedule a callback during the set time. This field is equivalent to
old hdl_instance_obj.tnext = hdl_instance_obj.tnow + 5e-9 |
userdata | Read or Write | Store state variables of the current matlabcp
instance. You can retrieve the variables the next time the callback of this
instance is scheduled. |
simstatus | Read-only | Store the status of the HDL simulator. The HDL Verifier software sets this field to >> hdl_instance_obj.simstatus ans= Init |
instance | Read-only | Store the full path of the Verilog or VHDL instance associated with the callback.
In the HDL simulator: hdlsim> matlabcp osc_top -mfunc oscfilter use_instance_obj In MATLAB: >> hdl_instance_obj.instance ans= osc_top |
argument | Read-only | Store the argument that is set by the matlabtb osc_top -mfunc oscfilter -use_instance_obj -argument foo -argument option only when
it is used with the -use_instance_obj pair. Otherwise, the
command ignores the argument. argument is a read-only
property.
>> hdl_instance_obj.argument ans= foo |
portinfo | Read-only | Store information about the VHDL and Verilog ports that are associated with this instance.
hdl_instance_obj.portinfo.field1.field2.field3
Note When you use |
tscale | Read-only | Store the resolution limit (tick) in seconds of the HDL simulator.
>> hdl_instance_obj.tscale ans= 1.0000e-009 Note When you use |
tnow | Read-only | Store the current time. hdl_instance_obj.tnext = hld_instance_obj.tnow + fastestrate; |
portvalues | Read or Write | Store the current values of and set new values for the output and
input ports for a >> hdl_instance_obj.portvalues ans = Read Only Input ports: clk_enable: [] clk: [] reset: [] Read/Write Output ports: sine_out: [22x1 char] |
linkmode | Read-only | Store the status of the callback. HDL Verifier sets this field to >> hdl_instance_obj.linkmode ans= component |
Version History
Introduced in R2008a
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)