Butterworth Design — Control Systems/Polynomials
Control_Systems/Polynomials/Butterworth_Design · 1 input / 2 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.
Butterworth Design
Control Systems / Polynomials
Designs a digital Butterworth filter of order N and reports its
coefficients, with the cutoff arriving on a port. It is MATLAB's
butter: the analog maximally-flat prototype, denormalized to the
cutoff and mapped to z by the bilinear transform prewarped at that same
cutoff, so the digital response is 3 dB down at exactly
fc.
Everything follows from one number, T = tan(πfc/fs); both polynomials are then divided by a[0], so the denominator is monic and the answer is MATLAB's exactly.
It designs; it does not filter. Feed b and a to Discrete / Transfer Fcn Direct Form II Time Varying, which takes them on ports and so retunes with them. If you only want the filtered signal and never the coefficients, Continuous / Varying Lowpass Filter is the same Butterworth with the cutoff on a port and no coefficients to look at.
Ports
- fc – the cutoff frequency in Hz. Scalar. Clamped into (0, fs/2) – see Notes, the clamp is a live branch.
- b – the numerator's coefficients, descending powers of z, as a column of N + 1 entries.
- a – the denominator's, the same length, with a[0] = 1.
Parameters
- Order – N, a whole number from 1 to 8. Both outputs are N + 1 long. Default 2.
- Filter Type – which prototype mapping is used:
- Lowpass – passes below the cutoff. Default.
- Highpass – passes above it. The same prototype with s and 1/s exchanged, which swaps the roles of (z−1) and (z+1) and makes the numerator (z−1)N.
- Sample Rate (Hz) – fs, the rate the filter is designed FOR, and the rate the cutoff is measured against. Strictly positive. This is not the block's own rate. Default 100.
- 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 order, the type and the rate are structural and are baked into the generated body, so nothing is exposed as a tunable parameter on the generated core; the prototype coefficients and the integer expansions are inlined.
The three HDL targets are simulation-only, and deliberately: a
tangent and a reciprocal do not belong in a Q16.16 datapath. Both
are evaluated in real and the values convert at the port boundary,
which is what the Trigonometry family does for the same reason. The seven
software targets are exact.
Simulink bridge
None (Support::None). butter is a MATLAB
function and the Signal Processing Toolbox it comes from ships no Simulink
library at all. A sweep of the DSP System Toolbox design library on 2026-09-10
found only Analog Filter Design, which does the mapping internally and
exposes no part of it – so there is no library path a diagram could name.
The bridge reports this block rather than dropping it silently, and it therefore
has no parity testbench; code export verification still covers it across
all ten languages. No configuration of it crosses either, including
"Sampling Time (s)", which has no counterpart to be written to.
Notes
- Algebraic, with no state: the output depends only on the current input.
- The cutoff is a PORT and MATLAB's is an argument. A cutoff taken from configuration would make this block a constant – nothing downstream could retune it. On a port it is a live design, which is what pairs it with Transfer Fcn Direct Form II Time Varying.
- The clamp is a live branch, not a safety net. fc is clamped into (0, fs/2) by (|x−lo| − |x−hi| + lo + hi)/2, branchless and identical in this block and in all ten emitted bodies, so they agree bit for bit. It exists because VHDL's TAN raises an error at π/2, which aborts a simulation rather than returning a bad number. A cutoff at or below zero therefore designs at the bottom of the band rather than failing: T → 0, the numerator vanishes and the denominator becomes (z−1)N.
- Dividing by a[0] is safe here, and it is not on Bilinear Transform. a[0] is a sum of dj·T… terms with every dj and T strictly positive, so it is at least 1 and cannot vanish. Polynomials / Bilinear Transform takes its analog denominator from a port, where the same quantity can pass through zero, so that block leaves the scale alone. The two blocks normalize differently on purpose.
- Measured against R2026a, at fs = 4 Hz over orders 2 and 3
and cutoffs 0.7 and 1.1 Hz, both types: the largest disagreement with
butteron any coefficient over those eight combinations is 2.2e−16. - No state space: one scalar in and two vectors out, so there is no A/B/C/D to merge and model reduction correctly declines it.
Code facts#
| Fact | Value |
|---|---|
| registered type | Control_Systems/Polynomials/Butterworth_Design |
| family | Control_Systems/Polynomials |
| solver environment class | ICoreBlock_0_Control_Systems_1_Polynomials_2_Butterworth_Design |
| source | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Polynomials/Butterworth_Design/ICoreBlock_0_Control_Systems_1_Polynomials_2_Butterworth_Design.cpp |
| header | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Polynomials/Butterworth_Design/ICoreBlock_0_Control_Systems_1_Polynomials_2_Butterworth_Design.h |
| default size on canvas | 132 × 80 px |
| ports at insert | 1 in, 2 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 | fc |
| 2 | out | ICoreDouble | b |
| 3 | out | ICoreDouble | a |
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 |
|---|---|---|
Order | 2 | — |
Filter Type | Lowpass%~%Highpass~~Lowpass | — |
Sample Rate (Hz) | 100 | — |
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::None |
| Simulink path | — |
| port-count rule | PortsParam::None |
SampleTime parameter | yes |
Caveat (shown to the user): designing a Butterworth filter is a MATLAB function (butter), not a Simulink library block -- the Signal Processing Toolbox it comes from ships no Simulink library at all, and a sweep of the DSP System Toolbox design library found only Analog Filter Design, which does the mapping internally and exposes no part of it -- so there is no path a diagram could name; the block is reported rather than dropped when a model crosses
Catalog contract: src/ICoreBlocks/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).
Butterworth Design -- butter on a wire, with the cutoff on a port One number carries the whole design: T = tan(pi*fc/fs). With d the analog prototype's coefficients and C(p,q) the integer expansion of (z-1)^p (z+1)^q,
lowpass a_raw[r] = SUM(j) d_j * T^j * C(N-j, j)[r] b_raw[r] = T^N * C(0, N)[r] highpass a_raw[r] = SUM(j) d_j * T^(N-j) * C(j, N-j)[r] b_raw[r] = C(N, 0)[r]
and both are divided by a_raw[0], which is MATLAB's normalization and is safe here: every d_j is strictly positive and so is T, so a_raw[0] is a sum of positive terms and is at least 1.
Verified against MATLAB R2026a rather than asserted, at fs = 4 Hz over orders 2 and 3 and cutoffs 0.7 and 1.1 Hz, both types: the largest disagreement with butter() over the eight combinations is 2.22e-16 on any coefficient. For the record, butter(3, 0.35) reports
lowpass b 0.071761203843781832 0.21528361153134551 0.21528361153134551 0.071761203843781832 a 1 -0.86822054422119499 0.53440466707071899 -0.092094492099269218 highpass b 0.31183996292389787 -0.93551988877169356 0.93551988877169356 -0.31183996292389787 a 1 -0.86822054422119488 0.53440466707071876 -0.09209449209926919
⚠ THE PROTOTYPE IS BUILT FROM REAL QUADRATIC FACTORS, not from complex poles. The left-half-plane poles come in conjugate pairs, so the polynomial is the product of s^2 - 2cos(theta_j)s + 1 over the pairs, times (s+1) when the order is odd. Nothing complex is ever formed, and the result matches MATLAB's real(poly(...)) to the last bits.
Sample results#
| t | in ICoreDouble-Out-0 | out ICoreDouble-Out-0 [3x1] entry 0 | out ICoreDouble-Out-1 [3x1] entry 0 |
|---|---|---|---|
| 0 | -2 | [9.87e-16, 1.974e-15, 9.87e-16] | [1, -2, 1] |
| 0.4 | 0.5 | [2.414e-4, 4.827e-4, 2.414e-4] | [1, -1.956, 0.9565] |
| 0.8 | -2 | [9.87e-16, 1.974e-15, 9.87e-16] | [1, -2, 1] |
| 1.2 | 0.5 | [2.414e-4, 4.827e-4, 2.414e-4] | [1, -1.956, 0.9565] |
| 1.6 | -2 | [9.87e-16, 1.974e-15, 9.87e-16] | [1, -2, 1] |
| 2 | 0.5 | [2.414e-4, 4.827e-4, 2.414e-4] | [1, -1.956, 0.9565] |
| 2.4 | -2 | [9.87e-16, 1.974e-15, 9.87e-16] | [1, -2, 1] |
| 2.8 | 0.5 | [2.414e-4, 4.827e-4, 2.414e-4] | [1, -1.956, 0.9565] |
| 3.2 | -2 | [9.87e-16, 1.974e-15, 9.87e-16] | [1, -2, 1] |
| 3.6 | 0.5 | [2.414e-4, 4.827e-4, 2.414e-4] | [1, -1.956, 0.9565] |
| 4 | -2 | [9.87e-16, 1.974e-15, 9.87e-16] | [1, -2, 1] |
| 4.4 | 0.5 | [2.414e-4, 4.827e-4, 2.414e-4] | [1, -1.956, 0.9565] |
| 4.8 | -2 | [9.87e-16, 1.974e-15, 9.87e-16] | [1, -2, 1] |
| 5.2 | 0.5 | [2.414e-4, 4.827e-4, 2.414e-4] | [1, -1.956, 0.9565] |
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) | 9.87e-16 … 9.447e-4 |
ramp | Ramp: slope 1 from t = 0 | 9.87e-16 … 0.02623 |
sine | Sine Wave: amplitude 1, 2 rad/s, no phase, no bias | 9.87e-16 … 9.439e-4 |
step | Step: 0 -> 1 at t = 1 s | 9.87e-16 … 9.447e-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 b755fc86d0eadc503c92782f3b2145159e1ec333 · produced by docsSample --out <folder> --blocks Butterworth_Design --steps 60 · data docs/generated/samples/Control_Systems__Polynomials__Butterworth_Design.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).