Main Content

Mask Workspace Variable in Variant Connector Block

This example shows how to use a mask workspace variable as a variant control variable in a Variant Connector block.

The mask workspace variables are the variables that you define in the mask workspace of the given block. These variables have a limited scope. They can be used only by the given block and the underlying layers of that block, so you can use same name for the variables in different masks. If you use a mask workspace variable as a variant control variable of a Variant Connector block, you can use the same variable name to set different active choices for multiple instances of the block in different masks. Using same name reduces the number of variables in the base workspace. When you select a value in the Block Parameters dialog box, the index of that value is mapped to the underlying mask workspace variable during simulation. The variable is then used to evaluate the variant control expression of the Variant Connector block. Depending on the variant control expression that evaluates to true, the blocks in the bounded region formed by the Variant Connector block remain active or inactive.

In this example, the mask workspace variable A is used as a variant control variable in the Variant Connector block. The scope of A is limited to the SS1 subsystem, so only SS1 and its underlying blocks can access A. If you select Resistor in the Block Parameters dialog box of SS1, its index is mapped during simulation to the underlying mask variable A, which then evaluates the variant control expression A==1 in the Variant Connector block to true. The Resistor block R1 becomes active.

Model

Simulation Results

Case 1: If you select Resistor in the SS1 Block Parameters dialog box, A==1 evaluates to true and the R1 block becomes active

Case 2: If you select No resistor in the SS1 Block Parameters dialog box, A==1 evaluates to false and the R1 block becomes inactive