Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 1.87 KB

File metadata and controls

29 lines (24 loc) · 1.87 KB

CPU-Simulator

Python Badge
Python program to simulate CPU functionalities using OOP structure.

Structure

📁inputs - Modifiable input files to be read into simulation
| data_input - Contains sample data that are read into memory bus
| instruction input - Contains sample instructions that are read into CPU

cache.py - Cache class
cpu.py - CPU class that contains the bulk of the applicable programming. Utilizes intstantiations of the cache and memory bus
main.py - Instantiates CPU, reads applicable data, and runs the simulation
memory.py - Memory bus class

Instruction Key

Command Argument Function
CACHE 0 Turn cache off
CACHE 1 Turn cache on
CACHE 2 Flush cache
JMP INT Jump to specified position
ADD Destination, Source, Target Add target and source register values on destination register
ADDI Destination, Source, Immediate Add immediate value to source register on destination register
HALT Halt program

References

Code is based on Codecademy's CPU Simulator Portfolio Project.

Thanks to Dr. Timothy Heil for his computer architecture knowledge.