$ cat /projects/mnist-upduino.md

MNIST on an FPGA

A 56-feature MNIST classifier small enough for an iCE40 UP5K, quantized to int8 and exported as Verilog memory files.

year
2026
role
Research & hardware
stack
Python · JAX · Verilog
A plot of test accuracy against on-chip weight storage for quantized and low-rank models.

Brief

An iCE40 UP5K has no DSPs, 15 KiB of EBR, and very little room for a neural network. I wanted to see how much of MNIST could fit if the model were designed for the chip rather than trained first and squeezed later.

Approach

The pipeline reduces each 28×28 image to 56 row and column means, trains a compact 64×64 MLP, quantizes the weights to int8 with power-of-two scales, and checks an integer-only forward pass. The exported weights and biases are written as $readmemh files for the FPGA build.

Result

The compact network has 8,458 parameters, occupies about 8.3 KiB of EBR, and reaches 90.63% on the official test set. Quantization costs 0.05 percentage points; the 56-feature projection is what limits accuracy. A follow-up low-rank study found a rank-16 SVD variant at 90.21% in 4.87 KiB — 42% less storage and 43% fewer MACs than the dense int8 export.