# gowthamaruthi/rv32i-single-cycle architecture

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

- Interactive diagram: https://gitdiagram.com/gowthamaruthi/rv32i-single-cycle
- Repository: https://github.com/gowthamaruthi/rv32i-single-cycle

## Overview

This repository is an educational, single-cycle RV32I SystemVerilog CPU with a Python instruction-level reference model. Its main workflow generates directed and seeded-random programs, simulates the RTL, and compares retirements, traps, registers, and memory against the model. The README also documents optional physical-implementation and UPF/output-isolation experiments. The hardware blocks follow the README architecture; sampled verification sources support the regression links. Physical and power implementation details are not sampled, so those branches are shown only at the documented subsystem level.

Main entry points: [`scripts/regress.py`](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/scripts/regress.py) (Regression runner), [`rtl/rv32i_core.sv`](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv) (ALU and branches), [`tb/tb_core.sv`](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/tb/tb_core.sv) (Core testbench), [`verification/programs.py`](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/verification/programs.py) (Program generators)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cpu["CPU RTL"]
  node_core["RV32I core<br/>[rv32i_core.sv]"]
  node_pc["Program counter<br/>[rv32i_core.sv]"]
  node_decode["Decode and immediates<br/>[rv32i_core.sv]"]
  node_regfile["Register file<br/>[rv32i_core.sv]"]
  node_alu["ALU and branches<br/>[rv32i_core.sv]"]
  node_writeback["Load and writeback<br/>[rv32i_core.sv]"]
end

subgraph group_verify["Verification"]
  node_generator["Program generators<br/>[programs.py]"]
  node_model["Reference model<br/>[model.py]"]
  node_regression["Regression runner<br/>[regress.py]"]
  node_testbench["Core testbench<br/>[tb_core.sv]"]
  node_results["Comparison results<br/>[regress.py]"]
end

subgraph group_physical["Physical experiment"]
  node_physicalexp["Physical implementation"]
end

subgraph group_power["Power experiment"]
  node_powerexp["UPF isolation experiment"]
end

node_engineer(("Engineer"))
node_imem[("Instruction memory")]
node_dmem[("Data memory")]

node_engineer -->|"runs checks"| node_regression
node_regression -->|"loads programs"| node_generator
node_regression -->|"steps reference"| node_model
node_regression -->|"compiles RTL"| node_core
node_regression -->|"compiles testbench"| node_testbench
node_testbench -.->|"simulates"| node_core
node_regression -->|"compares traces"| node_results
node_core -->|"updates"| node_pc
node_pc -->|"requests instruction"| node_imem
node_imem -->|"supplies instruction"| node_decode
node_decode -->|"selects registers"| node_regfile
node_regfile -->|"supplies operands"| node_alu
node_decode -->|"supplies control"| node_alu
node_alu -->|"requests memory access"| node_dmem
node_dmem -->|"supplies load data"| node_writeback
node_alu -->|"supplies result"| node_writeback
node_writeback -->|"writes result"| node_regfile
node_alu -->|"selects next PC"| node_pc
node_engineer -->|"runs experiment"| node_physicalexp
node_engineer -->|"runs experiment"| node_powerexp

click node_core "https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv"
click node_pc "https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv"
click node_decode "https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv"
click node_regfile "https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv"
click node_alu "https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv"
click node_writeback "https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv"
click node_generator "https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/verification/programs.py"
click node_model "https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/verification/model.py"
click node_regression "https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/scripts/regress.py"
click node_testbench "https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/tb/tb_core.sv"
click node_results "https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/scripts/regress.py"
click node_physicalexp "https://github.com/gowthamaruthi/rv32i-single-cycle/tree/main/physical"
click node_powerexp "https://github.com/gowthamaruthi/rv32i-single-cycle/tree/main/power"

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_core,node_pc,node_decode,node_regfile,node_alu,node_writeback toneBlue
class node_generator,node_model,node_regression,node_testbench,node_results,node_imem,node_dmem toneAmber
class node_physicalexp toneMint
class node_powerexp toneRose
class node_engineer toneIndigo
```

## Components

### CPU RTL

- [RV32I core](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv): `rtl/rv32i_core.sv`
- [Program counter](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv): `rtl/rv32i_core.sv`
- [Decode and immediates](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv): `rtl/rv32i_core.sv`
- [Register file](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv): `rtl/rv32i_core.sv`
- [ALU and branches](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv): `rtl/rv32i_core.sv`
- [Load and writeback](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/rtl/rv32i_core.sv): `rtl/rv32i_core.sv`

### Verification

- [Program generators](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/verification/programs.py): `verification/programs.py`
- [Reference model](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/verification/model.py): `verification/model.py`
- [Regression runner](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/scripts/regress.py): `scripts/regress.py`
- [Core testbench](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/tb/tb_core.sv): `tb/tb_core.sv`
- [Comparison results](https://github.com/gowthamaruthi/rv32i-single-cycle/blob/main/scripts/regress.py): `scripts/regress.py`

### Physical experiment

- [Physical implementation](https://github.com/gowthamaruthi/rv32i-single-cycle/tree/main/physical): `physical`

### Power experiment

- [UPF isolation experiment](https://github.com/gowthamaruthi/rv32i-single-cycle/tree/main/power): `power`

### Other components

- **Engineer**
- **Instruction memory**
- **Data memory**

## Connections

- Engineer → Regression runner: runs checks (evidence: `README.md`)
- Regression runner → Program generators: loads programs (evidence: `scripts/regress.py`)
- Regression runner → Reference model: steps reference (evidence: `scripts/regress.py`)
- Regression runner → RV32I core: compiles RTL (evidence: `scripts/regress.py`)
- Regression runner → Core testbench: compiles testbench (evidence: `scripts/regress.py`)
- Core testbench → RV32I core: simulates
- Regression runner → Comparison results: compares traces (evidence: `scripts/regress.py`)
- RV32I core → Program counter: updates (evidence: `README.md`)
- Program counter → Instruction memory: requests instruction (evidence: `README.md`)
- Instruction memory → Decode and immediates: supplies instruction (evidence: `README.md`)
- Decode and immediates → Register file: selects registers (evidence: `README.md`)
- Register file → ALU and branches: supplies operands (evidence: `README.md`)
- Decode and immediates → ALU and branches: supplies control (evidence: `README.md`)
- ALU and branches → Data memory: requests memory access (evidence: `README.md`)
- Data memory → Load and writeback: supplies load data (evidence: `README.md`)
- ALU and branches → Load and writeback: supplies result (evidence: `README.md`)
- Load and writeback → Register file: writes result (evidence: `README.md`)
- ALU and branches → Program counter: selects next PC (evidence: `README.md`)
- Engineer → Physical implementation: runs experiment (evidence: `README.md`)
- Engineer → UPF isolation experiment: runs experiment (evidence: `README.md`)
