Encoding
turning values into spikes & bitstreams
Every idea elsewhere in this section — a stochastic multiplier, a spiking network, a hypervector — starts by turning an ordinary number into something the fabric can compute on: a spike train or a random bitstream. The encoding you pick sets the whole trade between accuracy, latency and energy, so it is the first real design decision, not a detail. This page lays out the choices and what they cost.
The core idea — the same value, many codes
A value $v$ can be written as how often a neuron fires (rate coding), when it first fires (temporal coding), or the density of ones in a random stream (stochastic coding). These are not interchangeable: rate codes are robust but spike-hungry; temporal codes are extraordinarily sparse but fragile to jitter; stochastic streams are cheap to compute on but pay the $1/\sqrt L$ precision tax. The right choice depends on whether you are optimising accuracy, energy, or latency.
$$\text{rate: } \Pr(\text{spike})=v \qquad \text{latency: } t_{\text{spike}} \propto \tfrac{1}{v} \qquad \text{stochastic: } \hat v=\tfrac{1}{L}\textstyle\sum_i b_i$$
The three rows encode the same value. Rate fills the window with random spikes at density $v$; latency fires once, earlier for larger $v$; burst packs a run of spikes proportional to $v$. Notice how few spikes latency needs — that sparsity is its whole appeal.
01 Rate coding — value as firing probability
The simplest and most robust scheme: emit a spike each step with probability equal to the value (Bernoulli sampling), so the value is the average firing rate over the window. It tolerates noise well because the estimate averages over many spikes — and it costs many spikes for exactly that reason.
$$b_t \sim \text{Bernoulli}(v), \qquad \hat v = \frac{1}{T}\sum_{t=1}^{T} b_t, \qquad \sigma_{\hat v}\propto \tfrac{1}{\sqrt T}$$
Deeper: rate is the winner where accuracy matters
On a feedforward MNIST benchmark, rate-family encodings dominate accuracy — measured 90.4% for plain rate and 91.9% for a repeat-binary variant — at roughly 2,400 spikes per sample. That is the same de-correlated Bernoulli process that a stochastic number generator produces, which is why rate coding and stochastic computing are two views of one idea. The cost is spike count: robustness comes from averaging, and averaging takes samples. (Numbers from a fixed MNIST setup on 2026-03-28; treat them as directional, not universal.)
02 Temporal coding — value as timing
Put the information in when a neuron fires rather than how often. Latency (time-to-first-spike) fires once, sooner for a larger value; rank-order encodes only the order in which a population fires. Both are astonishingly sparse — a single spike per unit — and fast, because the answer is available at the first spike.
$$t_{\text{first}} = T\,(1 - v), \qquad \text{rank-order: information in the permutation of first-spike times}$$
Deeper: the sparsity dividend, and its fragility
On the same MNIST benchmark, latency coding reached 88.1% accuracy with only ~142 spikes per sample — about 17× fewer than rate for a few points less accuracy, the best accuracy-per-spike of any scheme tested. That is the neuromorphic dream: almost no spikes, almost all the answer. The price is fragility — a single spike carries the whole value, so timing jitter and dropped spikes hurt far more than in a rate code, and rank-order (142 spikes but 67.1%) shows that ordering alone needs a recurrent network to shine. Temporal codes reward event-driven hardware, where the cost is per spike.
03 Stochastic bitstreams — the number generator
To feed a stochastic datapath, a value becomes a random bitstream whose 1-density equals the value. A stochastic number generator does it each cycle: draw a pseudo-random number from an LFSR and emit 1 when it falls below the target. Operands that will be combined must use independent seeds, or their streams correlate and the arithmetic biases.
$$b_t = \mathbf{1}[\,r_t < v\,], \quad r_t \sim \text{LFSR}, \qquad \text{precision} \propto \tfrac{1}{\sqrt L}\;\;(\text{Sobol}: \tfrac{1}{L})$$
Deeper: the same code, two destinations
A rate-coded spike train and a unipolar stochastic bitstream are the same object seen by two communities: a Bernoulli sequence whose density is the value. The difference is what consumes it — a spiking neuron integrates it, a stochastic AND gate multiplies it. Driving the generator from a deterministic LFSR seed is what lets SC-NeuroCore reproduce the identical stream in simulation and in silicon, keeping the co-simulation bit-true. The full arithmetic that runs on these streams is the subject of the stochastic-computing page.
04 Fixed-point & mixed precision — when to leave the stream
Streams and spikes are cheap but low-precision. Where a model needs many accurate bits, the value is carried in fixed-point instead — commonly Q8.8, eight integer and eight fractional bits, a step of $1/256$ — or in a micro-floating-point format. Real designs are mixed precision: bulk computation in streams, precision-critical parts in fixed point.
$$\text{Q8.8: } x = \frac{n}{2^{8}},\; n\in[-2^{15}, 2^{15}\!-\!1], \qquad \text{step}=\tfrac{1}{256}\approx 0.0039$$
Deeper: the precision contract
Q8.8 covers roughly $[-128, +128)$ with a uniform step of $1/256$; wider dynamic range uses Q4.12 or Q16.16, and micro-floating-point (MXFP) trades a shared exponent for range where activations span many orders of magnitude. The engineering discipline SC-NeuroCore imposes is that the format is a stated contract: a quantisation manifest records exactly what precision each tensor carries, and the co-simulation proves the fixed-point Verilog matches the Python bit-for-bit. Precision is chosen, declared and verified — not assumed.
05 Decoding & compression
Reading a value back out of a stream is a popcount — count the ones in the packed word. And because spike rasters are mostly zeros, they compress well: SC-NeuroCore ships several lossless spike codecs that store only the events, shrinking a sparse raster by several times.
$$\hat v = \frac{\text{popcount}(\text{word})}{L}, \qquad \text{codec: raster} \leftrightarrow \text{events, lossless}$$
Deeper: the spike codecs
The codec family — inter-spike-interval, address-event, predictive, delta and streaming — each exploits sparsity differently, and all round-trip losslessly (decompressing to the exact original raster). On sparse trains they achieve several-fold compression; on dense trains the ratio falls toward one, as it must. The codec-benchmark notebook on this site runs all of them across spike densities and prints the ratios, so the trade is measured rather than asserted. Compression matters most for the address-event traffic between neuromorphic cores, where bandwidth is the constraint.
Measured — encodings on MNIST
Seven schemes on the same feedforward network, ranked by the trade you care about. Accuracy is not the only axis: latency coding gives up a few points for a 17× cut in spikes.
| Encoding | Principle | Spikes / sample | MNIST accuracy |
| repeat_binary | threshold > 0.5, repeat | 2,429 | 91.9% |
| direct | float repeated | 2,396 | 91.2% |
| rate | Bernoulli at p = value | 2,396 | 90.4% |
| latency | time-to-first-spike | 142 | 88.1% |
| burst | burst length ∝ value | 1,055 | 84.7% |
| rank_order | first-spike ordering | 142 | 67.1% |
| phase | phase within a cycle | 3,011 | 62.1% |
Measured on a fixed setup (SpikingNet 784→128→10, 5,000 train / 1,000 test, MNIST run 2026-03-28). These numbers are directional for this task and network, not universal constants; the demo above is illustrative and not the trained pipeline.
Where to next
Further reading. Gautrais, J. & Thorpe, S. (1998) Rate coding versus temporal order coding. Thorpe, S. et al. (2001) Spike-based strategies for rapid processing. For the terminology, see the SC-NeuroCore glossary.