How milleraj66/ece585_tomasuloalgorithm works
Project Type and Purpose
• This is a standalone C++ simulation tool that implements the Tomasulo algorithm’s datapath and scheduling logic.
File Structure Analysis
Top‐level files:
• main.cpp – Program entrypoint; parses configuration and instructions, drives the simulation loop.
• Instruction.h/.cpp – Defines an Instruction class (rd, rs, rt, opcode).
• ReservationStation.h/.cpp – Models a reservation station: fields for operands, operation type, busy flag, result readiness.
• RegisterStatus.h/.cpp – Tracks which reservation station will produce each register’s next value (for register renaming / status).
• Makefile – Build instructions.
• README.md – Usage and architecture notes.
No client/server or UI layers—pure compute simulation.
Key Architecture Concepts from README
• Configurable counts of ADD, MULT, DIV reservation stations.
• Latencies for different functional units and pipeline phases (issue, execute, writeback).
• Register file (vector<int>) and register status table (vector<RegisterStatus>) for renaming.
• Instruction queue (vector<Instruction>) as input program.
• Cycle‐by‐cycle simulation driving issue → execution → writeback, recording timing per instruction.
Main Components
a. Instruction Queue
• Holds the input vector<Instruction>.
• Feeds the Issue Unit each cycle.
b. Issue Unit
• Checks head of queue, consults Register Status to decide if operands are ready or which RS to allocate.
• Allocates a Reservation Station (RS) of the appropriate type (ADD/MULT/DIV).
• Updates Register Status table to point the destination register at that RS.
c. Register Status Table
• Maps each architectural register to the RS that will produce its next value or marks it “empty.”
d. Reservation Stations (multiple instances)
• Separate pools: ADD_RS, MULT_RS, DIV_RS (configurable counts).
• Each RS holds operation type, operand values or tags, busy bit, remaining execution time.
e. Functional Units (abstracted within RS in this code)
• Each Reservation Station steps its remaining latency each cycle once its operands are ready.
f. Common Data Bus (CDB) / Writeback Logic
• When an RS finishes execution, it broadcasts its result on the CDB.
• All RS instances and Register Status listen on the bus to wake up dependent operands.
• Register File is updated (the vector<int>) when Writeback occurs.
g. Register File
• Vector of integer values.
• Updated on writeback to hold committed results.
h. Simulation Controller (main.cpp)
• Advances the system clock each iteration.
• Steps: Issue → Execute (decrement latency in each RS) → Writeback (broadcast completions) → Record timing info.
Relationships and Data Flows
• Issue Unit → Reservation Station (allocation) and → Register Status Table (update).
• Reservation Stations ↔ Register Status & other RS’s (via CDB broadcasts).
• Reservation Stations → Register File (on writeback).
• Register Status Table → Issue Unit (to check operand availability).
• Main Simulation Loop wraps all of the above in a timed cycle.
Architectural Patterns and Principles
• Dynamic scheduling and register renaming via Tomasulo’s algorithm.
• Separation of concerns:
• Issue logic separate from execution state (RS).
• Decoupling of register writes via CDB.
• Parameterization for experimentation: number of RS’s and latencies are constants in code.