# benwin-dev/super-scalar-pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/benwin-dev/super-scalar-pipeline
- Repository: https://github.com/benwin-dev/super-scalar-pipeline

## Overview

This is a small C++ superscalar-pipeline simulator prototype. Its implemented workflow reads instructions from a trace, decodes and queues them, issues instructions while tracking register dependencies, then dispatches, executes, and writes back reservation-station entries for one cycle. Load and store queues are allocated and populated during issue, but this entry point does not process them further. The runtime is contained in main.cpp; the edges shown reflect calls and state transfers visible in that file.

Main entry points: [`main.cpp`](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp) (Instruction issue)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_trace["Instruction trace"]
node_main["Cycle driver<br/>[main.cpp]"]
node_fetch["Fetch and decode<br/>[main.cpp]"]
node_parser["Opcode parser<br/>[main.cpp]"]
node_instruction_queue["Instruction queue<br/>[main.cpp]"]
node_issue["Instruction issue<br/>[main.cpp]"]
node_latency["Latency lookup<br/>[main.cpp]"]
node_reservation_station[("Reservation station<br/>[main.cpp]")]
node_load_queue["Load queue<br/>[main.cpp]"]
node_store_queue["Store queue<br/>[main.cpp]"]
node_register_status[("Register status<br/>[main.cpp]")]
node_dispatch["Operand dispatch<br/>[main.cpp]"]
node_execute["Instruction execution<br/>[main.cpp]"]
node_writeback["Writeback and retire<br/>[main.cpp]"]

node_trace -->|"supplies input"| node_fetch
node_main -->|"calls"| node_fetch
node_fetch -->|"parses opcode"| node_parser
node_fetch -->|"enqueues instructions"| node_instruction_queue
node_main -->|"calls"| node_issue
node_issue -->|"dequeues instructions"| node_instruction_queue
node_issue -->|"gets latency"| node_latency
node_issue -->|"enqueues entries"| node_reservation_station
node_issue -->|"enqueues loads"| node_load_queue
node_issue -->|"enqueues stores"| node_store_queue
node_issue -->|"tracks producers"| node_register_status
node_main -->|"calls"| node_dispatch
node_dispatch -->|"marks ready entries"| node_reservation_station
node_main -->|"calls"| node_execute
node_execute -->|"advances entries"| node_reservation_station
node_main -->|"calls"| node_writeback
node_writeback -->|"wakes and retires"| node_reservation_station
node_writeback -->|"clears producers"| node_register_status

click node_main "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"
click node_fetch "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"
click node_parser "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"
click node_instruction_queue "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"
click node_issue "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"
click node_latency "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"
click node_reservation_station "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"
click node_load_queue "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"
click node_store_queue "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"
click node_register_status "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"
click node_dispatch "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"
click node_execute "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"
click node_writeback "https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp"

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_trace toneIndigo
class node_main,node_fetch,node_parser,node_issue,node_latency,node_dispatch,node_execute,node_writeback toneTeal
class node_instruction_queue,node_load_queue,node_store_queue toneRose
class node_reservation_station,node_register_status toneAmber
```

## Components

### Other components

- **Instruction trace**
- [Cycle driver](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`
- [Fetch and decode](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`
- [Opcode parser](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`
- [Instruction queue](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`
- [Instruction issue](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`
- [Latency lookup](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`
- [Reservation station](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`
- [Load queue](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`
- [Store queue](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`
- [Register status](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`
- [Operand dispatch](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`
- [Instruction execution](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`
- [Writeback and retire](https://github.com/benwin-dev/super-scalar-pipeline/blob/master/main.cpp): `main.cpp`

## Connections

- Instruction trace → Fetch and decode: supplies input (evidence: `main.cpp`)
- Cycle driver → Fetch and decode: calls (evidence: `main.cpp`)
- Fetch and decode → Opcode parser: parses opcode (evidence: `main.cpp`)
- Fetch and decode → Instruction queue: enqueues instructions (evidence: `main.cpp`)
- Cycle driver → Instruction issue: calls (evidence: `main.cpp`)
- Instruction issue → Instruction queue: dequeues instructions (evidence: `main.cpp`)
- Instruction issue → Latency lookup: gets latency (evidence: `main.cpp`)
- Instruction issue → Reservation station: enqueues entries (evidence: `main.cpp`)
- Instruction issue → Load queue: enqueues loads (evidence: `main.cpp`)
- Instruction issue → Store queue: enqueues stores (evidence: `main.cpp`)
- Instruction issue → Register status: tracks producers (evidence: `main.cpp`)
- Cycle driver → Operand dispatch: calls (evidence: `main.cpp`)
- Operand dispatch → Reservation station: marks ready entries (evidence: `main.cpp`)
- Cycle driver → Instruction execution: calls (evidence: `main.cpp`)
- Instruction execution → Reservation station: advances entries (evidence: `main.cpp`)
- Cycle driver → Writeback and retire: calls (evidence: `main.cpp`)
- Writeback and retire → Reservation station: wakes and retires (evidence: `main.cpp`)
- Writeback and retire → Register status: clears producers (evidence: `main.cpp`)
