11.11.21

CPU Exercise

     The idea for this Codecademy exercise was to create a highly simplified CPU using Python.  

     I have trouble wrapping my mind around how binary gates lead to certain processor functions, so my project is kind of a mish-mash of Python components (dictionaries, loops, etc.) and simulated binary comparisons. Basically, it's not even close to correctly replicating actually binary gate structure and processes.

     The ISA file starts off reading a set of instructions. The instructions begin by storing binary numbers into the cache (sometimes main memory using a write-back policy). Afterwards, the numbers are pulled from memory and used in arithmetic functions - in the order of addition, subtraction, multiplication, then division. All of the read/writes are printed out allowing the user to follow what's happening. The instructions are in binary, not assembly, complete with opcodes, functions, register destinations, jumps, etc. The different processor parts and ideas are represented by files with matching names - ISA, ALU, cache memory, main memory, and the register. The ISA file is the hub, connecting all the other files/CPU components.

     If you actually run the program, apologies for the chaotic feedback. The program pretty much prints out every little thing the components do, even when a numbers bit count is adjusted. But the calculation results are isolated to at least show a conclusion to all those processes.

CPUExercise - here is a link to the github files.

     In conclusion, I enjoyed programming the binary arithmetic functions; creating the CPU architecture was just so-so. Some of my disappointment may stem from my lack of deep understanding of the concepts, so I felt like I had to fake some of the binary interactions with python code instead of relying on binary methods. Either way, quite a bit of testing went into the arithmetic but not much in the processor exercise; meaning there are most likely plenty of bugs.

No comments: