
I built a custom CNN accelerator from scratch on a $25 FPGA (Tang Nano 20K)
Hey everyone, I wanted to share a personal project I just finished. I built this mainly to dive deep and learn more about VLSI, SystemVerilog, and how CNNs actually execute at the silicon level.
It’s an end-to-end SoC running a quantized MicroCNN on a Sipeed Tang Nano 20K, and right now I have it classifying biological images from the BloodMNIST dataset over a UART bridge. For the architecture, I wrote the entire datapath from scratch. It uses parallel spatial MAC arrays for the convolutional layers and parallel FC MACs for the linear layers, so it's not just relying on simple time-division multiplexing. The weights are quantized to INT8 and biases to INT32. I also got glitchless clock gating working with the Gowin DCS, meaning the NPU completely powers down during idle states.
The design runs at 30 MHz, and an end-to-end inference takes about 60 ms. To benchmark it, I ran a vectorized Python "golden model" on my MacBook Air 2017, which took around 120 ms. It was incredibly satisfying to watch a $25 FPGA beat the laptop CPU!
I really hope this inspires some of you to dust off your Tang Nano boards and give it a try. If you use the Jupyter notebook I included, you can easily retrain the network's weights and biases to use this exact architecture for your own custom classification models. I’m more than happy to help anyone who wants to get it running or has questions about the implementation.
I'll drop the link to the source code in the comments. Attached is a picture of the board running the Python host script alongside the BloodMNIST input image it classified. I'd love to hear your thoughts!