Docsity

CPU Architecture: Micro-operations, Control Unit, and Stack Organization - Prof. Rufe, Summaries of Operating Systems

Partial preview of the text

Download CPU Architecture: Micro-operations, Control Unit, and Stack Organization - Prof. Rufe and more Summaries Operating Systems in PDF only on Docsity!

UNIT - V

CENTRAL

PROCESSING

UNIT (CPU)

Introduction

What is CPU?

CPU is actually the main brain of the computer system.

It is here that the whole processing takes place.

It consists of 4 main units: Primary storage, Arithmetic

logic unit, control unit and output unit

 Primary storage unit: this is main storage area,

which is also called the main memory area. Its main

functions are 1) holding the data in its memory till it is

required to be processed. 2) holding the result of the

processed data 3) holding program instructions which

are required for processing.

 Arithmetic logic unit: this is used for the most of the

logical processing, for example, for calculations or

comparisons. The arithmetic operations like, +, -,*,

and / are performed here.

Cont’d The design of a CPU is a task that in large part involves choosing the hardware for implementing the machine instructions. The user who programs the computer in machine or assembly language must be aware of the register set, the memory structure, the type of data supported by the instructions and the function that each instruction performs.

General Register Organization

The registers communicate with each other not only

for direct data transfers, but also while performing

various micro-operations.

(the most basic operation achievable by a processor).

The operation selected in the ALU determines the

arithmetic or logic micro-operation that is to be

performed.

The result of the micro-operation is available for

output data and also goes into the inputs of all the

registers.

Cont’d  There are 14 binary selection inputs in the unit, and their combined value specifies a control word.  It consists of four fields. Three fields contain three bits each, and one field has five bits.  The three bits of SELA select a source register for the A input of the ALU. The three bits of SELB select a register for the B input of the ALU.  The three bits of SELD select a destination register using the decoder and its seven load outputs.  The five bits of OPR select one of the operations in the ALU.  The 14-bit control word when applied to the selection inputs specify a particular micro-operation.  The encoding of the register selections is specified in figures.

Cont’d

  • (^) The control must provide binary selection variables to the following selector inputs: - (^) MUX A selector (SELA): to place the content

of R2 into bus A.

  • (^) MUX B selector (SELB): to place the content

o f R 3 into bus B.

  • (^) ALU operation selector (OPR): to provide the

arithmetic subtraction A -B.

  • (^) Decoder destination selector (SELD): to

transfer the content of the output bus into R

  • (^) The four control selection variables are generated

in the control unit and must be available at the

beginning of a clock cycle.

  • (^).

Symbolic designation  (^) Microoperation SELA SELB SELD OPR Control word  (^) R1 R2-R3 R2 R3 R1 SUB 010 011 001 00101  (^) R4  R4 V R5 R4 R5 R4 OR 100 101 100 01010  (^) R6  R6 +1 R6 -- R6 INCA 110 000 110 00001  (^) R7  R1 R1 -- R7 TSFA 001 000 111 00000  (^) Output  R2 R2 -- None TSFA 010 000 000 00000  (^) Output input input -- None TSFA 000 000 000 00000  (^) R4  sh1 R4 R4 -- R4 SHLA 100 000 100

Stack Organization A stack is a storage device that stores information in such a manner that the item stored last in the first item retrieved(LIFO). The operation of a stack can be compared to a stack of trays. The last tray placed on top of the stack is the first to be taken off. The register that holds the address for the stack is called a stack pointer(SP). Because its value always points at the top item in the stack. The two operations of a stack are the insertion and deletion of items. The operation of insertion is called push(as the result of pushing a new item on top. The operation of deletion is called pop(as the result of removing one item).

Cont’d There are two types of stack organization

**_1. Register stack: built using registers

  1. Memory stack: Logical part of memory_** allocated as stack Register stack: A stack can be placed in a portion of a large memory or it can be organized as a collection of a finite number of memory words or register. For example, consider the organization of a 64 word register stack. The stack pointer register SP contains a binary number whose value is equal to the address of the word that is currently on top of the stack.

Cont’d  Three items are placed in the stack: A, B and C. Item C is on top of the stack so that the content of SP is now 3. To remove the top item, the stack is popped by reading the memory word at address 3 and decrementing the content of SP. Item B is now on top of the stack since SP holds address 2. To insert a new item, the stack is pushed by incrementing SP and writing a word in the next higher location of the stack. Note that item C has been read out but not physically removed. This does not matter because when the stack is pushed, a new item is written in its place

Cont’d In a 64 word stack, the stack pointer contains 6 bits because 2 6 =64. Since SP has only six bits, it cannot exceed a number greater than 63 ( in binary). When 63 is incremented by 1, the result is 0 since 111111 +1=1000000 in binary, but SP can accommodate only the six least significant bits. Similarly, when 000000 is decremented by 1, the result is 111111. The one bit register FULL is set to 1 when the stack is full, and one bit register EMTY is set to 1 when the stack is empty of items. DR is the data register that holds the binary data to be written into or read out of the stack.

Cont’d

The pop operation consists of the following sequence of micro operations:  DR  M[SP] Read item from the top of stack SP  SP-1 Decrement stack pointer If (SP=0) then (EMTY  1) check if stack is empty FULL  0 Mark the stack not full

Memory Stack:

The implementation of a stack in the CPU is done by assigning a portion

of memory to a stack operation and using a processor register as a stack

pointer.

A portion of computer memory partitioned into three segments:

program, data and stack.

The program counter PC points at the address of the next instruction in

the program.

the stack pointer SP points at the top of the stack.

PC is used during the fetch phase to read an instruction.

SP is used to push or pop items into or from the stack.