In this article we will see in detail what processors are and what role they play inside a computer. We will see how they are structured, the functions performed and how they are characterized. In particular we will analyze the differences between the CISC and RISC architectures. Finally we will close with a quick introduction to memory and how it is structured. Fundamental concept for understanding how a processor can access it.
But before starting let’s analyze if there are any differences between the term processor and the CPU.
Processors and CPU, are they the same thing?
Microprocessor and CPU, from a theoretical point of view are different but in fact they have become the same thing.
There is a small and subtle difference, even if they have practically become the same thing in common sense.
In fact, by microprocessor we mean a chip that carries out the execution of instructions in sequence, while the CPU is the central processing unit.
The CPU is itself a microprocessor, but in addition to executing instructions, it also performs a function of controlling all the devices inside a computer.
At present, you can use both words without worrying too much about this difference.
The Components of a Computer
The main part of a computer is the CPU (central processing unit), which can be represented divided into 3 different components:
- Control unit
- Arithmetic and logic unit (ALU)
Then in the diagram of a computer another very important component must be considered, which is the central memory, of the RAM type (Random Access Memory).
To complete the scheme there are other Input / Output devices, which can be video, hard disk, mouse, scanner, printer, keyboard, etc.
The CPU and its components
Three distinct components can be considered in the CPU, as shown in the figure.
The control unit is that part used for taking the instructions from the main memory, for their recognition. It also takes care of the general control of processor operation.
The arithmetic-logical unit is that part that performs the elementary operations required by the control unit according to the instructions received.
The internal registers, on the other hand, are very high-speed memory cells on which the CPU and the ALU act directly. The control information and temporary results of the operations carried out by the ALU are stored in these registers. There are different types of register, the most common are:
- Program Counter (PC) – it is the register that points to the next instruction to be executed by the CPU
- Instruction Register (IR) – it is the register that contains the instruction to be executed.
The instructions and their execution cycle
The CPU has a specific cycle with which the sequences of instructions (program) are executed. But before starting with the execution cycle, there is the bootstrap phase, during which the cycle is initialized by starting the execution of the program with the assignment of appropriate initial values.
Fetch. The CPU first reads the new instruction from the memory referring to the address contained in the PC register. This instruction is then copied to the IR register. The content of the PC register is filled with the address of the following instruction.
Decode. The CPU analyzes the instruction just received and determines its type by reading the first bits of the IR register (these bits represent the operating code of the instruction). If the new instruction carries out an operation between data in memory, it determines its position (addresses). It takes them and places them in the appropriate internal registers.
Execute. The CPU executes the instruction with the use of the logical arithmetic unit (ALU) and stores the result in a register or in a memory location, depending on what is provided by the instruction.
It restarts from the starting point and the execution cycle is repeated with the following instruction.
Instruction sets: RISC and CISC
Each specific computer (CPU) corresponds to a specific set of instructions, which will constitute the basic programming level: machine language. This language therefore varies from machine to machine as it is specific to the internal architecture of the computer.
There are sets of instructions with many or few commands:
Machines with very small instruction sets are called RISC (Reduced Instruction Set Computers) machines, while on the other hand there are machines with large instruction sets called CISC (Complex Instruction Set Computers).
Among the RISC processors we have: AVR, PIC, ARM, DEC Alpha, PA-RISC, SPARC, MIPS, POWER e PowerPC.
Among the CISC processors we have: System/360, VAX, PDP-11, Motorola 68000, gli x86 di Intel e AMD
CISC vs RISC
Let’s see in detail how the architectures based on CISC and RISC differ.
A RISC architecture is simple and straightforward, and thus microprocessors of this type will execute instructions in much faster times than those based on CISC. In fact, a reduced set of instructions does not mean that the processor is not able to perform some operations, but that the machine code will be longer than that necessary for a CISC processor, since the instructions are not present (but present in CISC) in the ‘together they will need to be implemented and will require multiple instructions to execute them. This will therefore lead to a greater demand for memory and a greater number of instructions to execute. However, the execution speed of each instruction will be equivalent to a single machine cycle.
The situation of a CISC architecture is completely opposite. There are individual instructions that allow you to perform multiple operations together, such as reading data in memory, modifying it and then saving it. We therefore have shorter and simplified machine code programs. However, the instructions in this case will be heavier, requiring even more machine cycles to be carried out (from 2 to 10 machine cycles).
It is therefore clear that the two architectures, RISC and CISC, do not differ substantially in terms of performances linked to the set of instructions chosen, but in how they are physically implemented. CISC architectures are easier to program and could be more advantageous, but they are difficult to improve electronically. In fact, the RISC having simpler electronics can be miniaturized or reworked more easily by integrating new technologies inside. CISC architectures will also follow that will integrate that technology, but will require more time to be implemented. It is therefore a continuous struggle between the two architectures that varies over time and from the technology used at the base.
A good way to better understand what has been said so far, let’s analyze the internal organization of a CPU and in particular its functioning. To do this we will use a standard model, called the Von Neumann classic model. This model effectively schematizes the data path to be processed within the CPU.
By executing an instruction, the CPU loads its registers with the data to be processed. Often the instructions to the processor require the execution of an operation on this data which is sent to the ALU (arithmetic logical unit). Following the Von Neumann scheme we can understand the path of this data and how it is processed.
The two data are taken from the CPU registers or from memory, then they are sent to two ALU input registers, after which the ALU performs the requested operation on the two data and stores the result on an ALU output register.
From here the result will be brought by the CPU once again to an internal register or to a memory location.
Based on this process, three different types of instructions can be distinguished:
- Instructions from memory to register, carry out the passage of data from the central memory to the internal registers of the CPU.
- Instructions from register to register, carry out the passage of data (two operands) from the CPU registers to the two input registers of the ALU. They perform the operation on them and then copy the result to a CPU register
- Instructions from memory to memory, carry out the passage of data directly from the central memory to the input registers of the ALU. They perform the operation on them and then copy the result directly into the main memory.
Memory and how it is structured
You have seen the very important role played by the central memory in the execution cycle of the programs by the CPU. The memory is in fact that part of the computer where the programs and the data on which they operate are stored.
Bits of memory
The fundamental unit into which the memory is divided is the bit, which is a binary number, that is either 0 or 1. It is in fact the simplest value to store in a memory cell. This results in binary information present in the memory.
In addition to being easily memorized, binary numbering is also easy to process. It can easily be assumed that arithmetic on binary numbers is highly efficient. This is true, but not only. The most important aspect is that binary arithmetic is also highly reliable. In fact, this is the fundamental characteristic that allowed its choice as the fundamental basis of all electronic computing.
Main memory is made up of a number of memory cells or locations. Each memory location must be identical to all the others and contain the same number of bits, i.e. the same number of binary digits. If a memory location contains K bits, then it can store 2K different values of information, ie 2K different binary combinations.
Each of them is identifiable thanks to a particular unique number, called the memory address, thanks to which computers can refer to them during the execution of the instructions contained in a program. Adjacent memory cells must have consecutive addresses. These memory addresses are also nothing more than binary numbers.
So the CPU can easily follow the data in memory and their addresses thanks to binary arithmetic. If a memory has addresses made up of M binary digits, then the directly usable memory locations will be 2 to M. By increasing or decreasing the binary units of the memory addresses, the CPU can easily access adjacent memory cells. This calculation is very useful because it is totally independent of the bit size of the cells, called bytes. 8-bit cells and 16-bit cells will have the same memory address, regardless of their size.
Despite this, all manufacturers have now decided to standardize the cell size on 8 bits, so when we say byte we refer to this amount of memory.
Instead, what varies is the size of the words. In fact, in turn, the bytes are grouped into contiguous groups called words. The number of bytes needed to form a word varies from computer to computer. In fact, we often hear about a 16-bit, 32-bit or 64-bit processor (ie 2.4 and 8 bytes respectively). But why use words? This is because the instructions executed by a computer operate on whole words, such as the sum of two words. So a 32-bit machine will work on instructions that move, add, subtract and manipulate 32 bits at a time.