For Each — Private/Subsystem Components
Private/Subsystem_Components/For_Each · 0 input / 0 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.
For Each
Control Systems / Ports And Subsystems
Makes the subsystem it sits in a For Each subsystem: each step, the subsystem runs once per slice of its partitioned inputs, each slice with its own copy of every state, and the outputs are the slices concatenated. Simulink’s For Each block (BlockType=ForEach). To make one, place this block in a subsystem, or insert the ready-made For Each Subsystem from the library’s Subsystem Templates.
Ports
- None. What it partitions is the subsystem’s own inputs, one entry per input in each list below, or one entry for all of them.
Parameters
- Input partition – on or off per input, comma-separated. At least one input must be partitioned; an input that is off reaches every slice whole.
- Input partition dimension – the dimension each input is sliced along, 1 or 2. A 1×n row partitioned along dimension 1 is a vector and is sliced along its length.
- Input partition width – the width of one slice.
- Input partition offset – the step between slices beyond the width; negative overlaps them. A length L gives (L + offset) / (width + offset) slices, and must divide evenly.
- Output concatenation dimension – per output, the dimension the slices are joined on. When every partitioned input is a row vector, row slices joined along dimension 1 make a longer row.
- Show iteration index – Off (default). On is refused: the block has no output port yet.
- Iteration index data type – int32 (default).
- Specified number of iterations – -1 (default): as many as the partition gives. Any other value must equal that number.
Notes
- Every partitioned input must give the same number of slices, and a size that does not divide into slices is refused before a run, in Simulink’s words.
- Each slice keeps its own copy of every state inside, a continuous one included, and its own clock. A block whose state cannot be copied per slice is refused before a run, by name, rather than letting the slices share one.
- A subsystem is iterated by one iterator block at most, and the block has to sit inside a subsystem, never at the top level.
Code export
The subsystem exports as a loop over its slices, each slice with its own copy of every state inside, swapped in for its pass: Python, MATLAB, Java, Rust, C, C++ and PLC Structured Text. VHDL, Verilog and SystemVerilog would need one copy of the hardware per slice and refuse it by name. Also refused by name: a For Each inside a For Each, and a sliced input or joined output that is not a double.
Simulink bridge
Import and export, mapped to built-in/ForEach; the
library’s For Each Subsystem imports with what R2026a puts in it (an In1,
the For Each, an Out1, In1 wired to Out1, atomic). Input partition,
Input partition dimension, Input partition width, Input
partition offset and Output concatenation dimension cross as
Simulink’s cells (InputPartition,
InputPartitionDimension, InputPartitionWidth,
InputPartitionOffset, OutputConcatenationDimension),
one entry per Inport or Outport; Show iteration index to
ShowIterationIndex, Iteration index data type to
IterationIndexDataType and Specified number of iterations
to SpecifiedNumIters. Mask-parameter partitioning does not cross:
no ICore block has a mask.
Code facts#
| Fact | Value |
|---|---|
| registered type | Private/Subsystem_Components/For_Each |
| family | Private/Subsystem_Components |
| solver environment class | ICoreBlock_0_Private_1_Subsystem_Components_2_For_Each |
| source | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Private/Subsystem_Components/For_Each/ICoreBlock_0_Private_1_Subsystem_Components_2_For_Each.cpp |
| header | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Private/Subsystem_Components/For_Each/ICoreBlock_0_Private_1_Subsystem_Components_2_For_Each.h |
| default size on canvas | 90 × 60 px |
| ports at insert | 0 in, 0 out |
| code generators implemented | Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text |
Ports#
The constructor creates no port explicitly — the port list comes from registerInitialPorts (0 in, 0 out) or from the block's configuration.
Configuration variables#
| Config variable | Default | Simulink parameter |
|---|---|---|
Input partition | on | InputPartition |
Input partition dimension | 1 | InputPartitionDimension |
Input partition width | 1 | InputPartitionWidth |
Input partition offset | 0 | InputPartitionOffset |
Output concatenation dimension | 1 | OutputConcatenationDimension |
Show iteration index | Off%~%On~~Off | ShowIterationIndex |
Iteration index data type | int32%~%double~~int32 | IterationIndexDataType |
Specified number of iterations | -1 | SpecifiedNumIters |
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.
Simulink bridge#
| support | Support::Both |
| Simulink path | built-in/ForEach |
| port-count rule | PortsParam::IteratorPorts |
SampleTime parameter | no — the counterpart defines none; the rate stays on the ICore side |
| ICore config | Simulink parameter | Value translation |
|---|---|---|
Input partition | InputPartition | passes through |
Input partition dimension | InputPartitionDimension | passes through |
Input partition width | InputPartitionWidth | passes through |
Input partition offset | InputPartitionOffset | passes through |
Output concatenation dimension | OutputConcatenationDimension | passes through |
Show iteration index | ShowIterationIndex | Off → off, On → on |
Iteration index data type | IterationIndexDataType | int32 → int32, double → double |
Specified number of iterations | SpecifiedNumIters | passes through |
Caveat (shown to the user): Simulink's For Each (built-in/ForEach) inside the subsystem it iterates, and the library's For Each Subsystem made with what R2026a puts in it (FEATURES_TO_ADD.md BF9.6). The partition and join lists cross as Simulink's cells, one entry per Inport or Outport, set once every port exists. Mask-parameter partitioning does not cross: no ICore block has a mask.
Catalog contract: src/ICoreBlocks/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h
Description vs code#
tools/docs/check_block_descriptions.py(P7.1) could not be run when this page was generated, so no verdict is shown. Run it yourself; a page cannot claim an agreement it did not measure.
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.
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.