Lookup Table 2D — Control Systems/Lookup Tables
Control_Systems/Lookup_Tables/Lookup_Table_2D · 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.
2-D Lookup Table
Control Systems / Lookup Tables
Maps a pair of inputs through a rectangular table: y = table(u1, u2). The two axes are searched independently and the surrounding table entries are blended – which for the Linear rule is ordinary bilinear interpolation.
u1 runs down the rows and u2 across the columns, so a table written
[1 -2 0.5; 3 0.25 -1; -0.5 2 1.5] is read the way it looks on the page.
That is Simulink's dimension order too.
Ports
- Input u1 – the row coordinate, a scalar.
- Input u2 – the column coordinate, a scalar.
- Output – the table's value y, a scalar.
Unlike the 1-D table this block does not run elementwise: a pair of matrix inputs has no single sensible reading, so all three ports are scalar.
Parameters
- Row Breakpoints – the first axis, indexing the table's rows. A row or column vector; both spell the same list. At least two strictly increasing values.
- Column Breakpoints – the second axis, indexing the columns, under the same rules.
- Table Data – the table itself, a matrix with one row per row breakpoint and one column per column breakpoint. A table whose shape disagrees with the two axes is reported and the run stopped.
- Interpolation Method – what the table says between the points.
- Linear point-slope – bilinear across the surrounding four entries.
- Flat – the entry at the breakpoint at or below each input, on both axes independently.
- Nearest – the entry at the nearer breakpoint on each axis. An exact tie takes the higher one.
- Extrapolation Method – what the table says outside its own range.
- Linear – continue the surface off the edge, along the slopes of the edge cell. Off a corner both axes extrapolate at once.
- Clip – hold each input inside its own axis, so an input off an edge reads the edge and one off a corner reads the corner entry.
- Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.
Code export
All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. The table and both rules are baked into the arithmetic at export time rather than exposed as tunable parameters, and they have to be: the table's shape decides the size of the generated code, which is an outer chain of comparisons picking the row, an inner one picking the column, and one expression per cell.
The three HDL targets are not simulation-only. Each cell's four coefficients fold both axes' widths in at export time, so a cell is three multiplies and three adds and no divider is emitted. The caveat is range – a signal is carried in Q16.16 there, so a breakpoint or table value outside ±32767 cannot be represented, and the bilinear cross term is the one place a large table value meets a large coordinate.
Simulink bridge
Import and export, mapped to simulink/Lookup Tables/2-D Lookup Table.
"Row Breakpoints" to BreakpointsForDimension1, "Column Breakpoints" to
BreakpointsForDimension2, "Table Data" to Table,
"Interpolation Method" to InterpMethod and "Extrapolation Method" to
ExtrapMethod – those values are Simulink's own strings, so the
mappings are 1:1 and lossless both ways. The block always writes
NumberOfTableDimensions = 2, which is what having two input ports
means. "Sampling Time (s)" goes to SampleTime, as on every block.
Simulink's three further interpolation methods – Linear Lagrange, Cubic spline and Akima spline – have no counterpart here, and a model importing one is reported rather than silently mapped onto a bilinear blend.
Notes
- Algebraic, with no state.
- Not linear, and so deliberately carries no state space – model reduction reports it as unmergeable.
- See 1-D Lookup Table for one axis and n-D Lookup Table for more than two.
Code facts#
| Fact | Value |
|---|---|
| registered type | Control_Systems/Lookup_Tables/Lookup_Table_2D |
| family | Control_Systems/Lookup_Tables |
| solver environment class | ICoreBlock_0_Control_Systems_1_Lookup_Tables_2_Lookup_Table_2D |
| source | src/ICoreSDK/ICoreBlockLibrary/Blocks/Control_Systems/Lookup_Tables/Lookup_Table_2D/ICoreBlock_0_Control_Systems_1_Lookup_Tables_2_Lookup_Table_2D.cpp |
| header | src/ICoreSDK/ICoreBlockLibrary/Blocks/Control_Systems/Lookup_Tables/Lookup_Table_2D/ICoreBlock_0_Control_Systems_1_Lookup_Tables_2_Lookup_Table_2D.h |
| default size on canvas | 85 × 75 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 | u1 |
| 2 | in | ICoreDouble | u2 |
| 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 |
|---|---|---|
Row Breakpoints | [1 2 3] | BreakpointsForDimension1 |
Column Breakpoints | [1 2 3] | BreakpointsForDimension2 |
Table Data | [4 5 6; 16 19 20; 10 18 23] | Table |
Interpolation Method | LUT::interpComboSpec() | InterpMethod |
Extrapolation Method | LUT::extrapComboSpec() | ExtrapMethod |
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/Lookup Tables/2-D Lookup Table |
| port-count rule | PortsParam::None |
SampleTime parameter | yes |
| always set | NumberOfTableDimensions = 2 |
| ICore config | Simulink parameter | Value translation |
|---|---|---|
Row Breakpoints | BreakpointsForDimension1 | passes through |
Column Breakpoints | BreakpointsForDimension2 | passes through |
Table Data | Table | passes through |
Interpolation Method | InterpMethod | Flat → Flat, Nearest → Nearest, Linear point-slope → Linear point-slope |
Extrapolation Method | ExtrapMethod | Clip → Clip, Linear → Linear |
Caveat (shown to the user): u1 indexes the table's ROWS and u2 its COLUMNS, matching Simulink's dimension order - getting that backwards is a silent transpose that only shows on a non-symmetric table. Simulink's three further interpolation methods (Linear Lagrange, Cubic spline, Akima spline) have no counterpart here. Flat and Nearest ignore the extrapolation method on both sides
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).
2-D Lookup Table block — y = table(u1, u2) Two axes searched independently, then the surrounding table entries blended. Algebraic, stateless, scalar in and out. No state space (see header).
THE EMITTED CODE IS A NESTED CHAIN: an outer chain picking the row, an inner one picking the column, and one expression per cell. That is (n1-1)*(n2-1) leaf expressions, so the table's SHAPE decides the size of the generated code - the same trade every table in this family makes, and the reason the table cannot be a tunable parameter.
CLIPPING IS DONE ON THE INPUTS. Holding each input inside its own axis before the cell lookup reproduces Simulink's Clip behaviour at the edges AND the corners exactly (verified against R2026a over a stimulus that leaves the table on both axes at once), and it costs one clamp per axis instead of a special case per cell.
NO DIVIDER IS EMITTED. Each cell's four coefficients fold both axes' widths in at export time, so a cell is three multiplies and three adds on constants.
Sample results#
| t | in ICoreDouble-Out-0 | in ICoreDouble-Out-0 | out ICoreDouble-Out-0 |
|---|---|---|---|
| 0 | -2 | -2 | -17 |
| 0.4 | 0.5 | 0.5 | -2 |
| 0.8 | -2 | -2 | -17 |
| 1.2 | 0.5 | 0.5 | -2 |
| 1.6 | -2 | -2 | -17 |
| 2 | 0.5 | 0.5 | -2 |
| 2.4 | -2 | -2 | -17 |
| 2.8 | 0.5 | 0.5 | -2 |
| 3.2 | -2 | -2 | -17 |
| 3.6 | 0.5 | 0.5 | -2 |
| 4 | -2 | -2 | -17 |
| 4.4 | 0.5 | 0.5 | -2 |
| 4.8 | -2 | -2 | -17 |
| 5.2 | 0.5 | 0.5 | -2 |
Every 4th of 60 samples, from the table stimulus.
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) | -7 … 4 |
ramp | Ramp: slope 1 from t = 0 | -7 … 76.76 |
sine | Sine Wave: amplitude 1, 2 rad/s, no phase, no bias | -14 … 3.994 |
step | Step: 0 -> 1 at t = 1 s | -7 … 4 |
Plotted: table — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample
Category static · sample time 0.1 · 60 steps · commit ccf005c8 · produced by docsSample --out <folder> --steps 60 · data docs/generated/samples/Control_Systems__Lookup_Tables__Lookup_Table_2D.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).