Note
This program is only a rough approximation of a simple real CPU. Its purpose is to create an basic understanding of how the system works and how it computes.
How to program the CPU.
Example: ["0001", "0000", "01010101", None, "0011"]
This block of code represents a single instruction for the CPU to execute. It's structure is build like this:
[instruction_address, instruction_type, memory_address, data, instruction_continuer]
The purpose of the instruction address is to establish a sequence of instructions that must be executed in a specific order. Also required is the instruction continuer, which informs the CPU about the next instruction to be processed (it appends to an already existing instruction address). To enable the CPU to determine the type of computation required, the instruction type is essential, as it defines the primary instruction from the instruction set.
Base instructions
- 0000 = load > imports data from RAM
- 0001 = add > adds number to data
- 0010 = store > stores data in RAM
- 0011 = compare > compares two datasets
- 0100 = output > outputs data in terminal
Note
Updates are upcoming. Not all base functionalities are given.
RAM structure
Example: ["00101101", "10011010"]
--> [memory_address, data]
Register types
- accumulator > imported data
- memory_address > saved memory address
- result_register > calculation values
- state_register > (True/False) values
(Default) show_process = True
> shows the process-steps in terminal
(Default) clock_speed = 1
> instruction step speed
Program your own CPU instructions in instruction_data
.