Skip to content

This project is a simplified single-cycle CPU simulator written in Java for an academic computer organization course. The simulation models the core functionality of a basic MIPS processor and demonstrates how machine instructions are executed at the hardware level.

Notifications You must be signed in to change notification settings

lukezeman/CPU-Simulation-in-Java

Repository files navigation

CPU-Simulation-in-Java

This project is a simplified single-cycle CPU simulator written in Java for an academic computer organization course. The simulation models the core functionality of a basic MIPS processor and demonstrates how machine instructions are executed at the hardware level.

Files Included

  • ALUControl.java (instructor provided)
    • Represents the ALU control bits
  • CPUControl.java (instructor provided)
    • Represents the CPU control bits
  • CPUMemory.java (instructor provided)
    • Simulates CPU memory
  • CPUSimulation.java (my code)
    • Executes the CPU
  • MemResult.java (instructor provided)
    • Stores the result from memory

Project Overview

  • Decodes and executes 32-bit MIPS instructions
  • Implements key components of the datapath:
    • Instruction decoding
    • ALU operation and control
    • Memory access
    • Register writeback
    • Program Counter updates
  • Supports both R-type and I-type instructions including:
    • add, sub, and, or, xor, sll, slt
    • addi, slti, andi, lui
    • lw, sw, beq, j

How It Works

  1. Takes a 32-bit instruction and extracts fields like opcode, registers, and immediates
  2. Determines the instruction type and sets control signals accordingly
  3. Selects ALU inputs based on control and instruction format
  4. Performs ALU computation and optional memory access
  5. Updates registers and calculates the next Program Counter

Concepts Practiced

  • Instruction set architecture (ISA) design (MIPS)
  • Bit manipulation and instruction parsing
  • Control signal generation
  • Single-cycle CPU operation modeling
  • Data flow and register/memory updates

Note: This project was tested using instructor-given test cases.

About

This project is a simplified single-cycle CPU simulator written in Java for an academic computer organization course. The simulation models the core functionality of a basic MIPS processor and demonstrates how machine instructions are executed at the hardware level.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages