# pigrabbit/final_project architecture

> Architecture diagram of the GitHub repository pigrabbit/final_project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pigrabbit/final_project
- Repository: https://github.com/pigrabbit/final_project

## Overview

##### Main System Components

a) Hardware Architecture Layer:
- Convolution Module (CONV)
- Fully Connected Module (FC)
- Pooling Module (POOL)
- APB Interface Controllers
- AXI-Stream Data Path

b) Software Interface Layer:
- MNIST Project Implementation
- CIFAR10 Project Implementation
- Hardware Control Interface

**[Software Interface Layer]**
- ↕
**[APB/AXI Interface Layer]**
- ↕
**[Hardware Accelerator Layer]**

##### Detailed Component Representation

For the Hardware Accelerator Layer:
- Each block should show:
- Input BRAM
- Processing Elements (MAC units)
- Control Logic
- Output Buffers

For the FC Module (as specifically detailed in README):
- 8-bit MAC unit
- 32-input/32-weight parallel loading structure
- Partial sum accumulation path
- Bias addition unit

##### Interface Representations
- Memory interfaces with double lines
- Bit widths on data paths

##### Implementation Details
- A memory map showing BRAM organization
- Scaling and quantization units for 8-bit operations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Software_Layer
        MNIST_HW[Hardware Control]:::software
        MNIST_Layer[Layer Implementation]:::software
        MNIST_Bit[Bit Operations]:::software
        MNIST_Param[Network Parameters]:::software
        CIFAR_HW[Hardware Control]:::software
        CIFAR_Layer[Layer Implementation]:::software
        CIFAR_Bit[Bit Operations]:::software
    end

    subgraph Interface_Layer
        APB_FC[APB FC Controller]:::interface
        APB_CONV[APB CONV Controller]:::interface
        APB_POOL[APB POOL Controller]:::interface
        AXI_Stream[AXI-Stream Data Path]:::interface
    end

    subgraph Hardware_Layer
        subgraph CONV_Module
            CONV_Top[Top CONV]:::hardware
            CONV_Design[CONV Design]:::hardware
            CONV_MAC[MAC 3x3]:::hardware
            CONV_BRAM[Input BRAM]:::memory
        end

        subgraph FC_Module
            FC_Top[Top FC]:::hardware
            FC_Main[FC Main]:::hardware
            FC_MAC[MAC Unit]:::hardware
            FC_Accum[Accumulation Unit]:::hardware
            FC_BRAM[Input BRAM]:::memory
        end

        subgraph POOL_Module
            POOL_Top[Top POOL]:::hardware
            POOL_Main[POOL Main]:::hardware
            POOL_BRAM[Input BRAM]:::memory
        end
    end

    %% Software Layer Connections
    MNIST_HW --> APB_FC & APB_CONV & APB_POOL
    MNIST_Layer --> MNIST_HW
    MNIST_Bit --> MNIST_HW
    MNIST_Param --> MNIST_Layer
    CIFAR_HW --> APB_FC & APB_CONV & APB_POOL
    CIFAR_Layer --> CIFAR_HW
    CIFAR_Bit --> CIFAR_HW

    %% Interface Layer Connections
    APB_FC --> FC_Top
    APB_CONV --> CONV_Top
    APB_POOL --> POOL_Top
    AXI_Stream --> CONV_BRAM & FC_BRAM & POOL_BRAM

    %% Hardware Layer Internal Connections
    CONV_Top --> CONV_Design
    CONV_Design --> CONV_MAC
    CONV_BRAM --> CONV_Design

    FC_Top --> FC_Main
    FC_Main --> FC_MAC
    FC_MAC --> FC_Accum
    FC_BRAM --> FC_Main

    POOL_Top --> POOL_Main
    POOL_BRAM --> POOL_Main

    %% Styling
    classDef hardware fill:#2374f7,stroke:#333,stroke-width:2px
    classDef memory fill:#4CAF50,stroke:#333,stroke-width:2px
    classDef interface fill:#FFD700,stroke:#333,stroke-width:2px
    classDef software fill:#FF6B6B,stroke:#333,stroke-width:2px

    %% Click Events
    click CONV_Design "https://github.com/Pigrabbit/final_project/blob/master/verilog code/conv/CONV_DESIGN.v"
    click CONV_Top "https://github.com/Pigrabbit/final_project/blob/master/verilog code/conv/top_conv.v"
    click CONV_MAC "https://github.com/Pigrabbit/final_project/blob/master/verilog code/conv/mac3x3.v"
    click FC_Main "https://github.com/Pigrabbit/final_project/blob/master/verilog code/fc/fc.v"
    click FC_Top "https://github.com/Pigrabbit/final_project/blob/master/verilog code/fc/top_fc.v"
    click FC_MAC "https://github.com/Pigrabbit/final_project/blob/master/verilog code/fc/mac_fc.v"
    click FC_Accum "https://github.com/Pigrabbit/final_project/blob/master/verilog code/fc/accumulation_32.v"
    click POOL_Main "https://github.com/Pigrabbit/final_project/blob/master/verilog code/pool/pool.v"
    click POOL_Top "https://github.com/Pigrabbit/final_project/blob/master/verilog code/pool/top_pool.v"
    click APB_FC "https://github.com/Pigrabbit/final_project/blob/master/verilog code/apb/apb_fc.v"
    click APB_CONV "https://github.com/Pigrabbit/final_project/blob/master/verilog code/apb/apb_conv.v"
    click APB_POOL "https://github.com/Pigrabbit/final_project/blob/master/verilog code/apb/apb_pool.v"
    click MNIST_HW "https://github.com/Pigrabbit/final_project/blob/master/mnist_project/hwctrl_mnist.ipynb"
    click MNIST_Layer "https://github.com/Pigrabbit/final_project/blob/master/mnist_project/layers_mnist.py"
    click MNIST_Bit "https://github.com/Pigrabbit/final_project/blob/master/mnist_project/bitop_mnist.py"
    click MNIST_Param "https://github.com/Pigrabbit/final_project/blob/master/mnist_project/mnist_network_param/mnist.pt"
    click CIFAR_HW "https://github.com/Pigrabbit/final_project/blob/master/cifar10_project/hwctrl_cifar10.ipynb"
    click CIFAR_Layer "https://github.com/Pigrabbit/final_project/blob/master/cifar10_project/layers_cifar10.py"
    click CIFAR_Bit "https://github.com/Pigrabbit/final_project/blob/master/cifar10_project/bitop_cifar10.py"
```
