# maze-0508/rv32i_core architecture

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

- Interactive diagram: https://gitdiagram.com/maze-0508/rv32i_core
- Repository: https://github.com/maze-0508/rv32i_core

## Overview

This repository implements an RV32I processor: instructions enter a five-stage pipeline and produce register and memory updates. The README documents stage order, each stage’s responsibilities, hazard handling, and the supporting RTL modules. The graph follows those documented relationships; source excerpts were unavailable, so it does not claim additional wiring beyond the README.

Main entry points: [`rtl/rv32i_pipeline.v`](https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v) (Instruction decode), [`rtl/hazard_unit.v`](https://github.com/maze-0508/rv32i_core/blob/main/rtl/hazard_unit.v) (Load-use detection), [`rtl/regfile.v`](https://github.com/maze-0508/rv32i_core/blob/main/rtl/regfile.v) (Register file), [`rtl/control.v`](https://github.com/maze-0508/rv32i_core/blob/main/rtl/control.v) (Opcode control)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pipeline["Pipeline stages"]
  node_pipeline_core["Pipeline core<br/>[rv32i_pipeline.v]"]
  node_fetch["Instruction fetch<br/>[rv32i_pipeline.v]"]
  node_decode["Instruction decode<br/>[rv32i_pipeline.v]"]
  node_execute["Execute stage<br/>[rv32i_pipeline.v]"]
  node_memory_stage["Memory stage<br/>[rv32i_pipeline.v]"]
  node_writeback["Write-back stage<br/>[rv32i_pipeline.v]"]
end

subgraph group_execution["Execution and control"]
  node_control["Opcode control<br/>[control.v]"]
  node_alu["ALU<br/>[alu.v]"]
  node_forwarding["Data forwarding<br/>[forward_unit.v]"]
  node_hazards["Load-use detection<br/>[hazard_unit.v]"]
end

subgraph group_state["Processor state"]
  node_regfile["Register file<br/>[regfile.v]"]
  node_instruction_memory[("Instruction memory<br/>[rv32i_pipeline.v]")]
  node_data_memory[("Data memory<br/>[rv32i_pipeline.v]")]
end

node_program["Instruction program"]
node_cpu_state(("CPU state"))

node_program -->|"provides instructions"| node_instruction_memory
node_fetch -->|"looks up instruction"| node_instruction_memory
node_fetch -->|"passes instruction"| node_decode
node_decode -->|"passes operands"| node_execute
node_execute -->|"passes result"| node_memory_stage
node_memory_stage -->|"passes data"| node_writeback
node_decode -->|"decodes opcode"| node_control
node_decode -->|"reads registers"| node_regfile
node_execute -->|"performs operation"| node_alu
node_execute -->|"selects operands"| node_forwarding
node_hazards -->|"freezes PC"| node_fetch
node_hazards -->|"stalls fetch/decode"| node_decode
node_hazards -->|"inserts bubble"| node_execute
node_memory_stage -->|"reads or writes"| node_data_memory
node_writeback -->|"writes register"| node_regfile
node_writeback -->|"updates state"| node_cpu_state
node_memory_stage -->|"updates memory"| node_cpu_state

click node_pipeline_core "https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v"
click node_fetch "https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v"
click node_decode "https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v"
click node_execute "https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v"
click node_memory_stage "https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v"
click node_writeback "https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v"
click node_control "https://github.com/maze-0508/rv32i_core/blob/main/rtl/control.v"
click node_alu "https://github.com/maze-0508/rv32i_core/blob/main/rtl/alu.v"
click node_forwarding "https://github.com/maze-0508/rv32i_core/blob/main/rtl/forward_unit.v"
click node_hazards "https://github.com/maze-0508/rv32i_core/blob/main/rtl/hazard_unit.v"
click node_regfile "https://github.com/maze-0508/rv32i_core/blob/main/rtl/regfile.v"
click node_instruction_memory "https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v"
click node_data_memory "https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v"

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_pipeline_core,node_fetch,node_decode,node_execute,node_memory_stage,node_writeback toneBlue
class node_control,node_alu,node_forwarding,node_hazards toneAmber
class node_regfile,node_instruction_memory,node_data_memory toneMint
class node_program,node_cpu_state toneIndigo
```

## Components

### Pipeline stages

- [Pipeline core](https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v): `rtl/rv32i_pipeline.v`
- [Instruction fetch](https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v): `rtl/rv32i_pipeline.v`
- [Instruction decode](https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v): `rtl/rv32i_pipeline.v`
- [Execute stage](https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v): `rtl/rv32i_pipeline.v`
- [Memory stage](https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v): `rtl/rv32i_pipeline.v`
- [Write-back stage](https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v): `rtl/rv32i_pipeline.v`

### Execution and control

- [Opcode control](https://github.com/maze-0508/rv32i_core/blob/main/rtl/control.v): `rtl/control.v`
- [ALU](https://github.com/maze-0508/rv32i_core/blob/main/rtl/alu.v): `rtl/alu.v`
- [Data forwarding](https://github.com/maze-0508/rv32i_core/blob/main/rtl/forward_unit.v): `rtl/forward_unit.v`
- [Load-use detection](https://github.com/maze-0508/rv32i_core/blob/main/rtl/hazard_unit.v): `rtl/hazard_unit.v`

### Processor state

- [Register file](https://github.com/maze-0508/rv32i_core/blob/main/rtl/regfile.v): `rtl/regfile.v`
- [Instruction memory](https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v): `rtl/rv32i_pipeline.v`
- [Data memory](https://github.com/maze-0508/rv32i_core/blob/main/rtl/rv32i_pipeline.v): `rtl/rv32i_pipeline.v`

### Other components

- **Instruction program**
- **CPU state**

## Connections

- Instruction program → Instruction memory: provides instructions (evidence: `README.md`)
- Instruction fetch → Instruction memory: looks up instruction (evidence: `README.md`)
- Instruction fetch → Instruction decode: passes instruction (evidence: `README.md`)
- Instruction decode → Execute stage: passes operands (evidence: `README.md`)
- Execute stage → Memory stage: passes result (evidence: `README.md`)
- Memory stage → Write-back stage: passes data (evidence: `README.md`)
- Instruction decode → Opcode control: decodes opcode (evidence: `README.md`)
- Instruction decode → Register file: reads registers (evidence: `README.md`)
- Execute stage → ALU: performs operation (evidence: `README.md`)
- Execute stage → Data forwarding: selects operands (evidence: `README.md`)
- Load-use detection → Instruction fetch: freezes PC (evidence: `README.md`)
- Load-use detection → Instruction decode: stalls fetch/decode (evidence: `README.md`)
- Load-use detection → Execute stage: inserts bubble (evidence: `README.md`)
- Memory stage → Data memory: reads or writes (evidence: `README.md`)
- Write-back stage → Register file: writes register (evidence: `README.md`)
- Write-back stage → CPU state: updates state (evidence: `README.md`)
- Memory stage → CPU state: updates memory (evidence: `README.md`)
