Conv 1D — Machine Learning/Neural Networks
Machine_Learning/Neural_Networks/Conv_1D · 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.
Conv 1D
Machine Learning / Neural Networks
Slides one kernel along the input column:
yi = b + Σj wj · uiS + jD − P, with u read as 0 outside the signal, and Lout = ⌊(L + 2P − span) ÷ S⌋ + 1 where span = (K−1)D + 1
The front end of any 1-D CNN or temporal convolutional network. Stack several with Dilation 1, 2, 4, 8 and you have a TCN: the receptive field doubles per layer while the parameter count does not.
This is cross-correlation – the kernel is not reversed
– which is what torch.nn.Conv1d and Keras Conv1D
compute under the name convolution. A block that reversed it to be
mathematically pedantic would disagree with every set of trained weights you
paste in.
Ports
- u – the sequence, a column [L,1]. L + 2P must be at least the kernel's span, or there is no complete window and the block is reported.
- Output – y, a column [Lout,1] as above. The block resizes its output when L or any of the geometry changes, so a downstream block sees the new length.
Parameters
- Kernel – w, the [K,1] filter taps, in signal
order.
layer.weight[0][0]for a single-channel PyTorchConv1d. - Bias – b, one scalar added to every output. Use 0 for a
layer trained with
bias=False. - Stride – S, how far the window advances per output; a whole number ≥ 1.
- Padding – P, how many implicit zeros are placed at each end; a whole number ≥ 0. P = (span−1)/2 with S = 1 is the "same" padding that keeps Lout = L.
- Dilation – D, the gap between taps; a whole number ≥ 1. D = 1 is an ordinary convolution; larger values spread the same K taps over a wider span without adding parameters.
- 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. Every window is unrolled at export time, and
each tap that falls in the padding is resolved to a literal zero and dropped
from the emitted expression rather than guarded at run time – so the
generated code contains no bounds check anywhere. The kernel and bias are baked
in at full setprecision(17); there is no tunable parameter, because
a trained tap is not something to retune on the target.
The three HDL targets are ordinary Q16.16 fixed point and are offered for synthesis: the whole block is multiply-accumulate, with no transcendental and no division.
Simulink bridge
None. Simulink's convolution layers live inside its Deep Learning
blocks, which take a trained network object rather than a kernel, and no
config value can carry an object across the bridge.
(Discrete FIR Filter is a different thing: it filters along
time, one sample in and one out, where this slides along a vector within one
sample.) The bridge reports the block rather than dropping it silently, and it
has no parity testbench, which is the documented consequence of
Support::None rather than a gap.
Notes
- Algebraic and stateless: the whole window comes from the current input column, not from past samples. This convolves across the vector, not across time – for a filter over TIME use Discrete FIR Filter.
- Linear in u, but it deliberately carries no state space: an
[Lout,L] feed-through matrix is not what
ICoreStateSpace's merge rules are for, and model reduction requires a SISO form this block does not have. - Single channel. One kernel, one input column, one output column. A multi-channel convolution – and the depthwise variant that goes with it – would need a three-dimensional weight tensor, which a two-dimensional config cannot carry without a flattening convention this block does not define.
- The tail is dropped, exactly as in every framework: if (L + 2P − span) is not a multiple of S, the samples past the last complete window are not read.
Code facts#
| Fact | Value |
|---|---|
| registered type | Machine_Learning/Neural_Networks/Conv_1D |
| family | Machine_Learning/Neural_Networks |
| solver environment class | ICoreBlock_0_Machine_Learning_1_Neural_Networks_2_Conv_1D |
| source | src/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Neural_Networks/Conv_1D/ICoreBlock_0_Machine_Learning_1_Neural_Networks_2_Conv_1D.cpp |
| header | src/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Neural_Networks/Conv_1D/ICoreBlock_0_Machine_Learning_1_Neural_Networks_2_Conv_1D.h |
| default size on canvas | 120 × 80 px |
| ports at insert | 1 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 | out | ICoreDouble | y |
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 |
|---|---|---|
Kernel | [0.6; -0.25; 0.9] | — |
Bias | 0.1 | — |
Stride | 1 | — |
Padding | 0 | — |
Dilation | 1 | — |
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): no Simulink equivalent as a signal block: its convolution layers exist only inside the Deep Learning blocks, which take a trained network OBJECT rather than a kernel. Discrete FIR Filter is not the same thing -- it filters along TIME, one sample in and one out, where this slides along a vector within one sample
Catalog contract: src/ICoreSDK/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h
Description vs code#
The checker has a blind spot here — it could not resolve something (a grouped port bullet, a computed config name), which is reported and never counted as a pass. A reader has to settle it:
B0every stimulus in the sample errored — cross-checks skipped
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).
Conv 1D — single-channel cross-correlation with stride, zero padding and dilation y[i] = b + sum_j w[j] * u[i*S + j*D - P] u read as 0 outside 0, L)
Fully UNROLLED at export time: L, K, S, P and D are all known once the model is built, and every tap that falls in the padding is resolved to a literal 0 and dropped from the emitted expression rather than guarded at run time. So no backend emits a loop bound, an index type or a bounds check, and PLC and the HDLs get the same straight-line code as C.
The three HDL targets are genuine Q16.16: this is multiply-accumulate and nothing else.
Sample results#
No stimulus produced a sampled output in this rig — Kernel span longer than the padded signal at: ICore Blocks/Home/Conv 1D. That is a fact about the single-block rig, not a verdict on the block: an offline batch fit, a block whose output only appears at onSolverFinish, or one that needs a driven environment cannot be exercised alone.
Category unsampled · sample time 0.1 · 60 steps · commit ccf005c8 · produced by docsSample --out <folder> --steps 60
Sample data: [docs/generated/samples/Machine_Learning__Neural_Networks__Conv_1D.json