Generated reference › Sine — Control Systems/Lookup Tables
kind: generated#block#control-systems-lookup-tables

Sine — Control Systems/Lookup Tables

Control_Systems/Lookup_Tables/Sine · 1 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.

Sine

Control Systems / Lookup Tables

Computes y = sin(2πu) from a quarter-wave lookup table in 16-bit fixed point – the same approximation Simulink's Sine block makes, not a call to sin().

This block is an approximation by design. Its output is quantized to multiples of 2−14 and lands roughly 6×10−5 from the true sine. That is the point of it: a table and a few adds are far cheaper on a fixed-point target than a series expansion. If you want true sine, use Trigonometric Function instead.

Note the argument is in cycles, not radians: u = 1 is one full period.

Ports

  • Input – the phase u in cycles, of any size [m,n]. Any value is accepted; the phase wraps, so u and u+1 give the same output.
  • Output – the approximated sine y, of the SAME size [m,n], always in [−1, 1] and always a multiple of 2−14.

Parameters

  • Number Of Data Points – how many points the quarter-wave table holds, and therefore the accuracy. Defaults to 33, as in Simulink. More points mean a finer table and a smaller error between the points; it does not change the 2−14 output step, which is set by the 16-bit word and is the floor on accuracy however large the table gets. At least two.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

How the value is produced

The phase is cast to a multiple of 2−16 and wrapped into one period; the quarter with the same magnitude is found by symmetry; the table is read and linearly interpolated there; and the result is truncated to the 2−14 grid before the sign is put back. Each of those steps is Simulink's, and reproducing them is what makes this block match it rather than merely resemble it – verified against the R2026a block to zero mismatches over 644 samples at three different table sizes.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. The table is baked in at export time: its size decides how many branches the generated code has, so it cannot be a tunable parameter.

The three HDL targets are not simulation-only, and they are the case this block was shaped for: the arithmetic is adds, one multiply per branch, and shifts, with no divider and no transcendental function anywhere. The Q16.16 datapath even matches the block's own 2−16 input cast exactly, so the HDL cores agree with the software ones rather than approximating them.

Simulink bridge

Import and export, mapped to simulink/Lookup Tables/Sine. "Number Of Data Points" to NumDataPoints as a plain pass-through value. The block always writes Formula = sin(2*pi*u) and OutputWordLength = 16, which is what this block is.

This Simulink block has no SampleTime parameter (verified against the R2026a dialog), so the rate stays on the ICore side and a block configured with an explicit positive rate reports that it did not cross. Simulink's other two formulas – exp(j*2*pi*u) and the combined sine-and-cosine – are complex or two-output and have no counterpart here; see Cosine for the other real one.

Notes

  • Algebraic, with no state.
  • Elementwise: the output carries the input's size.
  • Not linear, and so deliberately carries no state space.
  • See Cosine for the same table a quarter period earlier.

Code facts#

FactValue
registered typeControl_Systems/Lookup_Tables/Sine
familyControl_Systems/Lookup_Tables
solver environment classICoreBlock_0_Control_Systems_1_Lookup_Tables_2_Sine
sourcesrc/ICoreSDK/ICoreBlockLibrary/Blocks/Control_Systems/Lookup_Tables/Sine/ICoreBlock_0_Control_Systems_1_Lookup_Tables_2_Sine.cpp
headersrc/ICoreSDK/ICoreBlockLibrary/Blocks/Control_Systems/Lookup_Tables/Sine/ICoreBlock_0_Control_Systems_1_Lookup_Tables_2_Sine.h
default size on canvas75 × 70 px
ports at insert1 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDouble
2outICoreDouble

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
Number Of Data Pointsstd::to_string(QWT::DEFAULT_POINTS)NumDataPoints

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/Lookup Tables/Sine
port-count rulePortsParam::None
SampleTime parameterno — the counterpart defines none; the rate stays on the ICore side
deliberately not crossedInternalRulePriority
always setFormula = sin(2*pi*u), OutputWordLength = 16
ICore configSimulink parameterValue translation
Number Of Data PointsNumDataPointspasses through

Caveat (shown to the user): an APPROXIMATION on both sides, not true sine: the output is quantized to 2^-14 and lands ~6e-5 from sin(). This block reproduces Simulink's fixed-point pipeline exactly rather than computing sin(), which is what makes the two comparable at a tight tolerance. Simulink's other formulas - exp(j*2*pi*u) and the combined sine-and-cosine - are complex or two-output and have no counterpart here. The Simulink block has NO SampleTime parameter, so the rate stays on the ICore side

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).

Sine block — y = sin(2*pi*u) as SIMULINK computes it: a 16-bit quarter-wave lookup Every step of the pipeline, and why it is an approximation rather than a call to sin(), is in ICoreQuarterWaveTable.h. This file is the block around it: ports, config, the Simulink entry, and the ten spellings of one shared body.

Algebraic, stateless, elementwise. No state space (see header).

Sample results#

Sine — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sampleSine — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample-1-0.500.51-2-10123inputoutput
tin ICoreDouble-Out-0out ICoreDouble-Out-0
0-20
0.40.50
0.8-20
1.20.50
1.6-20
20.50
2.4-20
2.80.50
3.2-20
3.60.50
4-20
4.40.50
4.8-20
5.20.50

Every 4th of 60 samples, from the table stimulus.

The same rig also ran:

StimulusWhat it isOutput range
impulseImpulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair)0 … 0
rampRamp: slope 1 from t = 0-0.9508 … 0.9508
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias-0.9991 … 0.9989
stepStep: 0 -> 1 at t = 1 s0 … 0

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__Sine.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).