Spiking vs. Classical NN on RISC-V
On a small RISC-V core, a spiking network loses on a whole heartbeat but wins over 100× when the ECG arrives one sample at a time.
Three heartbeats from an unseen patient classified by a classical and a spiking neural network. Grey updates every unit on every sample; orange lights up only when the beat looks unusual. The bars show the latency measured on the FPGA board.
software / matched hardware
MNIST image / whole heartbeat
bit-exact
Sep–Oct 2026 · Code and full technical report on GitHub →
Why
A wearable ECG monitor has a small processor and a battery, and most of what it sees is uneventful: one normal heartbeat looks like the last.
A conventional neural network (ANN) ignores that and does the full computation for every input. A spiking neural network only works when something changes, and then it adds instead of multiplying.
That promise is usually shown on dedicated neuromorphic chips [1]. I wanted to know whether it holds on the kind of small RISC-V core an edge device actually has.
How
My hypothesis: dense vs. sparse input decides which network wins.
Dense input is new everywhere, like a handwritten MNIST digit [2] or a whole heartbeat handed over at once: the spiking network has to repeat its work over several time steps.
Sparse input is the ECG fed one sample at a time: a normal heartbeat barely differs from the last, so it triggers only a handful of spikes.
So I compared both networks on dense input, and a GRU (a recurrent ANN) against a recurrent spiking network on the streamed ECG, all on the same core. Then, keeping their budgets comparable, I gave each side its own custom instructions.
What
Both networks run on a PicoRV32 [3] RISC-V core at 100 MHz in the FPGA of a PYNQ-Z2. Each network gets its own custom instructions: a neuron unit for the spiking network (889 lookup tables) and a multiply-accumulate unit for the ANN (758), each under 2% of the FPGA’s 53,200 lookup tables. The ARM processor on the same chip only loads the models and collects the results. All timing is counted in clock cycles on the RISC-V core itself.
I trained an ANN and a spiking network [4] on MNIST and on the MIT-BIH arrhythmia data [5], quantised both to 8-bit integers and ran them as C firmware on the board. Every output is checked bit for bit against the PC model, and latency is compared sample by sample.
Tools: PyTorch · C · Verilog · Vivado · Python
Results
In software, the ANN wins on every single input, an MNIST digit or a whole heartbeat. On the sparse stream, the spiking network wins by 30×.
With matched hardware, a small custom unit for each network, the ANN keeps its lead on dense input and the stream result holds: 4.6 ms per heartbeat for the spiking network against 492 ms for the GRU, 107× faster on every beat. Accuracy is comparable within each pair.
A spiking network isn’t faster in general; it’s faster when the signal is quiet.
What I learned
- Pick the baseline before the winner. Against the muRISCV-NN library, the spiking network looked faster on 9,998 of 10,000 images. Against an equally optimised ANN, it lost on all of them.
- Count cycles, not operations. 164× fewer operations became only 30× less time. The gap pointed straight at what the hardware had to fix.
- Hardware can’t fix the workload. A matched multiply-accumulate unit made the GRU 2.2× faster, but it is still 107× slower per heartbeat than the spiking network.
Next steps
- Event-driven ANN: a GRU that skips unchanged samples, as a stronger streaming baseline.
- Measured power on the board instead of estimates from cycle counts.
All details, derivations and per-sample results are in the technical report on GitHub.
References
- M. Davies et al., “Loihi: A neuromorphic manycore processor with on-chip learning,” IEEE Micro, vol. 38, no. 1, pp. 82–99, 2018.
- Y. LeCun, C. Cortes and C. J. C. Burges, “The MNIST database of handwritten digits,” 1998.
- C. Wolf, PicoRV32: github.com/YosysHQ/picorv32
- J. K. Eshraghian et al., “Training spiking neural networks using lessons from deep learning,” Proceedings of the IEEE, vol. 111, no. 9, pp. 1016–1054, 2023.
- G. B. Moody and R. G. Mark, “The impact of the MIT-BIH Arrhythmia Database,” IEEE Engineering in Medicine and Biology Magazine, vol. 20, no. 3, pp. 45–50, 2001.