Introduction to CPU Design
Designing a central processing unit (CPU) is a complex and challenging task that requires a deep understanding of computer architecture, electrical engineering, and digital logic design. A CPU, also known as a microprocessor, is the brain of a computer and is responsible for executing instructions and performing various operations. In this article, we will discuss the steps involved in designing a CPU and what knowledge and skills are required to do so.
Different Steps to Design any CPU
To design any CPU, we might follow the below steps for our better understanding & design it.
Step 1: Define the Architecture
The first step in designing a CPU is to define its architecture. This includes determining the number of instruction sets, the number of general-purpose registers, and the size of the memory address space. The architecture also defines the instruction format, the data types supported, and the number of execution units.
Step 2: Design the Instruction Set Architecture (ISA)
The Instruction Set Architecture (ISA) defines the set of instructions that the CPU can execute. This includes arithmetic operations, logical operations, branching instructions, and memory access instructions. The ISA also defines the format of the instructions, including the size of the instruction, the number of operands, and the encoding of the instructions.
Step 3: Design the Microarchitecture
The microarchitecture is the implementation of the ISA. This involves designing the execution units, the register files, the data cache, and the memory hierarchy. The microarchitecture also determines how the instructions are executed, including the number of cycles required to execute each instruction, the order of execution, and the flow of data between the execution units.
Step 4: Implement the Design
Once the architecture and microarchitecture are designed, the next step is to implement the design. This involves writing the RTL (register transfer level) code, which defines the behavior of the CPU. The RTL code is then synthesized into a gate-level description, which is used to generate the final layout of the CPU.
Step 5: Verify the Design
The final step in designing a CPU is to verify the design. This involves running simulations and tests to ensure that the CPU behaves as expected and meets the design specifications. This step is critical to ensure the reliability and performance of the CPU.
Example Design of a 8-bit CPU
It actually takes very little hardware to implement a simple CPU. Today in class we built a CPU with the very basics:
- An instruction fetch unit, which grabs the next instruction. The bits of the instruction are what activate different parts of the CPU circuit to make things happen. See the bits in various CPU instruction sets here.
- A register file, from which operands are read, and results are written.
- An arithmetic unit, which performs operations on the operands.
There are a few key tricks used throughout these designs:
- In a CPU, we need some way to keep operating on the same values. In a circuit, this means feeding the output of the circuit back around to its own input, recycling the same values over and over.
- Most CPUs operate on values of more than one bit. Using a single bus to represent multiple bits with a single line dramatically simplifies the circuit schematic compared to the physically more realistic approach of drawing separate wires for each bit. Logisim calls this “Data Bits”; most other tools call it a “bus”.
- A multiplexer selects one input line from a set of inputs, based on “select line”. For example, an 8-in mux has a 3-bit select input, which is a binary code indicating which of the 8 inputs to select as the output. Multiplexors are used:
1) In the register file, select which register should provide
2) In the arithmetic unit, pick the output of one arithmetic circuit from those listed. The arithmetic select lines are controlled by the opcode portion of the instruction.
Timing matters! In a real circuit timing is often the most important consideration for both performance and correctness. In the simulator, all the registers are edge-triggered. To avoid timing bugs, we fetch the next instruction on one edge of the clock and write the results on the opposite edge of the clock, which prevents bugs where the register grabs a value as it changes. In a more complex design, we might need to keep a shift register to cycle between operating stages within a single instruction.
Here’s the compact 11-bit instruction set CPU we built-in class in 2018.
Now you might have thought about how an Operating System like Linux or any other is running on any CPU.
In conclusion, designing a CPU is a complex and challenging task that requires a deep understanding of computer architecture, electrical engineering, and digital logic design. The steps involved in designing a CPU include defining the architecture, designing the instruction set architecture, designing the microarchitecture, implementing the design, and verifying the design. Designing a CPU is a rewarding experience that can lead to a career in the semiconductor industry or academia.