Switch Case Action Subsystem - Subsystem whose execution is enabled by Switch Case block - Simulink (original) (raw)

Subsystem whose execution is enabled by Switch Case block

Libraries:
Simulink / Ports & Subsystems

Description

The Switch Case Action Subsystem block is a Subsystem block preconfigured as a starting point for creating a subsystem whose execution is controlled by a Switch Case block. The input port to aSwitch Case block selects a case defined using the Case conditions parameter. Depending on input value and case selected, an action signal is sent to execute a Switch Case Action Subsystem block. Execution of the subsystem is controlled by an Action Port block placed inside the subsystem.

Simulink® ignores a priority set on an Switch Case Action Subsystem block. Instead, set the priority on the Switch Case block that initiates execution of the subsystem.

All blocks in a Switch Case Action Subsystem block must run at the same rate as the driving Switch Case block. You can achieve this requirement by setting each block sample time parameter to be either inherited (-1) or the same value as the Switch Case block sample time.

Merge Signals from Switch Case Action Subsystem Blocks

The example model ex_switch_case_block shows how to create one signal from multiple subsystem output signals. For more information, see Select Subsystem Execution.

Model ex_switch_case_block

The Switch Case block selects the execution of one If Action Subsystem block from a set of subsystems. Regardless of which subsystem theSwitch Case block selects, you can create one resulting signal with aMerge block.

Examples

Ports

Input

expand all

Placing an Inport block in a subsystem adds an external input port to the Subsystem block. The port label matches the name of theInport block.

Use Inport blocks to get signals from the local environment.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus

The Action Port block inside a subsystem adds an external input port to the Subsystem block and changes the block to a Switch Case Action Subsystem block.

Note

The Action Port block is not available in the Simulink Library Browser. When using the Switch Case Action Subsystem block, you can access the Action Port block only from within the Switch Case Action Subsystem block.

Dot-dash lines from a Switch Case block to a Switch Case Action Subsystem block represent action signals. An action signal is a control signal connected to theAction port of a Switch Case Action Subsystem block. A message on the action signal initiates execution of the subsystem.

Data Types: action

Output

expand all

Placing an Outport block in a subsystem adds an output port from the Subsystem block. The port label on the subsystem block is the name of the Outport block.

Use Outport blocks to send signals to the local environment.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus

Parameters

expand all

To edit block parameters interactively, use theProperty Inspector. From the Simulink Toolstrip, on the Simulation tab, in thePrepare gallery, select Property Inspector.

Main

Select how to display port labels on the Subsystem block icon.

For port label editing on Subsystem blocks, see Edit Port Labels on Subsystem Blocks.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: ShowPortLabels
Values: 'FromPortIcon' (default) | 'FromPortBlockName' 'SignalName' 'none'

Control user access to the contents of the subsystem.

You do not receive a response if you attempt to view the contents of a subsystem whose Read/Write permissions parameter is set to NoReadOrWrite. For example, when double-clicking such a subsystem, the software does not open the subsystem and does not display any messages.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: Permissions
Values: 'ReadWrite' (default) | 'ReadOnly' 'NoReadOrWrite'

Enter the name of a function to be called if an error occurs while the software executes the subsystem.

The software passes two arguments to the function: the handle of the subsystem and a character vector that specifies the error type. If no function is specified, the software displays a generic error message if executing the subsystem causes an error.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: ErrorFcn
Values: '' (default) | function name in quotes
Data Types: char | string

Select whether to resolve names of workspace variables referenced by this subsystem.

For more information, see Symbol Resolution and Symbol Resolution Process.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: PermitHierarchicalResolution
Values: 'All' (default) | 'ExplicitOnly' 'None'

Select this parameter to display the reinitialize event ports. Clear this parameter to remove the ports.

Dependencies

To enable this parameter, select Treat as atomic unit.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: ShowSubsystemReinitializePorts
Values: 'off' (default) | 'on'

Code Generation

Parameters on the Code Generation tab require a Simulink Coder™ or Embedded Coder® license.

Select the code format to be generated for an atomic (nonvirtual) subsystem.

For more information, see:

The default value depends on the block configuration. For example, the default value for the Subsystem block is Auto. The default value for the CodeReuseSubsystem block isReusable function.

Tips

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWSystemCode
Values: 'Auto' | 'Inline' 'Nonreusable function' 'Reusable function'

Select how the software names the function it generates for the subsystem.

If you have an Embedded Coder license, you can control function names with options on the Configuration Parameter > pane.

For more information, see Generate Subsystem Code as Separate Function and Files (Simulink Coder).

The default value depends on the block configuration. For example, the default value for the Subsystem block is Auto. The default value for the CodeReuseSubsystem block isUse subsystem name.

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWFcnNameOpts
Values: 'Auto' | 'Use subsystem name' 'User specified'

Specify a unique, valid C or C++ function name for subsystem code.

