xlAddTerms
is similar to the addterms
command in
Simulink, in that it adds blocks to terminate or drive
unconnected ports in a model. With xlAddTerms
, output ports are
terminated with a Simulink terminator block, and input ports are
correctly driven with either a Simulink or HDL constant block.
Additionally HDL gateway blocks can also be conditionally added.
The optionStruct
argument can be configured to instruct
xlAddTerms to set a block's property (e.g. set a constant block's value to 5) or to
use different source or terminator blocks.
Syntax
xlAddTerms(arg1,optionStruct)
Description
In the following description, 'source block' refers to the block that is used to drive an unconnected port. And 'term block' refers to the block that is used to terminate an unconnected port.
xlAddTerms(arg1,optionStruct)
xlAddTerms
takes either 1 or 2
arguments. The second argument, optionStruct
argument is optional. The first argument can be the name of a system, or a block
list.
arg1 | Description |
---|---|
gcs
|
A string-handle of the current system |
'top/test1'
|
A string-handle of a system called test1. In this
case, xlAddTerms is passed a
handle to a system. This will run xlAddTerms on all the blocks under test1, including
all children blocks of Subsystems. |
{'top/test1'}
|
A block list of string handles. In this case,
xlAddTerms is passed a handle
to a block. This will run xlAddTerms only on the block called test1, and will
not process child blocks. |
{'t/b1';'t/b2';'t/b3'}
|
A block list of string handles. |
[1;2;3]
|
A block list of numeric handles. |
The optionStruct argument is optional, but when included, should be a MATLAB structure. The following table describes the possible values in the structure. The structure field names (as is true with all MATLAB structure field names) are case sensitive.
optionStruct | Description |
---|---|
Source
|
E.g. when a Simulink constant block is used as a Source Block, setting the block's value to 10 can be done with:
And when a HDL Constant block is used as a Source Block, setting the constant block to have a value of 10 and of type UFIX_32_0 can be done with:
|
SourceWith
|
The
|
TermWith
|
The
A string specifying the port number used to connect. E.g. '1' or '3' Specifying '1' instructs |
UseGatewayIns
|
Instructs xlAddTerms to insert HDL gateway ins when required.
The existence of the field is used to denote insertion of gateway
ins. This field must not be present if gateway ins are not to be
used. |
GatewayIn
|
If gateway ins are inserted, their parameters can be set using this field, in a similar way as for Source and Term. For example:
will set the gateway in to output a ufix_32_0. |
UseGatewayOuts
|
Instructs xlAddTerms to insert HDL gateway outs when required.
The existence of the field is used to denote insertion of gateway
outs. This field must not be present if gateway outs are not to be
used. |
GatewayOut
|
If gateway outs are inserted, their parameters can be set using this field, in a similar way as for Source and Term. For example:
This sets the gateway out to take an input of ufix_32_0. |
RecurseSubsystems
|
Instructs xlAddTerm to recursively run xlAddTerm under all child Subsystems. Expects a scalar
number, 1 or 0. |
Examples
Example 1: Runs xlAddTerms
on the current system, with the
default parameters: constant source blocks are used, and gateways are not added.
Subsystems are recursively terminated.
xlAddTerms(gcs);
Example 2: Runs xlAddTerms
on all the blocks in
the Subsystem tt./mySubsystem.
xlAddTerms(find_system('tt/mySubsystem','SearchDepth',1));
Example 3: Runs xlAddTerms
on the current
system, setting the source block's constant value to 1, using gateway outs and
changing the term block to use a Simulink
display block.
s.Source.const = '10';
s.UseGatewayOuts = 1;
s.TermWith.Block = 'built-in/Display';
s.TermWith.Port = '1';
s.RecurseSubsystem = 1;
xlAddTerms(gcs,s);
Remarks
Note that field names are case sensitive. When using the fields
'Source'
, 'GatewayIn'
and
'GatewayOut'
, users have to ensure that the parameter names to
be set are valid.