CPU-Simulator

This is a project required by Prof. Stephen Kaisler in Course: Computer System Architecture.

Purpose

To simulate a small classical CISC computer.

It has the following characteristics

  • Registers: General Purose Registers (GPRs), Index Registers, Program Counter, etc.
  • 18-bit words
  • Memory of 2048 words. (Size can be set in config file)
  • Cache of 16 lines, each of which has 8 words. (line amount and capacity can also be set in config file)

Features

User Program Editor
By using the instructions in this simulor, user can write a program which can be compiled into binary code automatically then loaded into a specific location of memory.
Multiple Running Mode

CPU-Simulator can run the target program in 3 modes:

Run: Simulator will run non-stoplly.
Debug (Single Step): Simulator will pause after each instruction finished. By clicking the Continue button, simulator will continue running.
Debug (Single Cycle): Simulator will pause after a cycle finished. By clicking the Continue button, simulator will continue running.
Monitor for Memory and Registers
This panel can give a quick view on the value of all the Memory and every register. All registers are editable which gives user a way to debug programs by setting a specific register.
Cache Monitor

The panel shows the hit rate by coloring every block in cache lines. Green means that block gets an immediate hit and it turns blue gradually after a time during which it never get another hit.
With the 'Enable Cache' unchecked, CPU can access the main memory directly.

Input and Output Device
Several io devices are embedded into this simulator including a keyboard and a printer which can be accessing by IN and OUT instructions.
On executing IN instruction associating with keyboard, the simulator will pause and wait for keyboard event. Keyboard panel will flash in green and by clicking any button on it, a keyboard input signal will be sent. With 'Link to keyboard' checked, user can send this signal via typing on their real keyboard.

Design

Instructions
Memory
IO Devices

Screenshot