Thoughts on an 8 bit CPU I Designed on Logisim

Star Watch

I recently designed an 8 bit CPU on logisim. I uploaded the files on GitHub, if you want to check it out. But, before going into detail, let me give an overview of the general structure of a CPU.

Overview of a CPU

The three main units of a CPU are the Arithmetic Logic Unit (ALU), the Control Unit (CU), and the Memory Unit (MU).

CPU Diagram

Basic CPU Architecture Diagram. Borrowed from Blogspot

The Arithmetic Logic Unit

The ALU does arithmetic and bitwise operations to binary inputs values. You can think of this similar to a calculator -- it can add, subtract, increment, decrement, and two's complement. In addition, it can do bitwise operations such as AND, OR, NOT (one's complement), and bit shifts.

The Control Unit

The CU controls the execution and interpretation of input instructions, guides data flow, and manages processer timing (clocking). Clock speed of the control unit determines the number of instructions processed in a given period. In the CPU I built on logisim, the clock speed for a simulation can be set from 0.25 Hz to 4.1 KHz.

The Memory Unit

The MU in a CPU, typically consists of Random Access Memory (RAM), Read Only Memory (ROM), and Registers. RAM is a volatile memory unit that stores data on the computer. RAM requires power to store data and will lose the information if the power is shut off. ROM is a type of memory where data that has been written to it cannot be removed, but only read. Unlike RAM, it retains its information even after the power is shut off. Processor registers are local storage on the processor itself, providing fast storage and access to data. Instruction registers store input instruction sets that are being executed.

Input Instruction Set Reference

The instruction set reference I used for the 8-bit CPU I designed is below:

Instruction Set Reference

Instruction Set Reference

Instruction Set Reference

The 8-Bit CPU I Designed

The 8-Bit CPU I designed on logisim can be found here.

Instruction Set Reference

The picture above is from the CPU I designed. It shows the ROM loaded with hexadecimal instructions. The button in green is the clock which cycles through each instruction on the ROM. In the next section, I'll explain how to decode the instructions loaded on the ROM.

Understanding the Input Instruction Set

The CPU can process an 8-bit binary input. The instruction reference set that I showed above is used to code the 8-bit binary input. For example, if we had the binary number 0b01101110, bits 7,6,and 5 are 011, which is 3. Bit 4 is 0. Bits 3,2,1, and 0 are 1110 which is 14. We now use the instruction reference set to understand this. Since bits 7, 6, and 5 equal 3, we go down to the row that has the value 3 in the table. Since bit 4 is 0 we can see rx is r0 or register 0. Since bits, 3, 2, 1, and 0 have a value of 14, the immediate value equals 14. By looking at the name column, we see that this is the ori function and that register 0 or r0 stores the value 14. If we want to input this instruction into the ROM, we need to convert the binary number 0b01101110 to hexadecimal and we get 0x6e. The instruction set I used to test it out can be found here.

Conclusion

The purpose of this project was mainly to thoroughly understand the architecture of a CPU. I've seen some people take the project a step further by purchasing logic gates and actually building the entire CPU on a breadboard. I'm not sure whether I plan to do this because of the extensive wiring it will require to build it from scratch. I might, however, purchase parts such as the ALU as a whole instead of building it purely from logic gates, but I'm not sure yet. I spent about 3 to 4 hours on this project and was pretty satisfied by the outcome. Please feel free to email me if you have any thoughts regarding this project or others.