# omarelhedaby/cnn-fpga architecture

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

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

## Overview

This repository implements a handwritten-digit CNN for Zynq FPGA in Verilog. The documented user-to-result flow is MNIST image data through three convolution/activation stages, two pooling stages, then a fully connected classifier and Softmax scores. The README establishes the network order; source excerpts are limited to Python reference/testing code, so internal RTL calls and parameter wiring are not verified and are not inferred here.

Main entry points: [`Final Code Files/Part 5- Integration/ANNfull.v`](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/ANNfull.v) (CNN integration), [`Final Code Files/Part 1- Convolution/convLayerMulti.v`](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%201-%20Convolution/convLayerMulti.v) (Convolution 1), [`Final Code Files/Part 5- Integration/HyperBolicTangent.v`](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/HyperBolicTangent.v) (Tanh 1), [`Final Code Files/Part 4- Average Pooling/AvgPoolMulti.v`](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%204-%20Average%20Pooling/AvgPoolMulti.v) (Average pool 1)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Network integration"]
  node_top["CNN integration<br/>[ANNfull.v]"]
end

subgraph group_features["Feature extraction"]
  node_conv1["Convolution 1<br/>[convLayerMulti.v]"]
  node_tanh1["Tanh 1"]
  node_pool1["Average pool 1<br/>[AvgPoolMulti.v]"]
  node_conv2["Convolution 2"]
  node_tanh2["Tanh 2"]
  node_pool2["Average pool 2<br/>[AvgPoolMulti.v]"]
  node_conv3["Convolution 3"]
  node_tanh3["Tanh 3"]
end

subgraph group_classifier["Classification"]
  node_fc1["Fully connected 1<br/>[InegrationFCpart.v]"]
  node_relu["ReLU"]
  node_fc2["Fully connected 2<br/>[InegrationFCpart.v]"]
  node_softmax["SoftMax scores<br/>[softmax.v]"]
end

subgraph group_numeric["Numeric primitives"]
  node_convunit["Convolution unit<br/>[convUnit.v]"]
  node_processing["Processing element"]
  node_weights["Model parameters"]
end

node_mnist(("MNIST image"))

node_mnist -.->|"input"| node_top
node_top -.->|"runs"| node_conv1
node_conv1 -->|"convolves then activates"| node_tanh1
node_tanh1 -->|"feeds"| node_pool1
node_pool1 -->|"feeds"| node_conv2
node_conv2 -->|"convolves then activates"| node_tanh2
node_tanh2 -->|"feeds"| node_pool2
node_pool2 -->|"feeds"| node_conv3
node_conv3 -->|"convolves then activates"| node_tanh3
node_tanh3 -->|"feeds"| node_fc1
node_fc1 -->|"feeds"| node_relu
node_relu -->|"feeds"| node_fc2
node_fc2 -->|"feeds"| node_softmax

click node_top "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/ANNfull.v"
click node_conv1 "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%201-%20Convolution/convLayerMulti.v"
click node_tanh1 "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/HyperBolicTangent.v"
click node_pool1 "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%204-%20Average%20Pooling/AvgPoolMulti.v"
click node_conv2 "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/IntegrationConvPart.v"
click node_tanh2 "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/HyperBolicTangent.v"
click node_pool2 "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%204-%20Average%20Pooling/AvgPoolMulti.v"
click node_conv3 "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/IntegrationConvPart.v"
click node_tanh3 "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/HyperBolicTangent.v"
click node_fc1 "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/InegrationFCpart.v"
click node_relu "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/activationFunction.v"
click node_fc2 "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/InegrationFCpart.v"
click node_softmax "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%203-%20SoftMax%20activation/softmax.v"
click node_convunit "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%201-%20Convolution/convUnit.v"
click node_processing "https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%201-%20Convolution/processingElement.v"
click node_weights "https://github.com/omarelhedaby/cnn-fpga/tree/master/Weight%20Files"

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_top toneBlue
class node_conv1,node_tanh1,node_pool1,node_conv2,node_tanh2,node_pool2,node_conv3,node_tanh3 toneAmber
class node_fc1,node_relu,node_fc2,node_softmax toneMint
class node_convunit,node_processing,node_weights toneRose
class node_mnist toneIndigo
```

## Components

### Network integration

- [CNN integration](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/ANNfull.v): `Final Code Files/Part 5- Integration/ANNfull.v`

### Feature extraction

- [Convolution 1](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%201-%20Convolution/convLayerMulti.v): `Final Code Files/Part 1- Convolution/convLayerMulti.v`
- [Tanh 1](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/HyperBolicTangent.v): `Final Code Files/Part 5- Integration/HyperBolicTangent.v`
- [Average pool 1](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%204-%20Average%20Pooling/AvgPoolMulti.v): `Final Code Files/Part 4- Average Pooling/AvgPoolMulti.v`
- [Convolution 2](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/IntegrationConvPart.v): `Final Code Files/Part 5- Integration/IntegrationConvPart.v`
- [Tanh 2](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/HyperBolicTangent.v): `Final Code Files/Part 5- Integration/HyperBolicTangent.v`
- [Average pool 2](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%204-%20Average%20Pooling/AvgPoolMulti.v): `Final Code Files/Part 4- Average Pooling/AvgPoolMulti.v`
- [Convolution 3](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/IntegrationConvPart.v): `Final Code Files/Part 5- Integration/IntegrationConvPart.v`
- [Tanh 3](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/HyperBolicTangent.v): `Final Code Files/Part 5- Integration/HyperBolicTangent.v`

### Classification

- [Fully connected 1](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/InegrationFCpart.v): `Final Code Files/Part 5- Integration/InegrationFCpart.v`
- [ReLU](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/activationFunction.v): `Final Code Files/Part 5- Integration/activationFunction.v`
- [Fully connected 2](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%205-%20Integration/InegrationFCpart.v): `Final Code Files/Part 5- Integration/InegrationFCpart.v`
- [SoftMax scores](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%203-%20SoftMax%20activation/softmax.v): `Final Code Files/Part 3- SoftMax activation/softmax.v`

### Numeric primitives

- [Convolution unit](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%201-%20Convolution/convUnit.v): `Final Code Files/Part 1- Convolution/convUnit.v`
- [Processing element](https://github.com/omarelhedaby/cnn-fpga/blob/master/Final%20Code%20Files/Part%201-%20Convolution/processingElement.v): `Final Code Files/Part 1- Convolution/processingElement.v`
- [Model parameters](https://github.com/omarelhedaby/cnn-fpga/tree/master/Weight%20Files): `Weight Files`

### Other components

- **MNIST image**

## Connections

- MNIST image → CNN integration: input
- CNN integration → Convolution 1: runs
- Convolution 1 → Tanh 1: convolves then activates (evidence: `README.md`)
- Tanh 1 → Average pool 1: feeds (evidence: `README.md`)
- Average pool 1 → Convolution 2: feeds (evidence: `README.md`)
- Convolution 2 → Tanh 2: convolves then activates (evidence: `README.md`)
- Tanh 2 → Average pool 2: feeds (evidence: `README.md`)
- Average pool 2 → Convolution 3: feeds (evidence: `README.md`)
- Convolution 3 → Tanh 3: convolves then activates (evidence: `README.md`)
- Tanh 3 → Fully connected 1: feeds (evidence: `README.md`)
- Fully connected 1 → ReLU: feeds (evidence: `README.md`)
- ReLU → Fully connected 2: feeds (evidence: `README.md`)
- Fully connected 2 → SoftMax scores: feeds (evidence: `README.md`)
