mpnpu: a switchable 1-bit / INT8 neural-network accelerator on a small FPGA
Draw a digit. Your browser runs the same bit-exact integer model that the Sipeed Tang Nano 9K runs in hardware, using the same packed weights and thresholds, so you see exactly what the FPGA computes, layer by layer. The matrix unit switches per layer between a 64-lane XNOR+popcount datapath and an 8-lane INT8 MAC datapath. Source, RTL and test benches on GitHub.
96.4%MNIST accuracy measured on the board (1,000 images)
1.63 mson-chip compute at 27 MHz (43,934 cycles)
12.3 msmean round trip over USB-UART on hardware
−68.7%weight memory compared with an all-INT8 model
38%of the GW1NR-9 logic, 42.3 MHz Fmax
Draw one digit, large and centred. It is cropped, scaled and centred like MNIST, then binarised at 128,
the same way sw/host_client.py prepares images for the board.
–
Waiting for a drawing.
Run it on a real Tang Nano 9K
Needs Chrome or Edge (Web Serial) and a board running this design, at 115,200 baud.
Input
28 × 28 × 1 bit 98 bytes over UARTconv1 3×3, 1 → 16, max-pool
precision_mode 0 · 1-bit XNOR + popcountBatchNorm and sign are folded into one integer threshold per channel. Binary max-pool is a logical OR. Output 13 × 13 × 16 bits.
conv2 3×3, 16 → 64, max-pool
precision_mode 0 · 1-bit XNOR + popcount144 of 192 binary lanes used per beat. Output 5 × 5 × 64 bits.
Region counts
256 values, 0 to 9For each of the 64 channels, the number of set bits in four overlapping 3 × 3 regions (top-left, top-right, bottom-left, bottom-right).