# foodinsect/mnist-cnn-fpga architecture

> Architecture diagram of the GitHub repository foodinsect/mnist-cnn-fpga, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/foodinsect/mnist-cnn-fpga
- Repository: https://github.com/foodinsect/mnist-cnn-fpga

## Overview

This is a Vivado/Zynq MNIST CNN accelerator project. The documented product workflow streams image pixels into FPGA logic, buffers them for convolution and pooling, computes class scores, and returns classifications over UART. The README also describes MATLAB host integration, AXI control, and simulation-only 1,000-image testing. The available tree lacks the RTL and MATLAB sources, so hardware stages and their links are represented from README documentation; the SDK application excerpt shows interrupt setup, but not the inference datapath. Generated files and the vendor BSP are not mapped as product subsystems.

Main entry points: [`MNIST_CNN_FPGA.sdk/CNN/src/helloworld.c`](https://github.com/foodinsect/mnist-cnn-fpga/blob/main/MNIST_CNN_FPGA.sdk/CNN/src/helloworld.c) (UART output), [`MNIST_CNN_FPGA.srcs/sources_1/bd/design_1`](https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1) (On-chip BRAM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host and control"]
  node_sdk["SDK application<br/>[helloworld.c]"]
  node_axi["AXI control<br/>[design_1]"]
end

subgraph group_buffer["Image buffering"]
  node_bram[("On-chip BRAM<br/>[design_1]")]
  node_sliding["Sliding window<br/>[design_1]"]
  node_shift["Shift buffers<br/>[design_1]"]
end

subgraph group_cnn["CNN inference"]
  node_pe["PE array<br/>[design_1]"]
  node_conv["Convolution<br/>[design_1]"]
  node_relu["ReLU<br/>[design_1]"]
  node_pool["Max pooling<br/>[design_1]"]
  node_fifo["Feature FIFO<br/>[design_1]"]
  node_fc["Fully connected<br/>[design_1]"]
  node_result["Digit result<br/>[design_1]"]
end

subgraph group_platform["Platform I/O"]
  node_uart["UART output<br/>[helloworld.c]"]
end

node_matlab(("MATLAB host"))
node_image["Image pixels"]
node_terminal(("UART terminal"))

node_matlab -.->|"streams images"| node_axi
node_sdk -.->|"controls accelerator"| node_axi
node_image -.->|"loads pixels"| node_bram
node_bram -.->|"fetches pixels"| node_sliding
node_sliding -.->|"buffers rows"| node_shift
node_shift -.->|"feeds pixels"| node_pe
node_pe -.->|"computes features"| node_conv
node_conv -.->|"activates features"| node_relu
node_relu -.->|"passes activations"| node_pool
node_pool -.->|"buffers features"| node_fifo
node_fifo -.->|"feeds classifier"| node_fc
node_fc -.->|"outputs class"| node_result
node_result -.->|"returns result"| node_uart
node_uart -.->|"prints result"| node_terminal
node_matlab -.->|"receives results"| node_uart

click node_sdk "https://github.com/foodinsect/mnist-cnn-fpga/blob/main/MNIST_CNN_FPGA.sdk/CNN/src/helloworld.c"
click node_axi "https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1"
click node_bram "https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1"
click node_sliding "https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1"
click node_shift "https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1"
click node_pe "https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1"
click node_conv "https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1"
click node_relu "https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1"
click node_pool "https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1"
click node_fifo "https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1"
click node_fc "https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1"
click node_result "https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1"
click node_uart "https://github.com/foodinsect/mnist-cnn-fpga/blob/main/MNIST_CNN_FPGA.sdk/CNN/src/helloworld.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sdk,node_axi toneBlue
class node_bram,node_sliding,node_shift toneAmber
class node_pe,node_conv,node_relu,node_pool,node_fifo,node_fc,node_result toneMint
class node_uart toneRose
class node_matlab,node_image,node_terminal toneIndigo
```

## Components

### Host and control

- [SDK application](https://github.com/foodinsect/mnist-cnn-fpga/blob/main/MNIST_CNN_FPGA.sdk/CNN/src/helloworld.c): `MNIST_CNN_FPGA.sdk/CNN/src/helloworld.c`
- [AXI control](https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1): `MNIST_CNN_FPGA.srcs/sources_1/bd/design_1`

### Image buffering

- [On-chip BRAM](https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1): `MNIST_CNN_FPGA.srcs/sources_1/bd/design_1`
- [Sliding window](https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1): `MNIST_CNN_FPGA.srcs/sources_1/bd/design_1`
- [Shift buffers](https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1): `MNIST_CNN_FPGA.srcs/sources_1/bd/design_1`

### CNN inference

- [PE array](https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1): `MNIST_CNN_FPGA.srcs/sources_1/bd/design_1`
- [Convolution](https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1): `MNIST_CNN_FPGA.srcs/sources_1/bd/design_1`
- [ReLU](https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1): `MNIST_CNN_FPGA.srcs/sources_1/bd/design_1`
- [Max pooling](https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1): `MNIST_CNN_FPGA.srcs/sources_1/bd/design_1`
- [Feature FIFO](https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1): `MNIST_CNN_FPGA.srcs/sources_1/bd/design_1`
- [Fully connected](https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1): `MNIST_CNN_FPGA.srcs/sources_1/bd/design_1`
- [Digit result](https://github.com/foodinsect/mnist-cnn-fpga/tree/main/MNIST_CNN_FPGA.srcs/sources_1/bd/design_1): `MNIST_CNN_FPGA.srcs/sources_1/bd/design_1`

### Platform I/O

- [UART output](https://github.com/foodinsect/mnist-cnn-fpga/blob/main/MNIST_CNN_FPGA.sdk/CNN/src/helloworld.c): `MNIST_CNN_FPGA.sdk/CNN/src/helloworld.c`

### Other components

- **MATLAB host**
- **Image pixels**
- **UART terminal**

## Connections

- MATLAB host → AXI control: streams images
- SDK application → AXI control: controls accelerator
- Image pixels → On-chip BRAM: loads pixels
- On-chip BRAM → Sliding window: fetches pixels
- Sliding window → Shift buffers: buffers rows
- Shift buffers → PE array: feeds pixels
- PE array → Convolution: computes features
- Convolution → ReLU: activates features
- ReLU → Max pooling: passes activations
- Max pooling → Feature FIFO: buffers features
- Feature FIFO → Fully connected: feeds classifier
- Fully connected → Digit result: outputs class
- Digit result → UART output: returns result
- UART output → UART terminal: prints result
- MATLAB host → UART output: receives results
