Generated reference › Variant Source — Control Systems/Signal Routing
kind: generated#block#control-systems-signal-routing

Variant Source — Control Systems/Signal Routing

?

Control_Systems/Signal_Routing/Variant_Source · 2 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

Variant Source

Control Systems / Signal Routing

Passes on one of its inputs, the one whose variant control is true: y = uk. Each input has a control, a condition over the project's variables such as V==1, and the choice is made before the run from the variables' values then. The inputs that are not chosen leave the run, and so does every block that feeds only them.

Ports

  • u1 … uN – the choices, one per variant control. Add or remove inputs from the block's port settings, and keep one control per input. Each may be any size [m,n]: only the chosen one is read, so they need not agree.
  • Output – y, the chosen input unchanged, of its size [m,n].

Parameters

  • Variant Controls – one control per input, in port order, written as Simulink writes them, {'V==1';'V==2'}, or as a plain list, V==1; V==2. A control is a condition that is true or false: V==1, V~=1, V>=1 && V<=2, V==1 || W==2, mod(V,2)==1, or true and false. (default) marks the input taken when no other control is true. A bare name such as V is not a condition and is refused, as Simulink refuses it. The default is {'true';'false'}: the first input.
  • Variant Control Mode – expression evaluates the controls as conditions; label treats each control as a name and takes the input whose name is Label Mode Active Choice; sim codegen switching takes the input whose control is (sim), and each control must be (sim) or (codegen).
  • Label Mode Active Choice – in label mode, the name of the chosen input. Unused in the other modes.
  • Allow Zero Variant Controls – Off: a run with no control true is refused. On: with no control true there is no choice, and the block leaves the run with everything after its output, as Simulink removes it.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period. It does not cross to Simulink, whose block has no rate parameter.

When a run is refused

In Simulink's words: no control true (must have at least one active port), more than one true (must have only one active port), two (default) controls, a bare name, a variable the project does not define, a value that is not true or false, and a number of controls that is not the number of inputs.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. The choice is made before the export, so the generated body is a plain copy of the chosen input and holds no condition; the inputs not chosen, and what fed only them, are not exported. Re-export after changing a variable a control reads. The HDL targets are fully synthesizable.

Simulink bridge

Import and export, mapped to simulink/Signal Routing/Variant Source. Variant Controls crosses as the cell VariantControls, which is what sets Simulink's input count; Variant Control Mode, Label Mode Active Choice and Allow Zero Variant Controls as VariantControlMode, LabelModeActiveChoice and AllowZeroVariantControls. The activation time is written as update diagram, the only one ICore makes; a model with another is reported on import. The rate does not cross.

Notes

  • Algebraic, with no state: the output depends only on the current input.
  • A block that reads this one's output and also something else keeps running when the output is removed, and reads 0 from it, as in Simulink.
  • Controls name variables of the project's variables space; Simulink's Simulink.Variant objects and model workspace are not carried.
  • To choose by a setting rather than a condition, use Signal Routing / Manual Variant Source; to choose on a signal, use Signal Routing / Multiport Switch.

Code facts#

FactValue
registered typeControl_Systems/Signal_Routing/Variant_Source
familyControl_Systems/Signal_Routing
solver environment classICoreBlock_0_Control_Systems_1_Signal_Routing_2_Variant_Source
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Signal_Routing/Variant_Source/ICoreBlock_0_Control_Systems_1_Signal_Routing_2_Variant_Source.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Signal_Routing/Variant_Source/ICoreBlock_0_Control_Systems_1_Signal_Routing_2_Variant_Source.h
default size on canvas80 × 90 px
ports at insert2 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoubleu1
2inICoreDoubleu2
3outICoreDouble—

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

Config variableDefaultSimulink parameter
Variant Controls{'true';'false'}VariantControls
Variant Control Modeexpression%~%label%~%sim codegen switching~~expressionVariantControlMode
Label Mode Active Choice—LabelModeActiveChoice
Allow Zero Variant ControlsOff%~%On~~OffAllowZeroVariantControls

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::Both
Simulink pathsimulink/Signal Routing/Variant Source
port-count rulePortsParam::VariantControlsIn
SampleTime parameterno — the counterpart defines none; the rate stays on the ICore side
always setVariantActivationTime = update diagram
ICore configSimulink parameterValue translation
Variant ControlsVariantControlspasses through
Variant Control ModeVariantControlModeexpression → expression, label → label, sim codegen switching → sim codegen switching
Label Mode Active ChoiceLabelModeActiveChoicepasses through
Allow Zero Variant ControlsAllowZeroVariantControlsOff → off, On → on

Caveat (shown to the user): the controls cross as the cell VariantControls, which sets Simulink's input count; the activation time is update diagram, the only one ICore makes; the block has NO SampleTime parameter, so a rate set here does not cross

Catalog contract: src/ICoreBlocks/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The checker has a blind spot here — it could not resolve something (a grouped port bullet, a computed config name), which is reported and never counted as a pass. A reader has to settle it:

  • B0 Ports lists 2 entries for 3 ports (2 in, 1 out), and the 2 they cover does not reconcile — grouped, or one undocumented? a reader must say
  • B0 no sample under docs/generated/samples/ — nothing to cross-check (P8.1)

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

Variant Source -- one of N inputs, the one whose variant control is true y = u<k>, where control k is the true one. Measured on R2026a (FEATURES_TO_ADD.md §F.BF3): VariantControls is a cell, one condition per input, default {'true';'false'}, and the input count FOLLOWS it (a 3-element cell gives Ports [3 1]); VariantControlMode expression | label | sim codegen switching; AllowZeroVariantControls off; activation update diagram; no SampleTime. The choice, the pruning, the refusals and the ten generators are ICoreVariantBlockBase's.

Sample results#

No sample run is committed for this block. Samples come from the headless harness (DOCS_PLAN.md P8.1) into docs/generated/samples/; until one exists this block's behaviour is witnessed by the parity and export-verification suites, not by a plot here.