# amd/mini-isp architecture

> Architecture diagram of the GitHub repository amd/mini-isp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amd/mini-isp
- Repository: https://github.com/amd/mini-isp

## Overview

1. **What this repo is**
   Mini-ISP is a hardware-first image signal processor for AMD FPGA/SoC targets. The core product is synthesizable RTL, with a Python reference/modeling layer used for algorithm prototyping, coefficient generation, and verification.

2. **Primary architectural boundary: Python vs RTL**
   The repository is split into two main implementation domains:
   - `rtl/`: the synthesizable ISP and its support IP
   - `python/`: software models, test harnesses, and tooling around the ISP
   This separation is the key architecture boundary for any diagram.

3. **Streaming image-processing datapath**
   The RTL core is built as a streaming pipeline around AXI4-Stream Video-style pixel flow. The top-level ISP assembly appears in `rtl/isp.sv` and is wrapped for integration by `rtl/isp_top.v`. The data path is designed for low-latency, fully pipelined operation with configurable pixel-per-clock throughput.

4. **Implemented ISP stages**
   The core image-processing blocks in RTL include decompanding, black level correction, digital color gain, demosaic, color correction matrix, and gamma. Supporting RTL modules such as line buffers, LUTs, and histogram/contrast helpers exist to serve those stages and to support future/optional functionality.

5. **Control plane and register interface**
   Configuration is separated from pixel data flow through an AXI4-Lite register interface implemented in `rtl/axi_lite_register.sv`. This is the control boundary for setting coefficients, mode bits, and runtime parameters without interrupting the streaming datapath.

6. **Reusable RTL infrastructure**
   The `rtl/` directory also contains reusable building blocks used across the pipeline: RAM/ROM wrappers, skid buffers, dividers, sqrt/log-style helpers, PRNG, and lookup-table support. These are not the ISP stages themselves, but the hardware primitives that make the streaming implementation practical and resource-efficient.

7. **Python algorithm/model layer**
   `python/mini_isp/` mirrors the ISP feature set in software. It contains modules for auto exposure, auto white balance, black level correction, color correction, color space conversion, decompanding, demosaic, gamma, lens shading, tone mapping, and statistics/percentile utilities. This layer is the reference side of the architecture.

8. **Python’s role in the workflow**
   The Python scripts in `python/` are used for calibration, coefficient derivation, scene handling, raw-file experimentation, and LUT export. In architecture terms, Python is the “analysis and preparation” layer that produces parameters and expected behavior consumed by RTL and tests.

9. **Verification and simulation**
   The `python/tb/` package contains focused test benches for individual RTL blocks and system-level ISP behavior. The repo’s test flow is centered on Verilator-based simulation, with Python tests in `python/test/` covering pure software helpers and math utilities. This makes the Python layer both a reference model and a verification harness.

10. **Build, synthesis, and packaging**
   The root `Makefile`, `pyproject.toml`, and `vivado/package.tcl` define the project’s build surfaces. The repo supports simulation, Python testing, synthesis, documentation generation, and Vivado packaging, so the architecture spans both software tooling and FPGA IP delivery.

11. **Reproducible development environment**
   A Dockerfile, devcontainer config, and GitHub Actions workflows provide a controlled environment for linting, simulation, synthesis, Docker builds, and docs generation. This matters architecturally because the project is intended to be reproducible across development and CI, not just locally.

12. **Documentation and external interface expectations**
   The `docs/` tree documents the ISP pipeline and usage, while the README frames the intended external integration points: AXI4-Lite for control and AXI4-Stream Video for pixel ingress/egress. Any architecture diagram should show Mini-ISP as a streaming FPGA IP block surrounded by a software modeling/test toolchain.

