# google-coral/coralnpu architecture

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

- Interactive diagram: https://gitdiagram.com/google-coral/coralnpu
- Repository: https://github.com/google-coral/coralnpu

## Overview

Coral NPU is a RISC-V machine-learning accelerator IP, with scalar, vector, and matrix processing, on-chip memories, and AXI integration. Its principal runtime path is software issuing ML work to the processor, which accesses memory and system buses; the tree also shows a distinct DMA subsystem, optimized LiteRT Micro kernels, FPGA boot support, simulation, and verification utilities. The excerpts establish selected DMA behavior, FPGA loading, and simulation helpers, but not the complete processor-to-software execution wiring, so those links are omitted rather than inferred.

Main entry points: [`sw/utils/tflite_runner/tflite_runner.cc`](https://github.com/google-coral/coralnpu/blob/main/sw/utils/tflite_runner/tflite_runner.cc) (LiteRT Micro runner), [`hdl/chisel/src/coralnpu/scalar/SCore.scala`](https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/coralnpu/scalar/SCore.scala) (Scalar core), [`hdl/chisel/src/soc/CoralNPUChiselSubsystem.scala`](https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/soc/CoralNPUChiselSubsystem.scala) (SoC subsystem), [`hdl/chisel/src/bus/DmaEngine.scala`](https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/bus/DmaEngine.scala) (DMA engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compute["NPU compute"]
  node_processor["Scalar core<br/>[SCore.scala]"]
  node_vector["Vector core<br/>[RvvCore.scala]"]
  node_float["Floating-point core<br/>[FloatCore.scala]"]
end

subgraph group_fabric["Memory and fabric"]
  node_memory["Tightly-coupled memories<br/>[TCM.scala]"]
  node_axi["AXI interfaces<br/>[CoreAxi.scala]"]
  node_soc["SoC subsystem"]
  node_dma["DMA engine<br/>[DmaEngine.scala]"]
  node_fill["DMA fill engine"]
  node_drain["DMA drain engine"]
end

subgraph group_software["ML software"]
  node_tflite["LiteRT Micro runner<br/>[tflite_runner.cc]"]
  node_conv["Convolution kernels<br/>[conv.cc]"]
  node_otherkernels["Other optimized kernels"]
end

subgraph group_platform["FPGA platform"]
  node_fpga["FPGA simulation host<br/>[main.cc]"]
  node_boot["ROM boot loader<br/>[main.c]"]
  node_flash["SPI flash driver<br/>[spi_flash.c]"]
  node_loader["FTDI Nexus loader<br/>[main.cc]"]
  node_spi["Loader SPI master<br/>[spi_master.cc]"]
end

subgraph group_validation["Simulation and verification"]
  node_spike["Spike simulator<br/>[spike_simulator.cc]"]
  node_sim["Core simulator"]
  node_siminterface["Simulator interface"]
  node_backdoor["Memory backdoor<br/>[backdoor.py]"]
  node_dispatch["Dispatch verifier<br/>[monitor.py]"]
end

node_developer(("Software integrator"))
node_flashdevice[("SPI flash device")]
node_host(("Simulation host"))

node_developer -.->|"runs inference"| node_tflite
node_processor -.->|"dispatches work"| node_vector
node_processor -.->|"uses operations"| node_float
node_soc -.->|"integrates memories"| node_memory
node_soc -.->|"exposes interfaces"| node_axi
node_dma -.->|"coordinates fill"| node_fill
node_dma -.->|"coordinates drain"| node_drain
node_tflite -->|"uses kernels"| node_conv
node_tflite -->|"uses kernels"| node_otherkernels
node_sim -.->|"drives simulation"| node_siminterface
node_siminterface -->|"uses backdoor"| node_backdoor
node_host -.->|"checks dispatch"| node_dispatch
node_fpga -->|"loads ELF through"| node_backdoor
node_boot -->|"reads flash"| node_flash
node_flashdevice -.->|"provides image"| node_boot
node_loader -->|"transfers via"| node_spi
node_spi -.->|"programs device"| node_flashdevice
node_spike -.->|"models execution"| node_processor

click node_processor "https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/coralnpu/scalar/SCore.scala"
click node_vector "https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/coralnpu/rvv/RvvCore.scala"
click node_float "https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/coralnpu/float/FloatCore.scala"
click node_memory "https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/coralnpu/TCM.scala"
click node_axi "https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/coralnpu/CoreAxi.scala"
click node_soc "https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/soc/CoralNPUChiselSubsystem.scala"
click node_dma "https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/bus/DmaEngine.scala"
click node_fill "https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/dma/DmaFillEngine.scala"
click node_drain "https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/dma/DmaDrainEngine.scala"
click node_tflite "https://github.com/google-coral/coralnpu/blob/main/sw/utils/tflite_runner/tflite_runner.cc"
click node_conv "https://github.com/google-coral/coralnpu/blob/main/sw/opt/litert-micro/conv.cc"
click node_otherkernels "https://github.com/google-coral/coralnpu/tree/main/sw/opt/litert-micro"
click node_spike "https://github.com/google-coral/coralnpu/blob/main/sw/coralnpu_sim/spike_simulator.cc"
click node_sim "https://github.com/google-coral/coralnpu/blob/main/hw_sim/core_mini_axi_simulator.cc"
click node_siminterface "https://github.com/google-coral/coralnpu/blob/main/coralnpu_test_utils/core_mini_axi_interface.py"
click node_backdoor "https://github.com/google-coral/coralnpu/blob/main/coralnpu_test_utils/backdoor.py"
click node_dispatch "https://github.com/google-coral/coralnpu/blob/main/coralnpu_test_utils/dispatch_verifier/monitor.py"
click node_fpga "https://github.com/google-coral/coralnpu/blob/main/fpga/main.cc"
click node_boot "https://github.com/google-coral/coralnpu/blob/main/fpga/sw/rom_boot/main.c"
click node_flash "https://github.com/google-coral/coralnpu/blob/main/fpga/sw/spi_flash.c"
click node_loader "https://github.com/google-coral/coralnpu/blob/main/sw/utils/nexus_loader/main.cc"
click node_spi "https://github.com/google-coral/coralnpu/blob/main/sw/utils/nexus_loader/spi_master.cc"

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_processor,node_vector,node_float toneBlue
class node_memory,node_axi,node_soc,node_dma,node_fill,node_drain,node_flashdevice toneAmber
class node_tflite,node_conv,node_otherkernels toneMint
class node_fpga,node_boot,node_flash,node_loader,node_spi toneRose
class node_spike,node_sim,node_siminterface,node_backdoor,node_dispatch,node_developer,node_host toneIndigo
```

## Components

### NPU compute

- [Scalar core](https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/coralnpu/scalar/SCore.scala): `hdl/chisel/src/coralnpu/scalar/SCore.scala`
- [Vector core](https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/coralnpu/rvv/RvvCore.scala): `hdl/chisel/src/coralnpu/rvv/RvvCore.scala`
- [Floating-point core](https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/coralnpu/float/FloatCore.scala): `hdl/chisel/src/coralnpu/float/FloatCore.scala`

### Memory and fabric

- [Tightly-coupled memories](https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/coralnpu/TCM.scala): `hdl/chisel/src/coralnpu/TCM.scala`
- [AXI interfaces](https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/coralnpu/CoreAxi.scala): `hdl/chisel/src/coralnpu/CoreAxi.scala`
- [SoC subsystem](https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/soc/CoralNPUChiselSubsystem.scala): `hdl/chisel/src/soc/CoralNPUChiselSubsystem.scala`
- [DMA engine](https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/bus/DmaEngine.scala): `hdl/chisel/src/bus/DmaEngine.scala`
- [DMA fill engine](https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/dma/DmaFillEngine.scala): `hdl/chisel/src/dma/DmaFillEngine.scala`
- [DMA drain engine](https://github.com/google-coral/coralnpu/blob/main/hdl/chisel/src/dma/DmaDrainEngine.scala): `hdl/chisel/src/dma/DmaDrainEngine.scala`

### ML software

- [LiteRT Micro runner](https://github.com/google-coral/coralnpu/blob/main/sw/utils/tflite_runner/tflite_runner.cc): `sw/utils/tflite_runner/tflite_runner.cc`
- [Convolution kernels](https://github.com/google-coral/coralnpu/blob/main/sw/opt/litert-micro/conv.cc): `sw/opt/litert-micro/conv.cc`
- [Other optimized kernels](https://github.com/google-coral/coralnpu/tree/main/sw/opt/litert-micro): `sw/opt/litert-micro`

### FPGA platform

- [FPGA simulation host](https://github.com/google-coral/coralnpu/blob/main/fpga/main.cc): `fpga/main.cc`
- [ROM boot loader](https://github.com/google-coral/coralnpu/blob/main/fpga/sw/rom_boot/main.c): `fpga/sw/rom_boot/main.c`
- [SPI flash driver](https://github.com/google-coral/coralnpu/blob/main/fpga/sw/spi_flash.c): `fpga/sw/spi_flash.c`
- [FTDI Nexus loader](https://github.com/google-coral/coralnpu/blob/main/sw/utils/nexus_loader/main.cc): `sw/utils/nexus_loader/main.cc`
- [Loader SPI master](https://github.com/google-coral/coralnpu/blob/main/sw/utils/nexus_loader/spi_master.cc): `sw/utils/nexus_loader/spi_master.cc`

### Simulation and verification

- [Spike simulator](https://github.com/google-coral/coralnpu/blob/main/sw/coralnpu_sim/spike_simulator.cc): `sw/coralnpu_sim/spike_simulator.cc`
- [Core simulator](https://github.com/google-coral/coralnpu/blob/main/hw_sim/core_mini_axi_simulator.cc): `hw_sim/core_mini_axi_simulator.cc`
- [Simulator interface](https://github.com/google-coral/coralnpu/blob/main/coralnpu_test_utils/core_mini_axi_interface.py): `coralnpu_test_utils/core_mini_axi_interface.py`
- [Memory backdoor](https://github.com/google-coral/coralnpu/blob/main/coralnpu_test_utils/backdoor.py): `coralnpu_test_utils/backdoor.py`
- [Dispatch verifier](https://github.com/google-coral/coralnpu/blob/main/coralnpu_test_utils/dispatch_verifier/monitor.py): `coralnpu_test_utils/dispatch_verifier/monitor.py`

### Other components

- **Software integrator**
- **SPI flash device**
- **Simulation host**

## Connections

- Software integrator → LiteRT Micro runner: runs inference
- Scalar core → Vector core: dispatches work
- Scalar core → Floating-point core: uses operations
- SoC subsystem → Tightly-coupled memories: integrates memories
- SoC subsystem → AXI interfaces: exposes interfaces
- DMA engine → DMA fill engine: coordinates fill
- DMA engine → DMA drain engine: coordinates drain
- LiteRT Micro runner → Convolution kernels: uses kernels (evidence: `sw/utils/tflite_runner/tflite_runner.cc`)
- LiteRT Micro runner → Other optimized kernels: uses kernels (evidence: `sw/utils/tflite_runner/tflite_runner.cc`)
- Core simulator → Simulator interface: drives simulation
- Simulator interface → Memory backdoor: uses backdoor (evidence: `coralnpu_test_utils/core_mini_axi_interface.py`)
- Simulation host → Dispatch verifier: checks dispatch
- FPGA simulation host → Memory backdoor: loads ELF through (evidence: `fpga/main.cc`)
- ROM boot loader → SPI flash driver: reads flash (evidence: `fpga/sw/rom_boot/main.c`)
- SPI flash device → ROM boot loader: provides image
- FTDI Nexus loader → Loader SPI master: transfers via (evidence: `sw/utils/nexus_loader/main.cc`)
- Loader SPI master → SPI flash device: programs device
- Spike simulator → Scalar core: models execution
