# adam-maj/tiny-gpu architecture

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

- Interactive diagram: https://gitdiagram.com/adam-maj/tiny-gpu
- Repository: https://github.com/adam-maj/tiny-gpu

## Overview

tiny-gpu is a learning-oriented Verilog GPU, not a general-purpose graphics stack. Its documented workflow is to load kernel instructions and data, configure a thread count, and launch execution; the dispatcher assigns blocks to cores, where threads execute instructions through fetch, decode, register, arithmetic, and load/store resources. The README also describes external memory controllers and a work-in-progress cache. No source excerpts were supplied, so the graph reflects documented relationships only; module-to-responsibility mappings follow filenames and README architecture descriptions.

Main entry points: [`src/scheduler.sv`](https://github.com/adam-maj/tiny-gpu/blob/master/src/scheduler.sv) (Scheduler), [`src/gpu.sv`](https://github.com/adam-maj/tiny-gpu/blob/master/src/gpu.sv) (GPU top), [`src/controller.sv`](https://github.com/adam-maj/tiny-gpu/blob/master/src/controller.sv) (Memory controllers), [`src/dispatch.sv`](https://github.com/adam-maj/tiny-gpu/blob/master/src/dispatch.sv) (Dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Device control"]
  node_gpu["GPU top<br/>[gpu.sv]"]
  node_dcr["Device control<br/>[dcr.sv]"]
  node_dispatch["Dispatcher<br/>[dispatch.sv]"]
end

subgraph group_core["Core execution"]
  node_core["Compute core<br/>[core.sv]"]
  node_scheduler["Scheduler<br/>[scheduler.sv]"]
  node_fetcher["Instruction fetcher<br/>[fetcher.sv]"]
  node_decoder["Instruction decoder<br/>[decoder.sv]"]
  node_registers[("Thread registers<br/>[registers.sv]")]
  node_alu["Thread ALU<br/>[alu.sv]"]
  node_lsu["Thread LSU<br/>[lsu.sv]"]
  node_pc["Program counter<br/>[pc.sv]"]
end

subgraph group_memory["Memory system"]
  node_controller["Memory controllers<br/>[controller.sv]"]
  node_cache["Cache &#40;WIP&#41;"]
  node_memory[("External global memory")]
end

node_host(("Kernel host"))

node_host -->|"loads and launches"| node_gpu
node_host -->|"sets thread count"| node_dcr
node_gpu -->|"starts execution"| node_dispatch
node_gpu -->|"interfaces memory"| node_controller
node_dispatch -->|"assigns blocks"| node_core
node_core -->|"manages execution"| node_scheduler
node_scheduler -->|"fetches instructions"| node_fetcher
node_fetcher -->|"reads program memory"| node_memory
node_scheduler -->|"decodes instruction"| node_decoder
node_scheduler -->|"executes per thread"| node_registers
node_scheduler -->|"issues arithmetic"| node_alu
node_scheduler -->|"issues memory access"| node_lsu
node_scheduler -->|"tracks instruction position"| node_pc
node_lsu -->|"requests data access"| node_controller
node_controller -->|"relays requests"| node_memory
node_memory -.->|"stores fetched data"| node_cache

click node_gpu "https://github.com/adam-maj/tiny-gpu/blob/master/src/gpu.sv"
click node_dcr "https://github.com/adam-maj/tiny-gpu/blob/master/src/dcr.sv"
click node_dispatch "https://github.com/adam-maj/tiny-gpu/blob/master/src/dispatch.sv"
click node_core "https://github.com/adam-maj/tiny-gpu/blob/master/src/core.sv"
click node_controller "https://github.com/adam-maj/tiny-gpu/blob/master/src/controller.sv"
click node_scheduler "https://github.com/adam-maj/tiny-gpu/blob/master/src/scheduler.sv"
click node_fetcher "https://github.com/adam-maj/tiny-gpu/blob/master/src/fetcher.sv"
click node_decoder "https://github.com/adam-maj/tiny-gpu/blob/master/src/decoder.sv"
click node_registers "https://github.com/adam-maj/tiny-gpu/blob/master/src/registers.sv"
click node_alu "https://github.com/adam-maj/tiny-gpu/blob/master/src/alu.sv"
click node_lsu "https://github.com/adam-maj/tiny-gpu/blob/master/src/lsu.sv"
click node_pc "https://github.com/adam-maj/tiny-gpu/blob/master/src/pc.sv"

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_gpu,node_dcr,node_dispatch toneBlue
class node_core,node_scheduler,node_fetcher,node_decoder,node_registers,node_alu,node_lsu,node_pc toneAmber
class node_controller,node_cache,node_memory toneMint
class node_host toneIndigo
```

## Components

### Device control

- [GPU top](https://github.com/adam-maj/tiny-gpu/blob/master/src/gpu.sv): `src/gpu.sv`
- [Device control](https://github.com/adam-maj/tiny-gpu/blob/master/src/dcr.sv): `src/dcr.sv`
- [Dispatcher](https://github.com/adam-maj/tiny-gpu/blob/master/src/dispatch.sv): `src/dispatch.sv`

### Core execution

- [Compute core](https://github.com/adam-maj/tiny-gpu/blob/master/src/core.sv): `src/core.sv`
- [Scheduler](https://github.com/adam-maj/tiny-gpu/blob/master/src/scheduler.sv): `src/scheduler.sv`
- [Instruction fetcher](https://github.com/adam-maj/tiny-gpu/blob/master/src/fetcher.sv): `src/fetcher.sv`
- [Instruction decoder](https://github.com/adam-maj/tiny-gpu/blob/master/src/decoder.sv): `src/decoder.sv`
- [Thread registers](https://github.com/adam-maj/tiny-gpu/blob/master/src/registers.sv): `src/registers.sv`
- [Thread ALU](https://github.com/adam-maj/tiny-gpu/blob/master/src/alu.sv): `src/alu.sv`
- [Thread LSU](https://github.com/adam-maj/tiny-gpu/blob/master/src/lsu.sv): `src/lsu.sv`
- [Program counter](https://github.com/adam-maj/tiny-gpu/blob/master/src/pc.sv): `src/pc.sv`

### Memory system

- [Memory controllers](https://github.com/adam-maj/tiny-gpu/blob/master/src/controller.sv): `src/controller.sv`
- **Cache (WIP)**
- **External global memory**

### Other components

- **Kernel host**

## Connections

- Kernel host → GPU top: loads and launches (evidence: `README.md`)
- Kernel host → Device control: sets thread count (evidence: `README.md`)
- GPU top → Dispatcher: starts execution (evidence: `README.md`)
- GPU top → Memory controllers: interfaces memory (evidence: `README.md`)
- Dispatcher → Compute core: assigns blocks (evidence: `README.md`)
- Compute core → Scheduler: manages execution (evidence: `README.md`)
- Scheduler → Instruction fetcher: fetches instructions (evidence: `README.md`)
- Instruction fetcher → External global memory: reads program memory (evidence: `README.md`)
- Scheduler → Instruction decoder: decodes instruction (evidence: `README.md`)
- Scheduler → Thread registers: executes per thread (evidence: `README.md`)
- Scheduler → Thread ALU: issues arithmetic (evidence: `README.md`)
- Scheduler → Thread LSU: issues memory access (evidence: `README.md`)
- Scheduler → Program counter: tracks instruction position (evidence: `README.md`)
- Thread LSU → Memory controllers: requests data access (evidence: `README.md`)
- Memory controllers → External global memory: relays requests (evidence: `README.md`)
- External global memory → Cache (WIP): stores fetched data (evidence: `README.md`)