Use this parameter if you want to give the function a specific name instead of allowing the Simulink Coder code generator to assign its own autogenerated name or use the subsystem name. For more information, see Generate Subsystem Code as Separate Function and Files (Simulink Coder).

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWFcnName
Values: '' (default) | function name in quotes
Data Types: char | string

Select how the software names the separate file for the function it generates for the subsystem.

The default value depends on the block configuration. For example, the default value for the Subsystem block is Auto. The default value for the CodeReuseSubsystem block isUse function name.

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWFileNameOpts
Values: 'Auto' | 'Use subsystem name' 'Use function name' 'User specified'

The filename that you specify does not have to be unique. However, avoid giving non-unique names that result in cyclic dependencies. For example,sys_a.h includes sys_b.h,sys_b.h includes sys_c.h, andsys_c.h includes sys_a.h.

For more information, see Generate Subsystem Code as Separate Function and Files (Simulink Coder).

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWFileName
Values: '' (default) | filename in quotes
Data Types: char | string

Select how to use arguments with the generated function.

In some cases, when generating optimized code, the code generator might not generate a function that has arguments.

For more information, see:

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: FunctionInterfaceSpec
Values: 'void_void' (default) | 'Allow arguments (Optimized)' 'Allow arguments (Match graphical interface)'

Generate subsystem function code in which the internal data for an atomic subsystem is separated from its parent model and is owned by the subsystem.

For details on how to generate modular function code for an atomic subsystem, seeGenerate Modular Function Code for Nonvirtual Subsystems (Embedded Coder).

For details on how to apply memory sections to atomic subsystems, see Override Default Memory Placement for Subsystem Functions and Data (Embedded Coder).

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: FunctionWithSeparateData
Values: 'off' (default) | 'on'

Select how the software applies memory sections to the subsystem initialization and termination functions.

Tips

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWMemSecFuncInitTerm
Values: 'Inherit from model' (default) | 'Default' model memory section in quotes

Select how Embedded Coder applies memory sections to the subsystem execution functions.

Tips

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWMemSecFuncExecute
Values: 'Inherit from model' (default) | 'Default' model memory section in quotes

Select how the software applies memory sections to the subsystem constants.

Tips

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWMemSecDataConstants
Values: 'Inherit from model' (default) | 'Default' model memory section in quotes

Select how the software applies memory sections to the subsystem internal data.

Tips

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWMemSecDataInternal
Values: 'Inherit from model' (default) | 'Default' model memory section in quotes

Select how the software applies memory sections to the subsystem parameters.

Tips

Dependencies

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: RTWMemSecDataParameters
Values: 'Inherit from model' (default) | 'Default' model memory section in quotes

Block Characteristics

Data Types Booleana | busa doublea enumerateda fixed pointa halfa integera singlea stringa
Direct Feedthrough no
Multidimensional Signals yesa
Variable-Size Signals yesa
Zero-Crossing Detection no
a Actual data type or capability support depends on block implementation.

Extended Capabilities

expand all

Actual code generation support depends on block implementation.

HDL Coder™ provides additional configuration options that affect HDL implementation and synthesized logic.

HDL Architecture

Architecture Description
Module (default) Generate code for the subsystem and the blocks within the subsystem.
BlackBox Generate a black box interface. The generated HDL code includes only the input/output port definitions for the subsystem. Therefore, you can use a subsystem in your model to generate an interface to existing, manually written HDL code. The black-box interface generation for subsystems is similar to the Model block interface generation without the clock signals.
No HDL Remove the subsystem from the generated code. You can use the subsystem in simulation, however, treat it as a “no-op” in the HDL code.

HDL Block Properties

General
AdaptivePipelining Automatic pipeline insertion based on the synthesis tool, target frequency, and multiplier word-lengths. The default is inherit. See alsoAdaptivePipelining (HDL Coder).
BalanceDelays Detects introduction of new delays along one path and inserts matching delays on the other paths. The default is inherit. See also BalanceDelays (HDL Coder).
ClockRatePipelining Insert pipeline registers at a faster clock rate instead of the slower data rate. The default is inherit. See also ClockRatePipelining (HDL Coder).
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 is0. For more details, see ConstrainedOutputPipeline (HDL Coder).
DistributedPipelining Pipeline register distribution, or register retiming. The default is inherit. See also DistributedPipelining (HDL Coder).
DSPStyle Synthesis attributes for multiplier mapping. The default is none. See also DSPStyle (HDL Coder).
FlattenHierarchy Remove subsystem hierarchy from generated HDL code. The default is inherit. See also FlattenHierarchy (HDL Coder).
InputPipeline Number of input pipeline stages to insert in the generated code. Distributed pipelining and constrained output pipelining can move these registers. The default is0. For more details, see InputPipeline (HDL Coder).
OutputPipeline Number of output pipeline stages to insert in the generated code. Distributed pipelining and constrained output pipelining can move these registers. The default is0. For more details, see OutputPipeline (HDL Coder).
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.

Restrictions

If the output of the subsystem is a bus then Initial condition of the outport must be 0.

Actual data type support depends on block implementation.

Version History

Introduced before R2006a