# Documentation

## Variant Source and Variant Sink Blocks

Define variant choice regions in the Variant Source and Sink blocks based on the block connectivity. The variant choice regions are computed by Simulink when you update diagram (Simulation > Update Diagram).

The process of computing the variant choice regions is called `variant condition propagation` . The Variant Source block provides variation on the source of a signal, and the Variant Sink blocks provides variation on the destination (sink) of a signal.

Consider a model containing two Variant Source blocks ( `Variant Source1` , `Variant Source2`) and a Sink block ( `Variant Sink` ).

The variant conditions at the inports and outports of Variant Source and Sink blocks, respectively, determine the activation and deactivation of the blocks connected to them. To view the annotations and the variant conditions, click Display > Blocks > Variant Conditions.

Let's analyze the variant conditions and the block activation state.

• In `Variant Source1`, when `W==1`, the `Sine3` block is active, and when `W==2`, the `Sine4` block is active.

• In `Variant Source2`, when `V==1`, the Sine1 block is active, and when `V==2`, the `Add1` block is active.

• At `Add1` block the condition propagation continues making `Variant Source1` block to be active only when the `V==2`. This further propagates to `Sine3` block and `Sine4` block, making the `Sine3` block active at `V==2 && W==1` and the `Sine4` block active at `V==2 && W==2`, respectively.

• The `Gain3` block is active when either `V==1` or `V==2`, and hence the condition `V==2` | | `V==1`. The variant condition is further propagated to `Scope1` and `Out1`.

• The blocks connected to the outport of `Variant Sink` are active when `W==1` (`Gain5`), or `W==2` (`Sine`, `Subtract`, `Terminator`).

• The `Sum` block illustrates two key concepts in variant condition propagation: Signals are only variant if explicitly marked or when all paths can be proven to be variant. To make the `Sine6`, `Sum`, `Out2` variant, place a Single-Input Single-Output Variant Source before Out2 (or after the `Sine6`). Reading an inactive signal is equivalent to reading ground. When `W ~= 1`, then the bottom input to the `Sum` block is inactive and `Out2 = Sine6 + ground`.

If you select the Analyze all choices during update diagram and generate preprocessor conditionals parameter for the Variant Source and Variant Sink block, the generated code contains the code for the active and the inactive (`#if COND`). If this parameter is not selected, then code is generated only for the active choices.

If you select the Allow zero active variant controls parameter for the Variant Source and Variant Sink block, you can simulate the variant model without an active variant. In such cases, Simulink disables the blocks connected to the input and output stream of Variant Source and Variant Sink. These disabled blocks are ignored from update diagram or simulation.