An arithmetic logic unit (ALU) is a digital circuit used to perform arithmetic and logic operations. The central processing unit is developed from ALU, ALU is sometimes referred to as a building block. ALU in the modern computer is robust and is of composite design. The control unit is also attached to the CPU in modern computers. ALU can be named a calculator of CPU because it is a collection of logic circuits designed to perform arithmetic and logical operations. One or more ALU performs operations of the CPU, which retrieves data from the input registers. A register is a storage space CPU, generally registers to hold small data only.
How does the ALU function?
As the name suggests, ALU only performs basic arithmetic and logic operations.
Namely arithmetic operations are
The logic operation is a comparison of values such as:
All computer stores data in binary form, any data we feed to the computer is manipulated in the form of a binary number.
Binary numbers are manipulated using transistors.
ALU contains a full adder, which performs addition and subtraction, and complex circuits are designed to perform multiplication and divisions. The logic operations help to manipulate the data sent in a different form, for example. NOT gates change the data sent to the opposite state. (If 1 is passed NOT gate alters it to 0).
A multiplexer is connected to the operations which receive a select bit in the processor, which determines which circuit to use to complete the desired operations. Multiplexor can switch to addition and subtraction. In our design, we change the state manually but in a processor, the change happens automatically.
Basically, an instruction decoder is a bridge between the ALU and the control unit. In a computer, all instructions are stored as a binary value, and an instruction decoder receives a signal from memory to interpret the binary values to see what operations to perform. The instruction decoder decodes the signal and tells ALU which circuit to activate to perform the task.
Clock and Program Counter
The clock is a signal which is generated by the clock generator. A clock generator is a digital circuit. The clock is a type of signal that oscillates between a high and low state. The clock signal can be used to stop or start the counter increment on every clock pulse. The program counter can be defined as a special purpose register that is used by the processor to hold data for the next instruction to be executed. To execute any program, the CPU needs to keep track of the address of the next instruction which must be retrieved from the instruction memory, this address is kept in a special register called program counter or PC. While running the current instruction, the CPU updates the PC in one of two ways. If the current process contains no goto directive, the PC is shifted to point to the next instructions and if the current process contains a goto n directive that should be executed, the CPU loads n into the PC.
It is a group of bits that instruct the computer to perform specific operations.
It is a part of the CPU, which handles the operations of the processor. The control unit is responsible for controlling all the tasks that have been sent to the processor. The control unit communicates with the main memory and pulls instructions of the program to the processor instruction register, and based on this register contents, the control produces the control signal or control codes that looks over the execution of these instructions.
Control interprets instructions, controls data flow inside the processor, and gets external instruction which converts to a sequence of control signals. It also controls ALU and registers within the CPU. The control unit is capable of handling multiple tasks such as fetching, decoding, execution handling, and storing results.