DEV Community

DouglasG98
DouglasG98

Posted on

Simulating 8 bit CPU using Python

This has been the most challenging project I had to code so far. It took me several versions before I manage to complete it.

The goal of this project was to simulate a CPU using python. Similar to a CPU it will have the function to fetch, decode, execute and write back data based on the assembly language MIPS32.

In this project I tried my best to mimic the operations of a CPU, e.g. using binary when possible, starting from logic gates. Then using those logic gates to build full-adders, full-adders into ALU and so on. The most challenging part for me was to try and rely on as little of python built in functions as possible. By doing so, it made the code a lot more bulkier.

Throughout this project, the majority of time spent was researching on how a CPU(and essentially the transistors within) actually would perform arithmetic operations. This research process took me through multiple simple CPU schematics, such as the 8 bit ALU, multipliers e.g.

All in all, although the code for this project wasn't the cleanest or the most accurate in mimicking an 8-bit CPU, it did significantly deepen my understanding and interest in the fundamental level of CPU arithmetic calculations and assemble languages.

If you are interest, here is the link to my GitHub containing the code: LINK

Top comments (0)