Main entry points: [`rtl/isp.sv`](https://github.com/amd/mini-isp/blob/main/rtl/isp.sv) (ISP core), [`python/mini_isp`](https://github.com/amd/mini-isp/tree/main/python/mini_isp) (Python ISP), [`Makefile`](https://github.com/amd/mini-isp/tree/main/Makefile) (Build entry), [`rtl/isp_top.v`](https://github.com/amd/mini-isp/blob/main/rtl/isp_top.v) (ISP top)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_rtl["RTL datapath"]
  node_n_isp_top["ISP top<br/>RTL wrapper<br/>[isp_top.v]"]
  node_n_isp_core["ISP core<br/>Streaming pipeline<br/>[isp.sv]"]
  node_n_ctrl["AXI-Lite reg<br/>Control plane"]
  node_n_stage1["Front-end<br/>Pixel conditioning"]
  node_n_stage2["Image core<br/>Color pipeline"]
  node_n_stage3["Tone end<br/>Output shaping"]
  node_n_hw_util["RTL utils<br/>Shared primitives"]
  node_n_bitmath["Bit math<br/>Approximation blocks<br/>[bitlog.sv]"]
end

subgraph group_grp_py["Python layer"]
  node_n_python_ref["Python ISP<br/>Reference model"]
  node_n_py_calib["Calibration<br/>Analysis tools"]
  node_n_py_tb["Py testbenches<br/>Simulation harness"]
  node_n_py_tests["Py unit tests<br/>Software tests"]
  node_n_py_scripts["Python tools<br/>Scripts<br/>[axis_video.py]"]
end

subgraph group_grp_tooling["Tooling"]
  node_n_build["Build entry<br/>Project build"]
  node_n_pyproj["Python pkg<br/>Packaging<br/>[pyproject.toml]"]
  node_n_vivado["Vivado pkg<br/>FPGA packaging<br/>[package.tcl]"]
  node_n_docs["Docs<br/>Documentation<br/>[isp.md]"]
  node_n_ci["CI/CD<br/>Automation<br/>[cicd.yml]"]
  node_n_dev["Dev env<br/>Reproducible setup"]
end

node_n_isp_top -->|"wraps"| node_n_isp_core
node_n_isp_core -->|"configures"| node_n_ctrl
node_n_isp_core -->|"feeds"| node_n_stage1
node_n_isp_core -->|"processes"| node_n_stage2
node_n_isp_core -->|"finishes"| node_n_stage3
node_n_stage1 -->|"uses"| node_n_hw_util
node_n_stage2 -->|"uses"| node_n_hw_util
node_n_stage3 -->|"uses"| node_n_hw_util
node_n_hw_util -->|"includes"| node_n_bitmath
node_n_python_ref -->|"mirrors"| node_n_stage1
node_n_python_ref -->|"mirrors"| node_n_stage2
node_n_python_ref -->|"mirrors"| node_n_stage3
node_n_py_calib -->|"produces"| node_n_python_ref
node_n_py_calib -.->|"informs"| node_n_docs
node_n_py_tb -->|"verifies"| node_n_isp_core
node_n_py_tests -->|"checks"| node_n_python_ref
node_n_py_scripts -->|"supports"| node_n_python_ref
node_n_build -->|"builds"| node_n_isp_top
node_n_build -->|"runs"| node_n_py_tests
node_n_pyproj -->|"packages"| node_n_python_ref
node_n_vivado -->|"packages"| node_n_isp_top
node_n_ci -->|"automates"| node_n_build
node_n_ci -->|"standardizes"| node_n_dev
node_n_docs -->|"documents"| node_n_isp_core
node_n_dev -->|"supports"| node_n_build

click node_n_isp_top "https://github.com/amd/mini-isp/blob/main/rtl/isp_top.v"
click node_n_isp_core "https://github.com/amd/mini-isp/blob/main/rtl/isp.sv"
click node_n_ctrl "https://github.com/amd/mini-isp/blob/main/rtl/axi_lite_register.sv"
click node_n_bitmath "https://github.com/amd/mini-isp/blob/main/rtl/bitlog.sv"
click node_n_python_ref "https://github.com/amd/mini-isp/tree/main/python/mini_isp"
click node_n_py_calib "https://github.com/amd/mini-isp/blob/main/python/find_coefficients.py"
click node_n_py_tb "https://github.com/amd/mini-isp/tree/main/python/tb"
click node_n_py_tests "https://github.com/amd/mini-isp/tree/main/python/test"
click node_n_py_scripts "https://github.com/amd/mini-isp/blob/main/python/axis_video.py"
click node_n_build "https://github.com/amd/mini-isp/tree/main/Makefile"
click node_n_pyproj "https://github.com/amd/mini-isp/blob/main/pyproject.toml"
click node_n_vivado "https://github.com/amd/mini-isp/blob/main/vivado/package.tcl"
click node_n_docs "https://github.com/amd/mini-isp/blob/main/docs/isp.md"
click node_n_ci "https://github.com/amd/mini-isp/blob/main/.github/workflows/cicd.yml"
click node_n_dev "https://github.com/amd/mini-isp/tree/main/docker/Dockerfile"

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_n_isp_top,node_n_isp_core,node_n_ctrl,node_n_stage1,node_n_stage2,node_n_stage3,node_n_hw_util,node_n_bitmath toneBlue
class node_n_python_ref,node_n_py_calib,node_n_py_tb,node_n_py_tests,node_n_py_scripts toneAmber
class node_n_build,node_n_pyproj,node_n_vivado,node_n_docs,node_n_ci,node_n_dev toneMint
```

## Components

### RTL datapath

Synthesizable ISP pipeline and reusable hardware blocks.

- [ISP top](https://github.com/amd/mini-isp/blob/main/rtl/isp_top.v): RTL wrapper · Top-level integration wrapper for the streaming ISP block. · `rtl/isp_top.v`
- [ISP core](https://github.com/amd/mini-isp/blob/main/rtl/isp.sv): Streaming pipeline · Main AXI4-Stream image-processing datapath assembly. · `rtl/isp.sv`
- [AXI-Lite reg](https://github.com/amd/mini-isp/blob/main/rtl/axi_lite_register.sv): Control plane · Register interface for configuration and runtime control. · `rtl/axi_lite_register.sv`
- **Front-end**: Pixel conditioning · Decompanding, black level correction, and digital color gain.
- **Image core**: Color pipeline · Demosaic and color matrix conversion stages.
- **Tone end**: Output shaping · Gamma and contrast/histogram-based finishing stages.
- **RTL utils**: Shared primitives · Line buffers, RAM/ROMs, LUTs, dividers, sqrt/log helpers, skid buffers, and PRNG.
- [Bit math](https://github.com/amd/mini-isp/blob/main/rtl/bitlog.sv): Approximation blocks · Specialized bitlog/bitsqrt and related arithmetic support blocks. · `rtl/bitlog.sv`

### Python layer

Reference models, calibration tools, and verification harnesses.

- [Python ISP](https://github.com/amd/mini-isp/tree/main/python/mini_isp): Reference model · Software mirror of the ISP feature set for prototyping and validation. · `python/mini_isp`
- [Calibration](https://github.com/amd/mini-isp/blob/main/python/find_coefficients.py): Analysis tools · Coefficient derivation, scene handling, raw experimentation, and LUT export. · `python/find_coefficients.py`
- [Py testbenches](https://github.com/amd/mini-isp/tree/main/python/tb): Simulation harness · Focused RTL test benches and Verilator-based system simulation support. · `python/tb`
- [Py unit tests](https://github.com/amd/mini-isp/tree/main/python/test): Software tests · Pure Python tests for helper math and color conversion utilities. · `python/test`
- [Python tools](https://github.com/amd/mini-isp/blob/main/python/axis_video.py): Scripts · Standalone helpers for axis-video handling, raw-file testing, tone mapping, and color transforms. · `python/axis_video.py`

### Tooling

Build, packaging, docs, CI, and reproducible development environment.

- [Build entry](https://github.com/amd/mini-isp/tree/main/Makefile): Project build · Root build surface for simulation, testing, synthesis, and docs workflows. · `Makefile`
- [Python pkg](https://github.com/amd/mini-isp/blob/main/pyproject.toml): Packaging · Python project metadata and dependency specification. · `pyproject.toml`
- [Vivado pkg](https://github.com/amd/mini-isp/blob/main/vivado/package.tcl): FPGA packaging · Vivado packaging script for delivering the ISP as FPGA IP. · `vivado/package.tcl`
- [Docs](https://github.com/amd/mini-isp/blob/main/docs/isp.md): Documentation · User and architecture documentation for the ISP pipeline and usage. · `docs/isp.md`
- [CI/CD](https://github.com/amd/mini-isp/blob/main/.github/workflows/cicd.yml): Automation · GitHub Actions workflows for linting, simulation, synthesis, Docker builds, and docs. · `.github/workflows/cicd.yml`
- [Dev env](https://github.com/amd/mini-isp/tree/main/docker/Dockerfile): Reproducible setup · Container and devcontainer setup for consistent local development. · `docker/Dockerfile`

## Connections

- ISP top → ISP core: wraps · Integration wrapper instantiates the core pipeline.
- ISP core → AXI-Lite reg: configures · Registers provide runtime control of the streaming datapath.
- ISP core → Front-end: feeds · Front-end conditioning prepares raw pixels.
- ISP core → Image core: processes · Core color stages transform the image stream.
- ISP core → Tone end: finishes · Final stages shape output tone and contrast.
- Front-end → RTL utils: uses · Front-end stages rely on shared LUTs and arithmetic helpers.
- Image core → RTL utils: uses · Color pipeline stages use common RTL infrastructure.
- Tone end → RTL utils: uses · Tone and histogram logic reuse shared primitives.
- RTL utils → Bit math: includes · Utility layer includes specialized bit-level math blocks.
- Python ISP → Front-end: mirrors · Python models correspond to RTL front-end algorithms.
- Python ISP → Image core: mirrors · Python models correspond to color pipeline algorithms.
- Python ISP → Tone end: mirrors · Python models correspond to tone and gamma behavior.
- Calibration → Python ISP: produces · Calibration scripts derive coefficients and LUTs for the model and RTL.
- Calibration → Docs: informs · Analysis outputs support usage and pipeline documentation.
- Py testbenches → ISP core: verifies · Python testbenches exercise RTL blocks and system behavior.
- Py unit tests → Python ISP: checks · Unit tests validate pure Python helpers and math utilities.
- Python tools → Python ISP: supports · Standalone scripts provide analysis and conversion tooling around the models.
- Build entry → ISP top: builds · Make-driven flow drives RTL simulation and synthesis entry points.
- Build entry → Py unit tests: runs · Project build surface includes Python test execution.
- Python pkg → Python ISP: packages · Python project metadata packages the model/tooling layer.
- Vivado pkg → ISP top: packages · Vivado packaging targets the FPGA integration wrapper.
- CI/CD → Build entry: automates · CI orchestrates builds, tests, synthesis, and docs generation.
- CI/CD → Dev env: standardizes · CI is aligned with containerized development environments.
- Docs → ISP core: documents · Docs explain the streaming ISP pipeline and external interfaces.
- Dev env → Build entry: supports · Development container supports reproducible builds and verification.
