Professional Documents
Culture Documents
Chapter 3 (Part I) - CPU Organization
Chapter 3 (Part I) - CPU Organization
Chapter 3 (Part I) - CPU Organization
and Architecture
Chapter 3 (Part I)
CPU Organization
Chere L. (M.Tech)
Lecturer, AASTU
Chapter 1 1
Outline
Introduction
Instruction Set Design Factors
Operand Addressing
CPU (ISA) Organizations
Single accumulator organization
General Register Organization
Stack Based Organization
Summary
1. Introduction
Major Components of CPU
Register
File ALU
Control Unit
2. Instruction Set Design Factors
The Instruction Set Architecture (ISA)
Recall that ISA is the part of the processor that is visible to the
programmer or compiler writer.
The ISA serves as the boundary between software and hardware.
A register-memory architecture
accesses register and memory in one instruction.
No of instructions and accesses to memory is intermediate
Cont. . . Operand Addressing
Implicitly addressing:
Some operands are not explicitly addressed because their location
is specified either by the opcode of the instruction or by an address
assigned to one of the other operands.
In such a case, the operand has an implied address.
If the address is implied then there is no need for a memory or
register address field for the operand in the instruction
Explicitly addressing:
An operand has an address in the instruction
i.e. the operand is explicitly addressed or has an explicit address.
No of Operands that can be explicitly addressed by the instruction
is an important factor and varies amongst different architectures
Cont. . . Operand addressing categories
No of instructions is 8,
However memory access is reduced because it does not uses
memory in ADD and MUL instructions
4. Internal CPU Organization
Instruction format mainly depends on the internal organization of
CPU
From the above discussed ISA design factor Operand Storage in the
CPU (number of address fields in the ISA) is the most distinguishing
factor of internal CPU organization.
The 3 most common types of ISAs (CPU Organization) are the
following:
Single Accumulator
Organization
Stack- based
Organization
a) Single accumulator organization
The accumulator register is used implicitly for processing all
instructions of a program and store the result.
The first ALU operand is always stored into the Accumulator and
the second operand is present either in Registers or in the
Memory.
Advantages
• Efficiency of CPU increases as there are large number of registers are used
• Less memory space is used since the instructions are written in compact way.
Disadvantages
• Require to avoid unnecessary usage of registers. Thus, compilers need to be
more intelligent in this aspect.
• Extra cost -- since large number of registers are used
Cont. . . General purpose Register organization
R1
R2
R3
R4
R5
R6
R7
Load
(7 lines)
SELA { MUX MUX } SELB
3x8 A bus B bus
decoder
SELD
OPR ALU
Output
Cont. . . General purpose Register organization
Components
7 general purpose register
3x8 decoder
Two 3*8 Multiplexer
ALU with 5 bits Opcode
1 bit Input and 1 bit output carries (external)
Clock signal
A common bus system
Cont. . . General purpose Register organization
Organizations
The output of each register connected to two multiplexers (MUX) to
form the two buses A and B.
The selection lines in each multiplexer select one register or the input
data for the particular bus.
The A and B buses form the inputs to a common ALU.
The Opcode selected in the ALU determines the arithmetic or logic
micro-operation that is to be performed.
The result of the microoperation is available for output data and also
goes into the inputs of all the registers.
The register that receives the information from the output bus is
selected and it’s load inputs are activated by the decoder, thus
providing a transfer path for the data between the output bus and the
inputs of the selected destination register
Cont. . . General purpose Register organization
Control word
The combination of the two multiplexer (MUX) selectors (SELA
& SELB), Decoder selector (SELD) and Opcode selector (OPR)
define a 14-bit control word (instruction code)
3 3 3 5
SELA SELB SELD OPR
Three fields contain three bits each, and one field has five bits.
The first two three bits of SELA & SELB are the selector of the source
register for the A input and B input of the ALU respectively.
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.
Cont. . . General purpose Register organization
Binary
Code SELA SELB SELD OPR
000 Input Input None Select Operation Symbol
001 R1 R1 R1 00000 Transfer A TSFA
Note:
When SELA or SELB is 000, the corresponding multiplexer selects the
external input data.
When SELD = 000, no destination register is selected but the contents of the
output bus are available in the external output.
Example of Micro-operation for the CPU
Symbolic Designation
The two operations of a stack are the insertion (PUSH) and deletion
(POP) of items.
Advantages
Very useful feature for nested subroutines, nested loops control
Efficient for arithmetic expression evaluation
Cont. . . Stack based organization
stack Address
63
Flags
FULL EMPTY
Stack pointer 4
SP C 3
B 2
A 1
0
DR
Note that:
SP holds the address of the top of the stack and that M[SP] denotes
the memory word specified by the address presently available in SP.
The first item stored in the stack is at address 1.
The last item is stored at address 0.
If SP reaches 0, the stack is full of items, so the FULL flag is set to 1
When SP reaches 1, the stack is empty and EMPTY flag set to 1 and
FULL is cleared to 0, so that SP points to the word at address 0 and
the stack is marked empty and not full.
If the stack is not full (if FULL = 0), a new item is inserted with a push
operation
Most computers do not provide hardware to check stack overflow
(full stack) or underflow(empty stack)
Cont. . . Stack based organization
Example:
In a 64-word stack, the stack pointer contains 6 bits since 26 = 64.
Because SP has only six bits, it cannot exceed a number greater
than 63 (111111 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 the
one-bit register EMTY is set to 1 when the stack is empty of items
Cont. . . Stack based organization
1000
Program
PC (instructions)
Data
AR
(operands)
3000
SP
stack
3997
3998
3999
4000
4001
DR
Cont. . . Reverse Polish Notation
A stack organization is very effective for evaluating arithmetic
expressions.
Mathematical method of writing arithmetic expression
A + B Infix notation (difficult to evaluate using computer)
Most common method of writing expressions
+ A B Prefix Polish notation
A B + Postfix or reverse Polish notation
very suitable for stack manipulation
Example 1: A * B + C * D
Postfix notation: AB*CD*+
Example 2: (A + B) * [C * (D + E) + F]
Postfix notation: A B + D E + C * F + *
Cont. . . Evaluation of Arithmetic Expressions
6
4 5 5 30
3 3 12 12 12 12 42
3 4 * 5 6 * +
Exercise:
1. Given the arithmetic expression 10 + (2 * 8) - 3
a) Write its postfix format
b) Evaluate the expression using Stack (show all the steps)
39
?
THANKS!!
40