Skip to the content.

← Back to Home

Pipeline Simulator & Assembler

View Code on GitHub


Overview

This project implements both an Assembler and a 5-Stage Pipeline Simulator for the LC-2K instruction set architecture (ISA), fully written in C. It provides low-level insight into how a processor parses assembly instructions, manages control flow, detects hazards, and simulates pipeline stages like modern CPUs.

The project is divided into two components:

  1. Assembler:
    • Converts LC-2K assembly code into 32-bit machine code.
    • Handles labels, opcode translation, offset calculations, and error checking.
  2. Pipeline Simulator:
    • Simulates a 5-stage pipeline: IF, ID, EX, MEM, WB.
    • Implements data hazard detection, stalling, and forwarding to ensure correctness.
    • Prints state of memory, registers, and pipeline registers after each cycle.

Features

Assembler:


Pipeline Simulator:

Stage Description
IF Instruction Fetch: loads instruction and increments PC
ID Instruction Decode: reads registers, detects hazards, stalls if necessary
EX Execute: ALU operations, calculates branches, sets branch target
MEM Memory: executes load/store instructions, resolves branches
WB Write Back: writes results to registers

Technologies


← Back to Home