Template subsystem containing Subsystem blocks or Model blocks as Variant choices
Simulink / Ports & Subsystems
HDL Coder / Ports & Subsystems
The Variant Subsystem block can have at most one active choice for simulation. The Variant Subsystem block is a template preconfigured to contain two Subsystem blocks to use as Variant Subsystem choices.
A Variant Subsystem block can contain a mixture of Subsystem and Model blocks as Variant systems. This can also include Inport, Outport, and Connection Port blocks. There are no drawn connections inside the Variant Subsystem blocks.
A Variant Subsystem block with Model blocks as choices, is called Variant Model block.
Each Variant system is associated with a Variant control that is created in the global
workspace. The Variant control determines which Variant system is active. The Variant
control can be a condition expression, a Simulink.Variant
object
specifying a condition expression, or a default Variant. The Variant control that
evaluates to true
determines the active Variant.
When you select the Specify output when source is unconnected option in the Outport block that is in a Variant Subsystem block, you can specify a non-ground value as its output.
Note
You must specify the correct data type in the Signal Attributes section of the Outport block dialog box.
During simulation, Simulink® disables the inactive ports in a Variant Subsystem block.
In_1
— Input port corresponding to root-level Inport blocks contained in Variant
SubsystemEach Subsystem or Model block contained within a Variant Subsystem represents one Variant system. If the inport names on a Variant system are a subset of the inport names used by the Variant Subsystem container block, then Variant system blocks can have different numbers of inports than the Variant Subsystem block has.
Out_1
— Output port corresponding to root-level Outport blocks contained in Variant
SubsystemEach Subsystem or Model block contained within a Variant Subsystem represents one Variant system. If the outport names on a Variant system are a subset of the outport names used by the Variant Subsystem block, then Variant system blocks can have different numbers of outports than the Variant Subsystem block has.
Variant control mode
— Name of Variant control modeexpression
(default) | label
| sim codegen switching
expression
— To choose the active Variant
based on the evaluation of the Variant conditions, use
expression
mode. The Variant control
variables used in the Variant condition must be created in a global
workspace or in a data dictionary.
Label
— To choose the active Variant based
on the name of the Variant you specify in the Label mode
active choice parameter, use
label
mode. In label
mode, the Variant control is a string and does not need to be created in
any workspaces.
When you select label
mode, the Variant
badge indicates the change.
Note
When you promote the Label mode active choice parameter to a mask, Variant control mode is disabled.
If the block is in
expression
mode while
promoting the Label mode active
choice parameter to a mask, you can
change the Variant control mode to
label
by changing the
promoted Label mode active choice
parameter from the Mask dialog box.
If the block is in label
mode while promoting the Label mode active
choice parameter to a mask, you cannot
change the Variant control mode to
expression
mode.
For information about promoting parameters to masks, see Promote Parameter to Mask.
sim codegen switching
— To automatically
switch between the Variants for simulation and code generation
workflows, use sim codegen switching
mode.
When you simulate (Normal , Accelerator, Rapid Accelerator) a model,
then Simulink automatically chooses the sim
branch as
the active choice. Similarly, when you do a Software-in-the-loop (SIL),
Processor-In-Loop (PIL) simulation or generate code or use external
mode, Simulink automatically chooses the codegen
branch.
When you set this parameter to different values, the Variant badge changes as shown in Variant Badges.
The Variant activation time parameter is available
only when you set the Variant control mode parameter to
expression
or sim codegen
switching
.
Variant activation time
— Determine when Simulink chooses active variant choiceupdate diagram
(default) | update diagram analyze all choices
| code compile
This parameter determines if Simulink sets the active choice of a Variant Subsystem block during update diagram or code compile. This parameter also determines which variability to include in the generated code for ERT targets. If you choose to include all the Variant choices, the choices are enclosed within C preprocessor conditional statements (#if and #endif) in the generated code.
When you set this parameter to different values, the variant badge changes as shown in Variant Badges.
You can set the Variant activation time parameter as:
update diagram
— Simulink sets the active choice during update diagram before
the propagation of signal attributes. Inactive choices are removed
prior to propagation of signal attributes, so the generated code
contains only active choice.
update diagram analyze all choices
—
Simulink sets the active choice during update diagram after the
propagation of signal attributes. Signal attributes are propagated
to both active and inactive choices. All choices are analyzed to
ensure consistency of all variant branches between the results of
simulation and code generation. Inactive choices are removed at the
end of update diagram before model start occurs. The generated code
contains only active choices. This workflow remains the same for
simulation and code generation.
code compile
— For simulation, the
workflow is same as the update diagram analyze all
choices
. However, the inactive choices are not
removed during code generation. The generated code contains active
and inactive choices, and the choices are enclosed in C preprocessor
conditional statements, #if
and
#endif
.
This figure shows the Variant activation time for the different values you specify in this parameter.
For more information, see Represent Variant Source and Sink Blocks in Generated Code (Embedded Coder).
When you set the Variant control mode to
expression
, this parameter can be
set to update diagram
,
update diagram analyze all
choices
, or code
compile
.
When you set the Variant control mode to
sim codegen switching
, this
parameter can be set to either update
diagram
or update diagram analyze
all choices
. The code
compile
option becomes unavailable.
Block Parameter:
VariantActivationTime
|
Type: character vector |
Values:
update diagram | update diagram
analyze all choices |code
compile
|
Default:
update diagram
|
Variant choices (table of variant systems)
— Table of variant choices, variant controls, and conditionsThe table has a row for each Variant system contained in the Variant Subsystem. If there are no Variant systems, the table is empty.
You can use buttons to the left of the Variant choices table to modify the elements in the table.
To... | Click... |
---|---|
Create and add a new subsystem choice: Place a new Subsystem Variant choice in the table and create a Subsystem block in the Variant Subsystem block diagram. | ![]() |
Create and add a new model variant choice: Place a new Model Variant choice in the table and create a Model block in the Variant Subsystem block. | ![]() |
Create/Edit selected variant object:
Create a Simulink.Variant object in the
global workspace and open the
Simulink.Variant object parameter dialog
box to specify the Variant
Condition. | ![]() |
Open selected variant choice block: Open the Subsystem block diagram for the selected row in the Variant choices table. | ![]() |
Refresh dialog information from Variant Subsystem contents: Update the Variant choices table according to the Variant system and values of the Variant control in the global workspace. | ![]() |
Name (read-only)
— Variant system name''
(default) | name of Subsystem or Model block contained in the Variant SubsystemThis read-only field is based on the Variant system name. To add a Subsystem
Variant choice, click . To add a Model Variant choice, click
.
Variant control expression
— Variant control in global workspaceChoice_<index>
(default) | boolean condition expression | a Simulink.Variant object representing a boolean condition expression | a Simulink.Parameter object (required for code generation) | enumTo enter a Variant name, double-click a Variant control cell in a new row and type in the Variant control expression.
To enter non-numeric Variant control values, use enumerated data. For information about using enumerated data, see Use Enumerated Data in Simulink Models
Structure field: Represented by the
read-only variant.Name field in the
Variant parameter structure |
Type: character vector |
Value: Variant control that is associated with the Variant choice |
Default:
'variant' |
Condition (read-only)
— Condition for Variant controls''
(default)This read-only field is based on the condition for the associated Variant
control in the global workspace. Create or change a Variant condition in the
Simulink.Variant
parameter dialog box or in the global
workspace.
Label mode active choice
— Name of Active choice if Label mode is selectedChoice_1
(default) | on
When you select the Variant control mode to
Label
, the Label mode active
choice option is available. You can select an active Variant
choice from Label mode active choice options. You can also
right-click the badge on the Variant Subsystem block and select
Label Mode Active Choice.
For Label mode active choice option, the Variant control
need not be a Boolean condition expression or a
Simulink.Variant
object. Variant controls that start with
a %
symbol are ignored.
Note
Label mode active choice option is not available in
Expression
mode.
To enable this parameter, select Label
option
from Variant control mode parameter.
Parameter:
LabelModeActivechoice
|
Type: character vector |
Value: if no Label mode active choice is specified, the value is empty. If Label mode active choice is specified, the value is the name of the Label mode active choice. |
Default:
'' |
Allow zero active variant controls
— Simulate model without using active Variantoff
(default) | on
To simulate a model (containing a Variant system) without an active Variant choice, select the Allow zero active variant controls option. When you select this option and if there is no active Variant choice, Simulink disables all the blocks connected to the input and output stream of Variant Subsystem block. The disabled blocks are ignored from update diagram or simulation.
If you do not select this option, Simulink generates an error when there is no active Variant choice.
The (default) option of Variant is not selected
Expression
option from
Variant control mode is selected.
Parameter:
AllowZeroVariantControls
|
Type: character vector |
Value:
'off' | 'on' |
Default:
'off' |
Propagate conditions outside of variant subsystem
— Propagate Variant conditions outside of Variant Subsystem blockoff
(default) | on
When you select this option, Simulink propagates the Variant conditions outside of the Variant Subsystem block to determine which components of the model are active during simulation.
When you select this option, the Variant badge indicates the change.
Parameter:
PropagateVariantConditions
|
Type: character vector |
Value:
'off' | 'on' |
Default:
'off' |
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
[a] Actual data type or capability support depends on block implementation. |
Actual data type or capability support depends on block implementation.
HDL Coder™ provides additional configuration options that affect HDL implementation and synthesized logic. Actual data type or capability support depends on block implementation.
Architecture | Description |
---|---|
Module (default) | Generate code for the subsystem and the blocks within the subsystem. HDL Coder generates code for only the active variant. |
BlackBox | Generate a black-box interface. That is, the generated HDL code includes only the input/output port definitions for the subsystem. In this way, you can use a subsystem in your model to generate an interface to existing manually written HDL code. The black-box interface generated for subsystems is similar to the interface generated for Model blocks, but without generation of clock signals. |
| Remove the subsystem from the generated code. You can use the subsystem in simulation but treat it as a “no-op” in the HDL code. |
For the BlackBox
architecture, you
can customize port names and set attributes of the external component
interface. See Customize Black Box or HDL Cosimulation Interface (HDL Coder).
General | |
---|---|
AdaptivePipelining | Automatic pipeline insertion based on the synthesis tool, target frequency, and
multiplier word-lengths. The default is |
BalanceDelays | Detects introduction of new delays along one path and inserts
matching delays on the other paths. The default is |
ClockRatePipelining | Insert pipeline registers at a faster clock rate instead of the slower data rate. The
default is |
ConstrainedOutputPipeline | Number of registers to place at
the outputs by moving existing delays within your design. Distributed
pipelining does not redistribute these registers. The default is
|
DistributedPipelining | Pipeline register distribution, or register retiming. The default
is |
DSPStyle | Synthesis attributes for multiplier mapping. The default is |
FlattenHierarchy | Remove subsystem hierarchy from generated HDL code. The default
is |
InputPipeline | Number of input pipeline stages
to insert in the generated code. Distributed pipelining and constrained
output pipelining can move these registers. The default is
|
OutputPipeline | Number of output pipeline stages
to insert in the generated code. Distributed pipelining and constrained
output pipelining can move these registers. The default is
|
SharingFactor | Number of functionally equivalent resources to map to a single shared resource. The default is 0. See also Resource Sharing (HDL Coder). |
StreamingFactor | Number of parallel data paths, or vectors, that are time multiplexed to transform into serial, scalar data paths. The default is 0, which implements fully parallel data paths. See also Streaming (HDL Coder). |
Target Specification
This block cannot be the DUT, so the block property settings in the Target Specification tab are ignored.
The DUT cannot be a Variant Subsystem.
Actual data type or capability support depends on block implementation.