Central Processing Unit
The CPU

Central Processing Unit

The central processing unit (CPU) is the part of the computer that performs the bulk of data processing operations. It is composed of three major components:

  1. Register Set: Stores intermediate data used during the execution of instructions.
  2. Arithmetic Logic Unit (ALU): Performs the required micro-operations for executing the instructions.
  3. Control Unit: Supervises the transfer of information among the registers and instructs the ALU on which operation to perform.
Hello

CPU Functions and Architecture

The CPU executes a variety of functions dictated by the types of instructions incorporated in the computer's architecture. Computer architecture is defined as the structure and behavior of the computer as perceived by a programmer using machine language instructions. This includes:

  • Instruction formats
  • Addressing modes
  • Instruction set
  • Organization of CPU registers

Instruction Set

The instruction set of a CPU provides the specifications for the design and operation of the CPU. It defines how machine instructions are implemented in hardware. The user programming the computer in machine or assembly language must understand:

  • The register set
  • Memory structure
  • Data types supported by the instructions
  • Functions performed by each instruction

General Register Organization

In programming, memory locations are often used to store pointers, counters, return addresses, temporary results, and partial products during multiplication. Accessing these memory locations is time-consuming. It is more efficient to store intermediate values in processor registers. When a large number of registers are included in the CPU, connecting them through a common bus system is most efficient.

Bus System

A bus organization for CPU registers facilitates direct data transfers and various micro-operations. Consider a bus system for seven CPU registers:

  1. Multiplexers (MUX): The output of each register is connected to two multiplexers to form buses A and B. Selection lines in each multiplexer select one register or input data for the particular bus.
  2. ALU: The ALU performs arithmetic or logic micro-operations. The result is available for output data and is also fed back into the input of all registers.
  3. Decoder: Selects the register that receives the information from the output bus.

Example Micro-Operation

To perform the operation R1R2+R3R1 \leftarrow R2 + R3:

  1. MUX A selector (SELA): Places the content of R2R2 into bus A.
  2. MUX B selector (SELB): Places the content of R3R3 into bus B.
  3. ALU operation selector (OPR): Performs the addition A+BA + B.
  4. Decoder destination selector (SELD): Transfers the content of the output bus into R1R1.

The control unit generates these selection variables at the beginning of a clock cycle. Data from the source registers propagate through the multiplexers and ALU to the output bus and into the destination register during the clock cycle interval. At the next clock transition, the data is transferred into R1R1.

Control Word

A 14-bit control word specifies a micro-operation in the CPU. It consists of four fields:

  • SELA: Selects the source register for the ALU's A input.
  • SELB: Selects the source register for the ALU's B input.
  • SELD: Selects the destination register using the decoder.
  • OPR: Specifies the ALU operation.
Hello

For example, the subtract micro-operation R1R2R3R1 \leftarrow R2 - R3 is specified by the control word 010 011 001 00101, derived as follows:

Hello
  • SELA (R2): 010
  • SELB (R3): 011
  • SELD (R1): 001
  • OPR (SUB): 00101

Register and ALU Operation Encoding

Register Selection Fields

Binary CodeSELASELBSELD
000InputInputNone
001R1R1R1
010R2R2R2
011R3R3R3
100R4R4R4
101R5R5R5
110R6R6R6
111R7R7R7

ALU Operations Encoding

OPROperation SymbolDescription
00000TSFATransfer A
00001INCAIncrement A
00010ADDAdd A + B
00101SUBSubtract A - B
00110DECADecrement A
01000ANDAND A and B
01010OROR A and B
01100XORXOR A and B
01110COMAComplement A
10000SHRAShift right A
11000SHLAShift left A

Examples of Micro-Operations

Examples of control words for various micro-operations:

Symbolic DesignationMicro-OperationSELASELBSELDOPRControl Word
R1R2R3R1 \leftarrow R2 - R3R2 - R301001100100101010 011 001 00101
R4R4R5R4 \leftarrow R4 \vee R5R4 OR R510010110001010100 101 100 01010
R6R6+1R6 \leftarrow R6 + 1Increment R6110-11000001110 000 110 00001
R7R1R7 \leftarrow R1Transfer R1 to R7001-11100000001 000 111 00000
OutputOutput R2\leftarrow R2 Output R2010--00000010 000 000 00000
R4SHL R4R4 \leftarrow \text{SHL } R4Shift left R4100-10011000100 000 100 11000
R50R5 \leftarrow 0Clear R5101-10101100101 000 101 01100

Microprogrammed Control

The most efficient way to generate control words with a large number of bits is to store them in a memory unit, referred to as control memory. By reading consecutive control words from memory, a desired sequence of micro-operations can be initiated for the CPU. This type of control is known as microprogrammed control.