Variable Integer Delay — Control Systems/Discrete
Control_Systems/Discrete/Variable_Integer_Delay · 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.
Variable Integer Delay
Control Systems / Discrete
Delays its input by a whole number of samples that can change while the run is in progress:
y[k] = u[k − d[k]]
The delay arrives on its own port as a count of samples, is rounded to the nearest whole number and clamped to Maximum Delay (samples). A delay of zero is direct feedthrough, and a delay reaching back past the start of the run reads the configured Initial Condition.
Ports
- u – the delayed signal, of any size [m,n]. This is what comes out delayed.
- d – the delay in samples, a scalar [1,1]. It applies to the whole signal, not per entry. Negative values are clamped to zero – nothing arrives before it was sent.
- Output – the delayed signal, the SAME size [m,n] as u.
Parameters
- Maximum Delay (samples) – the depth of the ring buffer, and so the longest delay the block can represent. Defaults to 100, as Simulink's upper limit does. A larger requested delay is clamped rather than growing the buffer, because a delay line that reallocates mid-run is a latency spike on a real target.
- Initial Condition – a scalar, what the block emits while the delay still reaches back past the start of the run. Defaults to 0. The whole buffer is pre-filled with it.
- Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period. It is the spacing of the line, so it is part of the arithmetic and not merely a schedule.
Code export
All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. Each carries the ring buffer as its state, pre-filled with the initial condition, and indexes it with the rounded delay exactly as the simulation does. Nothing about the delay is baked in – it is read from its port every tick.
The three HDL targets derive the read address in hardware with the
generated fixed-point package's fx_to_int. Because the delay arrives
already as a COUNT rather than as a time, there is no 1/dt scaling
and so none of the half-sample rounding ambiguity the seconds-based delay blocks
carry – this block is the one to reach for when an exact delay matters on
hardware. A zero delay is special-cased to the input rather than read back from
the buffer: the write is registered, so on that tick the addressed slot still
holds its previous contents and reading it would return the value from a whole lap
ago.
Simulink bridge
Import and export, mapped to simulink/Discrete/Variable Integer Delay.
"Maximum Delay (samples)" to DelayLengthUpperLimit, "Initial
Condition" to InitialCondition, and "Sampling Time (s)" to
SampleTime as on every block. The Simulink block is the general Delay
block configured to take its length from a port, so
DelayLengthSource is always emitted as Input port and
InitialConditionSource as Dialog – those are what
make it this block rather than one of its siblings, and there is no choice to
offer behind either.
It also imports Control System Toolbox's cstblocks/Linear Parameter
Varying/Discrete Varying Delay, which computes exactly the same thing
under different parameter names. That was measured against R2026a rather than
assumed: its Td is in samples, rounded half-up, clamped to
[0, TdMax], with u0 held until the buffer fills and a
delay of zero passing straight through – term for term what this block
does. The importer folds the path and translates
TdMax → "Maximum Delay (samples)",
u0 → "Initial Condition" and Ts → "Sampling
Time (s)". Its TdFixed and PreventDirectFeedthrough have
no counterpart here and are reported as unmapped: the first pins the delay to a
constant, which a Constant on the delay port does instead, and the second forces a
minimum of one sample, which this block cannot express. Export always emits the
Discrete/Variable Integer Delay path, so a model imported from the Linear
Parameter Varying palette comes back as its equivalent rather than as itself.
Notes
- Stateful: maximum delay + 1 past values of the signal port.
- Discrete by nature – the line advances one slot per sample.
- Compare with the seconds-based delays. Variable Time Delay and Entity Transport Delay take a transit time in seconds and divide by the sampling period; this block takes the count directly. Use this one when you are counting samples and that one when you are measuring time.
- Deliberately carries no state space. A pure delay is the transcendental factor e^(−sd), which no finite A/B/C/D expresses – and a time-varying one is not even time-invariant.
Code facts#
| Fact | Value |
|---|---|
| registered type | Control_Systems/Discrete/Variable_Integer_Delay |
| family | Control_Systems/Discrete |
| solver environment class | ICoreBlock_0_Control_Systems_1_Discrete_2_Variable_Integer_Delay |
| source | src/ICoreSDK/ICoreBlockLibrary/Blocks/Control_Systems/Discrete/Variable_Integer_Delay/ICoreBlock_0_Control_Systems_1_Discrete_2_Variable_Integer_Delay.cpp |
| header | src/ICoreSDK/ICoreBlockLibrary/Blocks/Control_Systems/Discrete/Variable_Integer_Delay/ICoreBlock_0_Control_Systems_1_Discrete_2_Variable_Integer_Delay.h |
| default size on canvas | 110 × 80 px |
| ports at insert | 2 in, 1 out |
| code generators implemented | Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text |
Ports#
| # | Direction | Signal type | Description label |
|---|---|---|---|
| 1 | in | ICoreDouble | u |
| 2 | in | ICoreDouble | d |
| 3 | out | ICoreDouble | — |
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 variable | Default | Simulink parameter |
|---|---|---|
Maximum Delay (samples) | 100 | DelayLengthUpperLimit |
Initial Condition | 0 | InitialCondition |
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 | simulink/Discrete/Variable Integer Delay |
| port-count rule | PortsParam::None |
SampleTime parameter | yes |
| always set | DelayLengthSource = Input port, InitialConditionSource = Dialog |
| ICore config | Simulink parameter | Value translation |
|---|---|---|
Maximum Delay (samples) | DelayLengthUpperLimit | passes through |
Initial Condition | InitialCondition | passes through |
Caveat (shown to the user): the delay arrives on a port as a whole number of samples, so no time-to-samples rounding is involved in either direction
Catalog contract: src/ICoreSDK/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h
Description vs code#
The lists agree. check_block_descriptions.py finds no disagreement between the description's Ports, Parameters, Code export and Simulink bridge lists and the code's.
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).
Variable Integer Delay — y[k] = u[k - d[k]], with the delay arriving on a port in SAMPLES A ring buffer of maxDelay+1 past values, pre-filled with the initial condition so a delay reaching back past the start of the run reads that rather than a sample that was never taken.
buffer[head] = u[k] k_d = clamp(round(d), 0, maxDelay) y = buffer[(head - k_d + N) mod N] (N = maxDelay + 1) head = (head + 1) mod N
d = 0 is direct feedthrough, which is what a zero delay should be. Verified against Simulink R2026a with maxDelay 5, ic -1, u = 1..10 and d = 0 1 2 3 2 1 0 4 4 4: 1 1 1 1 3 5 7 4 5 6 == u[k - d[k]] exactly.
THE DIFFERENCE FROM Entity Transport Delay / Variable Time Delay is the UNIT: those take a transit time in SECONDS and divide by the sampling period, this one takes a whole number of SAMPLES directly. There is no 1/dt scaling anywhere here, which also means no rounding ambiguity near a half-sample boundary -- a real advantage on the fixed-point HDL targets, where a delay in seconds can quantize to a neighbouring sample count.
Discrete by nature: the line advances one slot per SAMPLE.
Sample results#
The same rig also ran:
| Stimulus | What it is | Output range |
|---|---|---|
impulse | Impulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair) | 0 … 0 |
ramp | Ramp: slope 1 from t = 0 | 0 … 5.2 |
sine | Sine Wave: amplitude 1, 2 rad/s, no phase, no bias | -1 … 0.9996 |
table | Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample | -2 … 0.5 |
Plotted: step — Step: 0 -> 1 at t = 1 s
Category dynamic · sample time 0.1 · 60 steps · commit ccf005c8 · produced by docsSample --out <folder> --steps 60 · data docs/generated/samples/Control_Systems__Discrete__Variable_Integer_Delay.json · the SVG is generated from those numbers by tools/docs/plot_svg.py, so it is a run and not a drawing (R-D10).