Throughout this course we already encountered all the necessary parts that comprise a generic CPU – Central Processing Unit – and the primary purpose of this paper is to create a relatively thorough compilation of these parts and describe how they work together in processing data.
Computer Architecture is a very vast and rapidly expanding field, and that makes the fact that a fully-functional CPU can be created using a relatively small number of components even more astonishing. These components include:
ALU – Arithmetic Logical Unit;
Clock and Program Counter (PC);
Control (instruction) Codes;
Let’s delve deeper into each of those.
It can easily be said that an ALU is the heart of every CPU. This is where the arithmetic (such as addition, subtraction, multiplication, and division) and logical operations (OR, AND, exclusive OR, and so on) happen, with the implications that it’s exactly an ALU that processes the data. Not only that, and in some cases an ALU is also responsible for data movement operations: such as the movement of data and instructions inside the CPU or carrying out memory read/write operations – the so-called load and store instructions.
Clock and Program Counter (PC)
A clock is a system chip that controls the speed of the computer functions, and it is characterized by a clock cycle. In general, a counter is a circuit that increments output on each clock edge (rising or falling depending on the design), and such a program counter is a specific case of a counter register that contains information about what the next instruction the CPU should perform is, with this information being presented in the form of an address.
If an ALU is a heart of the CPU, then a control unit is its brain. A control unit doesn’t process or store any data (that’s the job of the ALU and memory), but it “decides” what data is going to be processed and from where and to where it’s going to flow by performing the related tasks. These tasks are performed through a particular circuity (continuing the analogy, not unlike how a highly complex human brain controls a plethora of bodily functions).
Control (instruction) Codes
A control (instruction) code is an essential part of a CPU design. For a control unit to function without getting and sending instruction codes is unimaginable. In its principle, a control code is a binary number of a fixed length that consists of an operation code (opcode – this part specifies the operation which is to be performed by processing this instruction code) and one or more operands, together creating one of the three basic types of instruction codes:
Memory reference instruction;
Register reference instruction;
Before processing an instruction, a control unit has to decode it with the help of an instruction decoder – a component responsible for turning opcodes into set of signals to perform the specific data flow between different parts of the CPU and, consequently, perform the specific tasks associated with such flow.
How It Works
Obviously, it’s important not only to have all the necessary components but to make them actually work together. Hopefully, my paper so far was sufficient enough to show that none of these components worked in isolation, and there are some noticeable co-dependencies there: such as a control unit having a need for an instruction decoder to actually convert opcodes into the signals to be processed, or the ALU being dependent on the control unit to provide the operands and the operations. Or the control unit being dependent on the ALU to provide the specific flags so that a correct path for the data flow was selected.
As we were (hopefully) able to see from the paper, creating a basic CPU capable of performing some pre-defined operations, while not a trivial task, is nothing to shy away from. We have all the required circuitry and the knowledge how it should be connected in order for the data to flow exactly like we want it to flow. A bunch of registers, a component to decode instructions, another component to perform some pretty basic operations and an understanding how all these should be connected – there is no magic in how CPUs work, just logic, coherence, and perseverance.