# p72i1ip/computer-architecture architecture

> Architecture diagram of the GitHub repository p72i1ip/computer-architecture, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/p72i1ip/computer-architecture
- Repository: https://github.com/p72i1ip/computer-architecture

## Overview

##### Project type and purpose
- This is an educational hardware design project for a Computer Architecture course. It culminates in a CPU implementation in Verilog that supports a basic subset of RISC-V instructions. The repository also contains two earlier homeworks:
- HW1: RISC-V assembly exercises (recursion, Caesar cipher)
- HW2: A Verilog ALU module with testbench
- The “Final_project” (folder named Final_group_45) holds the CPU RTL, its testbench, assembly programs, Python pattern generators, and documentation.

##### File structure
Top-level:
- hw1_b09502158/ – RISC-V assembly exercises + report
- HW2_b09502158/ – ALU Verilog + testbench patterns + scripts
- Final_group_45/ – Final CPU project
- LICENSE, README.md

Inside Final_group_45:
- 00_TB/Pattern – test vectors (input memories, golden outputs)
- 00_TB/tb.v & memory.v – top-level testbench module + memory model
- 01_RTL/ – scripts (run, clean) and CHIP.v (top-level CPU RTL)
- 02_Assembly/ – handwritten assembly test programs
- 03_Python/ – generators converting .s → memory data files
- CHIP.v (duplicate top-level) + documentation PDFs

##### Key insights from README
- The final CPU supports a small set of RISC-V instructions.
- Python scripts automate test pattern generation for each program.
- Standard structure: Memory ←→ CPU under testbench control.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data-Source Tier"
        Asm["Assembly Programs"]:::script
        Py["Python Generators"]:::script
        PATTERN["Test Vector Patterns"]:::script
        Asm -->|"source .s"| Py
        Py -->|"generate .dat"| PATTERN
    end

    subgraph "Simulation Tier"
        TB["tb.v (Testbench)"]:::tb
        MEM["memory.v (Memory Model)"]:::rtl
        RUN1["01_run.sh"]:::script
        RUN2["99_clean_up.sh"]:::script
        PATTERN -->|"init patterns"| TB
        RUN1 -->|"run simulation"| TB
        RUN2 -->|"clean outputs"| TB
        TB -->|"drive signals"| MEM
    end

    subgraph "RTL Tier"
        CHIP["CHIP.v (CPU RTL)"]:::rtl
        subgraph "Inside CHIP.v"
            IF["Instruction Fetch"]:::rtl
            ID["Instruction Decode"]:::rtl
            EX["Execute (ALU)"]:::rtl
            MEM_IF["Mem Interface"]:::rtl
            WB["Write-Back"]:::rtl
            CU["Control Unit"]:::rtl
            IF -->|"instr"| ID
            ID --> EX
            EX --> MEM_IF
            MEM_IF --> WB
            CU --> ID
            CU --> EX
        end
        MEM -->|"instr_data / data"| CHIP
        CHIP -->|"addr / data"| MEM
        TB -->|"stimulus & checks"| CHIP
    end

    subgraph "Documentation"
        DOC1["report.pdf"]:::script
        DOC2["final_project.pdf"]:::script
        DOC3["Instruction_Set_Listings.pdf"]:::script
    end

    classDef rtl fill:#AED6F1,stroke:#21618C,color:#1B2631;
    classDef script fill:#ABEBC6,stroke:#1D8348,color:#1B2631;
    classDef tb fill:#F9E79F,stroke:#B7950B,color:#1B2631;

    click TB "https://github.com/p72i1ip/computer-architecture/blob/main/Final_group_45/00_TB/tb.v"
    click MEM "https://github.com/p72i1ip/computer-architecture/blob/main/Final_group_45/00_TB/memory.v"
    click PATTERN "https://github.com/p72i1ip/computer-architecture/tree/main/Final_group_45/00_TB/Pattern/"
    click CHIP "https://github.com/p72i1ip/computer-architecture/blob/main/Final_group_45/01_RTL/CHIP.v"
    click RUN1 "https://github.com/p72i1ip/computer-architecture/blob/main/Final_group_45/01_RTL/01_run.sh"
    click RUN2 "https://github.com/p72i1ip/computer-architecture/blob/main/Final_group_45/01_RTL/99_clean_up.sh"
    click Asm "https://github.com/p72i1ip/computer-architecture/tree/main/Final_group_45/02_Assembly/"
    click Py "https://github.com/p72i1ip/computer-architecture/tree/main/Final_group_45/03_Python/"
    click DOC1 "https://github.com/p72i1ip/computer-architecture/blob/main/Final_group_45/report.pdf"
    click DOC2 "https://github.com/p72i1ip/computer-architecture/blob/main/Final_group_45/final_project.pdf"
    click DOC3 "https://github.com/p72i1ip/computer-architecture/blob/main/Final_group_45/Instruction_Set_Listings.pdf"
```
