my_demo.mp4
my_image_classif_demo.mp4
After months of dedication and hardwork I'm happy to say that I have finally completed the MAC Array Based Neural Network Accelerator using VHDL on Vivado from scratch(No HLS).
-
A MAC Array Control Unit with 5 states (IDLE, FETCH , COMPUTE, STORE, CLEAR) to control the data movement and computational processes in the entire Accelerator.
-
An Input Features Buffer to receive the preprocessed data from my PC via UART, temporarily store them in an async FIFO and send them to the MAC array for computation.
-
Parameter BRAM to store the the model parameters.
-
A Parameter Buffer to fetch parameters from Parameter BRAM and feed each parameter to its own corresponding MAC unit
-
A layer reusable MAC array comprised of Serial MAC units for matrix-vector computations
-
Requantization Block to convert the Q8.8 accumulations back to Q4.4.
-
An Activation Buffer to temporarily store activations and distribute them to their designated address in the Activation FIFO
-
Activation FIFO to temporarily store the activations and feed them back into the MAC array for next layer computation
-
ReLU and Argmax Activation blocks for hidden and output layer activation functions
The challenging part of this entire project was designing the architecture and before writing any RTL code I asked myself these critical questions:
-
How do I fetch parameters from BRAM and send them to their designated MAC units?
-
How do I store the computed activations and feed them back into the MAC Array for next layer computations?
-
How do I synchronize the incoming input features with their corresponding parameters during computation?
-
How do I receive and handle preprocessed data sent from PC to the FPGA?
-
How do I control and organize all the data movement and computational processes in the Accelerator?
-
How do I design a Serial MAC unit optimized for scalability and resource utilization?
-
How does the Accelerator know when to start running inference?
-
How can I reuse my MAC Array over multiple layers ?
-
How do I make the Accelerator configurable for different neural network topologies?
These questions influenced all my architectural design choices and by addressing them one by one I was able to build the core modules for this project.
Behavioural simulation was carried out by running inference for a pretrained speech recognition model for digits 0-9 and predictions for test data samples matched the expected outcome.
Initially, the Accelerator design worked in simulation but failed on hardware. I use the Integrated Logic Analyzer to compare the MAC Array vs Argmax outputs which showed that Argmax was producing wrong activations. I redesigned it using a serial chain of pipelined comparators and it worked.
Next I will run hardware inference for other dense neural network models since the accelerator is fully configurable and this will be the fun part. I will also use this project as a foundation for a CNN Accelerator project in the future.







