Untitled

While the memory stores the code and data, the Central Processing Unit (CPU) does all the work. CPU. CPU includes registers and Arithmetic Logic Unit (ALU).

A register is like temporary memory in a calculator. It holds one word that can be used in the sequential computation. Some specified registers hold specific type of data — floating point numbers, addresses, etc.

One of them is the Program Counter (PC) which holds the address of which instruction is currently executed. The registers can be accessed much more quickly than memory but the number of registers are quite small compared to the size of memory.

The ALU performs the actual computation such addition, multiplication along with comparison and other operations. Most modern CPUs actually contains several specialized logic units in addition to the ALU which can do parallel computations. However, the complexity is kept within the CPU. For users, CPU just executes instructions on at a time, in the order presented in memory.

One major difference between the variables of a programming language and registers is the limited number of registers, typically 32 on current computers, like RISC-V. The reason for the limit of 32 registers may be found in the underlying design principles of hardware technology:

Smaller is faster.

A very large number of registers may increase the clock cycle time simply because it takes electronic signals longer when they must travel farther. Guidelines such as “smaller is faster” are not absolutes; 31 registers may not be faster than 32. In this case, the designer must balance the craving of programs for more registers with the designer’s desire to keep the clock cycle fast. Another reason for not using more than 32 is the number of bits it would take in the instruction format.