# hourfa/riscv-fpga-iot-teaching-kit architecture

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

- Interactive diagram: https://gitdiagram.com/hourfa/riscv-fpga-iot-teaching-kit
- Repository: https://github.com/hourfa/riscv-fpga-iot-teaching-kit

## Overview

This repository is a RISC-V/FPGA teaching kit whose substantial runtime product branches are camera/video I/O, face detection and recognition, and CNN acceleration. The user-facing flow is image or camera input through detection and recognition to displayed or saved results; LAB4 also supports hardware-accelerated inference. The README documents accelerator RTL capabilities, but RTL source files are absent from the supplied tree, so that subsystem is represented at its documented directory. Some LAB2/LAB4 stage implementations were not excerpted; edges to them are limited to documented or indexed relationships.

Main entry points: [`software/LAB3/cam.c`](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB3/cam.c) (Camera Controller), [`software/LAB4/benchmark_compare.c`](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/benchmark_compare.c) (SW/HW Benchmark), [`software/LAB2/Stage_1_Face_Detection_Image_Processing/main.c`](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB2/Stage_1_Face_Detection_Image_Processing/main.c) (Face Pipeline CLI), [`software/LAB4/main.c`](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/main.c) (Live Face App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_camera["Camera and Video I/O"]
  node_camera_app["Camera Controller<br/>[cam.c]"]
  node_sensor["OV5640 Sensor<br/>[ov5640.c]"]
  node_i2c["I²C Control<br/>[i2c_ctrl.c]"]
  node_vdma["VDMA Driver<br/>[vdma.c]"]
  node_framebuffer["Framebuffer<br/>[framebuffer.c]"]
end

subgraph group_faces["Face Pipeline"]
  node_face_cli["Face Pipeline CLI<br/>[main.c]"]
  node_detect2["Face Detection"]
  node_recognize2["Face Recognition"]
  node_preprocess["Image Preprocessing"]
  node_quant_model["Quantized Model Data<br/>[quantized_model.c]"]
  node_live_app["Live Face App<br/>[main.c]"]
  node_detect4["Face Detection Stage"]
  node_recognize4["Recognition Stage"]
  node_soft_cnn["Software CNN<br/>[stage2_software.c]"]
end

subgraph group_accel_sw["Accelerator Software"]
  node_accel_test["Inference Test App<br/>[main.c]"]
  node_cnn_model["CNN Model Runtime<br/>[cnn_model.c]"]
  node_driver["Accelerator Driver<br/>[accel_driver.c]"]
  node_benchmark["SW/HW Benchmark"]
end

subgraph group_accel_hw["Accelerator RTL"]
  node_rtl["CNN Accelerator RTL"]
end

node_operator(("Operator"))
node_input_image(("Image Input"))
node_soc["RISC-V SoC"]
node_display["Framebuffer Display"]

node_operator -->|"configures"| node_camera_app
node_camera_app -->|"controls"| node_sensor
node_sensor -->|"accesses registers"| node_i2c
node_camera_app -->|"initializes"| node_vdma
node_camera_app -->|"initializes"| node_framebuffer
node_camera_app -.->|"outputs video"| node_display
node_input_image -->|"provides image"| node_face_cli
node_face_cli -->|"detects faces"| node_detect2
node_face_cli -->|"recognizes faces"| node_recognize2
node_preprocess -.->|"prepares input"| node_face_cli
node_recognize2 -->|"uses model data"| node_quant_model
node_operator -->|"starts"| node_live_app
node_live_app -->|"runs detection"| node_detect4
node_live_app -->|"runs recognition"| node_recognize4
node_recognize4 -->|"uses software inference"| node_soft_cnn
node_recognize4 -->|"uses model data"| node_quant_model
node_operator -->|"starts inference"| node_accel_test
node_accel_test -->|"invokes inference"| node_cnn_model
node_cnn_model -->|"issues accelerator operations"| node_driver
node_driver -->|"controls accelerator"| node_rtl
node_rtl -->|"integrates with"| node_soc
node_operator -->|"runs comparison"| node_benchmark
node_benchmark -->|"runs hardware inference"| node_cnn_model
node_benchmark -->|"runs software inference"| node_soft_cnn
node_benchmark -->|"loads hardware data"| node_driver

click node_camera_app "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB3/cam.c"
click node_sensor "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB3/ov5640.c"
click node_i2c "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB3/i2c_ctrl.c"
click node_vdma "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB3/vdma.c"
click node_framebuffer "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB3/framebuffer.c"
click node_face_cli "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB2/Stage_1_Face_Detection_Image_Processing/main.c"
click node_detect2 "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB2/Stage_1_Face_Detection_Image_Processing/stage1_face_detection.c"
click node_recognize2 "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB2/Stage_1_Face_Detection_Image_Processing/stage2_face_recognition.c"
click node_preprocess "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB2/Stage_1_Face_Detection_Image_Processing/preprocess_image.py"
click node_quant_model "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB2/Stage_2_Face_Recognition_Model_CASIA/c_quantized_model/quantized_model.c"
click node_live_app "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/main.c"
click node_detect4 "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/stage1_face_detection.c"
click node_recognize4 "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/stage2_face_recognition.c"
click node_soft_cnn "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/stage2_software.c"
click node_accel_test "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/Acc/main.c"
click node_cnn_model "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/Acc/cnn_model.c"
click node_driver "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/Acc/accel_driver.c"
click node_benchmark "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/benchmark_compare.c"
click node_rtl "https://github.com/hourfa/riscv-fpga-iot-teaching-kit/tree/main/hardware/ai_accelerator"

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_camera_app,node_sensor,node_i2c,node_vdma,node_framebuffer toneBlue
class node_face_cli,node_detect2,node_recognize2,node_preprocess,node_quant_model,node_live_app,node_detect4,node_recognize4,node_soft_cnn toneAmber
class node_accel_test,node_cnn_model,node_driver,node_benchmark toneMint
class node_rtl toneRose
class node_operator,node_input_image,node_soc,node_display toneIndigo
```

## Components

### Camera and Video I/O

- [Camera Controller](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB3/cam.c): `software/LAB3/cam.c`
- [OV5640 Sensor](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB3/ov5640.c): `software/LAB3/ov5640.c`
- [I²C Control](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB3/i2c_ctrl.c): `software/LAB3/i2c_ctrl.c`
- [VDMA Driver](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB3/vdma.c): `software/LAB3/vdma.c`
- [Framebuffer](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB3/framebuffer.c): `software/LAB3/framebuffer.c`

### Face Pipeline

- [Face Pipeline CLI](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB2/Stage_1_Face_Detection_Image_Processing/main.c): `software/LAB2/Stage_1_Face_Detection_Image_Processing/main.c`
- [Face Detection](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB2/Stage_1_Face_Detection_Image_Processing/stage1_face_detection.c): `software/LAB2/Stage_1_Face_Detection_Image_Processing/stage1_face_detection.c`
- [Face Recognition](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB2/Stage_1_Face_Detection_Image_Processing/stage2_face_recognition.c): `software/LAB2/Stage_1_Face_Detection_Image_Processing/stage2_face_recognition.c`
- [Image Preprocessing](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB2/Stage_1_Face_Detection_Image_Processing/preprocess_image.py): `software/LAB2/Stage_1_Face_Detection_Image_Processing/preprocess_image.py`
- [Quantized Model Data](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB2/Stage_2_Face_Recognition_Model_CASIA/c_quantized_model/quantized_model.c): `software/LAB2/Stage_2_Face_Recognition_Model_CASIA/c_quantized_model/quantized_model.c`
- [Live Face App](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/main.c): `software/LAB4/main.c`
- [Face Detection Stage](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/stage1_face_detection.c): `software/LAB4/stage1_face_detection.c`
- [Recognition Stage](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/stage2_face_recognition.c): `software/LAB4/stage2_face_recognition.c`
- [Software CNN](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/stage2_software.c): `software/LAB4/stage2_software.c`

### Accelerator Software

- [Inference Test App](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/Acc/main.c): `software/LAB4/Acc/main.c`
- [CNN Model Runtime](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/Acc/cnn_model.c): `software/LAB4/Acc/cnn_model.c`
- [Accelerator Driver](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/Acc/accel_driver.c): `software/LAB4/Acc/accel_driver.c`
- [SW/HW Benchmark](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/blob/main/software/LAB4/benchmark_compare.c): `software/LAB4/benchmark_compare.c`

### Accelerator RTL

- [CNN Accelerator RTL](https://github.com/hourfa/riscv-fpga-iot-teaching-kit/tree/main/hardware/ai_accelerator): `hardware/ai_accelerator`

### Other components

- **Operator**
- **Image Input**
- **RISC-V SoC**
- **Framebuffer Display**

## Connections

- Operator → Camera Controller: configures (evidence: `software/LAB3/cam.c`)
- Camera Controller → OV5640 Sensor: controls (evidence: `software/LAB3/cam.c`)
- OV5640 Sensor → I²C Control: accesses registers (evidence: `software/LAB3/ov5640.c`)
- Camera Controller → VDMA Driver: initializes (evidence: `software/LAB3/cam.c`)
- Camera Controller → Framebuffer: initializes (evidence: `software/LAB3/cam.c`)
- Camera Controller → Framebuffer Display: outputs video (evidence: `README.md`)
- Image Input → Face Pipeline CLI: provides image (evidence: `software/LAB2/Stage_1_Face_Detection_Image_Processing/main.c`)
- Face Pipeline CLI → Face Detection: detects faces (evidence: `software/LAB2/Stage_1_Face_Detection_Image_Processing/main.c`)
- Face Pipeline CLI → Face Recognition: recognizes faces (evidence: `README.md`)
- Image Preprocessing → Face Pipeline CLI: prepares input
- Face Recognition → Quantized Model Data: uses model data
- Operator → Live Face App: starts (evidence: `software/LAB4/main.c`)
- Live Face App → Face Detection Stage: runs detection (evidence: `README.md`)
- Live Face App → Recognition Stage: runs recognition (evidence: `README.md`)
- Recognition Stage → Software CNN: uses software inference
- Recognition Stage → Quantized Model Data: uses model data
- Operator → Inference Test App: starts inference (evidence: `software/LAB4/Acc/main.c`)
- Inference Test App → CNN Model Runtime: invokes inference (evidence: `software/LAB4/Acc/main.c`)
- CNN Model Runtime → Accelerator Driver: issues accelerator operations
- Accelerator Driver → CNN Accelerator RTL: controls accelerator (evidence: `README.md`)
- CNN Accelerator RTL → RISC-V SoC: integrates with (evidence: `README.md`)
- Operator → SW/HW Benchmark: runs comparison (evidence: `software/LAB4/benchmark_compare.c`)
- SW/HW Benchmark → CNN Model Runtime: runs hardware inference (evidence: `software/LAB4/benchmark_compare.c`)
- SW/HW Benchmark → Software CNN: runs software inference (evidence: `software/LAB4/benchmark_compare.c`)
- SW/HW Benchmark → Accelerator Driver: loads hardware data (evidence: `software/LAB4/benchmark_compare.c`)
