# ct7-labs/argon-cpu architecture

> Architecture diagram of the GitHub repository ct7-labs/argon-cpu, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ct7-labs/argon-cpu
- Repository: https://github.com/ct7-labs/argon-cpu

## Overview

##### Project Overview
- This is a RISC-like CPU written in SystemVerilog intended for an iCE40HX8K implementation. It’s part of the Oganesson SoC project and serves as a learning platform for optimized, resource-constrained digital design.
- Key features include a 16-bit datapath, 24-bit address space with banking, a 32-bit instruction width, and a classic five-stage RISC execution model (though not pipelined yet).

##### Main Components
- Top-Level Module (SimTop.sv): Acts as the integration point for the CPU design, tying together all core components.
- ALU (ArgonALU.v): The arithmetic and logic unit responsible for performing operations.
- Instruction Cache (ArgonInstructionCache.v): Contains a 64B I-cache dedicated to instruction fetching.
- Register File (ArgonRegFile.v): Houses the 16 general-purpose registers.
- System Cache (ArgonSysCache.v): This is likely responsible for the unified system caching (instruction and data or possibly split caches); note the 4kB system cache mentioned in the README.
- Testbench (testbench.cpp): Provides the testbench environment to simulate and verify the design.

##### Relationships and Interactions
- The SimTop module should be depicted as the central node, interfacing with all subsidiary modules.
- From SimTop to each core module (ALU, Instruction Cache, Register File, System Cache) to show data/control signals.
- How the instruction flow moves: Instructions are fetched via the Instruction Cache, processed using the Register File and ALU, and memory operations are handled by the System Cache.
- A feedback loop from the ALU for flag generation and control signal updates, if applicable.

##### Architectural Patterns & Design Principles
- This is a classic RISC design with a five-stage execution model (despite being non-pipelined in this version).
- Separation of concerns: Each module (ALU, caches, registers) is self-contained but integrated via the top-level module.

##### Technologies & Frameworks
- Mention that the design may involve simulation aspects (indicated by the testbench in C++), which suggests a mixed simulation environment.

##### Instructing the Principal Software Engineer
- Branch out nodes for:
- CPU datapath components (ALU, Register File).
- Memory interfaces (Instruction Cache, System Cache).
- The flow of instructions from the Instruction Cache into the CPU core.
- Data pathways between the CPU core (ALU, Register File) and the System Cache.
- With design notes about:
- The 5-stage, classic RISC pipeline model (even if not pipelined, the stages should be illustrated, perhaps with the plan for future versions).
- How resource optimizations might affect module interconnections.
- A separate section or note for the testbench indicating how simulation/verification interacts with the SimTop module.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CPU Architecture Subgraph
    subgraph "CPU Architecture"
        SimTop["SimTop.sv\n(Top-Level Module)"]:::core
        ALU["ArgonALU.v\n(ALU)"]:::core
        RegFile["ArgonRegFile.v\n(Register File)"]:::core
        InCache["ArgonInstructionCache.v\n(Instruction Cache)"]:::core
        SysCache["ArgonSysCache.v\n(System Cache)"]:::core
    end

    %% Simulation Subgraph
    subgraph "Simulation Environment"
        Testbench["testbench.cpp\n(Testbench)"]:::simulated
    end

    %% Connections
    InCache -->|"fetches"| SimTop
    Testbench -->|"drives"| SimTop
    SimTop -->|"executes"| ALU
    SimTop -->|"accesses"| RegFile
    SimTop -->|"interfaces"| SysCache
    ALU -->|"flagUpdates"| SimTop

    %% Click Events
    click SimTop "https://github.com/ct7-labs/argon-cpu/blob/master/rtl/SimTop.sv"
    click ALU "https://github.com/ct7-labs/argon-cpu/blob/master/rtl/ArgonALU.v"
    click InCache "https://github.com/ct7-labs/argon-cpu/blob/master/rtl/ArgonInstructionCache.v"
    click RegFile "https://github.com/ct7-labs/argon-cpu/blob/master/rtl/ArgonRegFile.v"
    click SysCache "https://github.com/ct7-labs/argon-cpu/blob/master/rtl/ArgonSysCache.v"
    click Testbench "https://github.com/ct7-labs/argon-cpu/blob/master/testbench.cpp"

    %% Styles
    classDef core fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef simulated fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
```
