CAO - Processor Organization and Control Unit
CAO - Processor Organization and Control Unit
• General Purpose
• Data
• Address
• Condition Codes
General Purpose Registers
May be true general purpose
can be assigned to a variety of functions by the programmer
May be used for data or addressing
Data
used to hold only data and cannot be employed in the
calculation of an operand address.
Addressing
Segment pointers
Index registers
Stack Pointer
Condition Code Registers
• Sets of individual bits
– e.g. result of last operation was zero
• Can be read (implicitly) by programs
– e.g. Jump if zero
• Can not (usually) be set by programs
Program Status Word
• A set of bits Includes Condition Codes
• Sign of last result
• Zero
• Carry
• Equal
• Overflow
• Interrupt enable/disable
• Supervisor
Supervisor Mode
• Kernel mode
• Allows privileged instructions to execute
• Used by operating system
• Not available to user programs
Control & Status Registers
• Program Counter
• Instruction Decoding Register
• Memory Address Register
• Memory Buffer Register
18
Features of an ISA – II
Concise
The instruction set should have a limited size.
Typically an ISA contains 32-1000 instructions.
Generic
Instructions should not be too specialized, e.g.
add14 (adds a number with 14) instruction is
too specialized
Simple
Should not be very complicated.
19
Designing an ISA
Important questions that need to be
answered :
How many instructions should we have ?
What should they do ?
How complicated should they be ?
RISC CISC
(Reduced Instruction Set (Complex Instruction
Computer) Set Computer)
20
RISC vs CISC
A reduced instruction set computer (RISC) implements
simple instructions that have a simple and regular
structure. The number of instructions is typically a small
number (64 to 128). Examples: ARM, IBM PowerPC,
HP PA-RISC
21
Completeness of an ISA
Complete means :
Can implement all types of programs
For example, if we just have add instructions,
we cannot subtract (NOT Complete)
22
Completeness of an ISA – II
23
Let us now design an ISA ...
1: sbn temp, b, 2
2: sbn a, temp, exit
24
Single Instruction ISA - II
Add the numbers – 1 … 10
Initialization:
one = 1
index = 10
sum = 0
exit
25
Multiple Instruction ISA
Arithmetic Instructions
add, subtract, multiply, divide
Logical Instructions
or, and, not
Move instructions
Transfer values between memory locations
Branch instructions
Move to a new program location, based on the values of some
memory locations
26
CISC RISC
• It consists of a large set of • It consists of small set of
instructions with variable instructions with fixed format
formats (Typically 16 to 64 bits and these instructions are of
per instruction) register based instructions.
• It has higher number of • It has a limited number of
addressing modes, typically 12 addressing modes, typically 3 to
to 24. 5.
• It consists of complex • It consists of simple instructions
instructions that take multiple that take single cycle to
cycles to execute execute.
• Instructions are not pipelined or • Instructions are pipelined
less pipelined • Complexity lies the compiler
• Complexity lies in microprogram
Instruction Cycle
Fetch
Read next instruction from memory into the processor
Indirect Cycle (Decode Cycle)
May require memory access to fetch operands, therefore more
memory accesses.
Interrupt
Save current instruction and service the interrupt
Execute
Interpret the opcode and perform the indicated operation
Indirect Cycle
• May require memory access to fetch operands
• Indirect addressing requires more memory
accesses
• Can be thought of as additional instruction
subcycle
Instruction Cycle with Indirect
Instruction Cycle State Diagram
Data Flow (Instruction Fetch)
• Depends on CPU design
• In general:
• Fetch
– PC contains address of next instruction
– Address moved to MAR
– Address placed on address bus
– Control unit requests memory read
– Result placed on data bus, copied to MBR, then to IR
– Meanwhile PC incremented by 1
Data Flow (Data Fetch)
• IR is examined
• If indirect addressing, indirect cycle is
performed
– Right most N bits of MBR transferred to MAR
– Control unit requests memory read
– Result (address of operand) moved to MBR
Data Flow (Fetch Diagram)
PC MAR
Memory
Control
Unit
MBR
IR MBR
Data Flow (Indirect Diagram)
MAR
Memory
Memory
Control
Unit
MBR
MBR
Data Flow (Execute)
• May take many forms
• Depends on instruction being executed
• May include
– Memory read/write
– Input/Output
– Register transfers
– ALU operations
Data Flow (Interrupt)
• Simple
• Predictable
• Current PC saved to allow resumption after interrupt
• Contents of PC copied to MBR
• Special memory location (e.g. stack pointer) loaded to
MAR
• MBR written to memory
• PC loaded with address of interrupt handling routine
• Next instruction (first of interrupt handler) can be
fetched
Data Flow (Interrupt Diagram)
PC
PC MAR
Memory
Control
Control
Unit
Unit
MBR
Control Unit Design
DESIGN ISSUES OF RISC PROCESSOR
Characteristic of RISC
• Although a variety of different approaches to
reduce Instruction set architecture have been
taken, certain characteristics are common to
all of them:
– One instruction per cycle.
– Register–to–register operations.
– Simple addressing modes.
– Simple instruction formats.
Characteristic of RISC cont.d
1. One machine instruction per machine cycle :
• A machine cycle is defined to be the time it takes to fetch two operands
from registers, perform an ALU operation, and store the result in a
register.
With simple, one-cycle instructions there is little or no need of microcode,
the machine instructions can be hardwired. Hardware implementation of
control unit executes faster than the microprogrammed control, because it
is not necessary to access a microprogram control store during instruction
execution.
• One Cycle Execution Time. RISC processors have a CPI (clock per
instruction) of one cycle. This is due to the optimization of each
instruction on the CPU
2. Register –to– register operations
• With register–to–register operation, a simple LOAD and STORE operation
is required to access the memory, because most of the operation are
register–to-register. Generally we do not have memory–to–memory and
mixed register/memory operation.
Characteristic of RISC cont.d
3. Simple Addressing Modes
• Almost all RISC instructions use simple register addressing. For
memory access only, we may include some other addressing, such
as displacement and PC-relative. Once the data are fetched inside
the CPU, all instruction can be performed with simple register
addressing.
4. Simple Instruction Format
• Generally in most of the RISC machine, only one or few formats are
used. Instruction length is fixed and aligned on word boundaries.
Field locations, especially the opcode, are fixed.
With fixed fields, opcode decoding and register operand accessing
can occur simultaneously. Simplified formats simplify the control
unit.
CISC
• Intel IA-32, belongs to the Complex Instruction
Set Computer (CISC) design.
• The obvious reason for this classification is the
“complex” nature of its Instruction Set
Architecture (ISA). The motivation for designing
such complex instruction sets is to provide an
instruction set that closely supports the
operations and data structures used by Higher-
Level Languages (HLLs).
• However, the side effects of this design effort are
far too serious to ignore.
Addressing Modes in CISC
• The decision of CISC processor designers to
provide a variety of addressing modes leads to
variable-length instructions. For example,
instruction length increases if an operand is in
memory as opposed to in a register.
a) This is because we have to specify the memory
address as part of instruction encoding, which takes
many more bits.
b) This complicates instruction decoding and
scheduling. The side effect of providing a wide range
of instruction types is that the number of clocks
required to execute instructions varies widely.
c) This again leads to problems in instruction
scheduling and pipelining.
• Because CISC and RISC have their advantages
and disadvantages, modern processors take
features from both classes. For example, the
PowerPC, which follows the RISC philosophy,
has quite a few complex instructions.
RISC Vs CISC: An Example
• Multiplying Two Numbers in Memory. The main
memory is divided into locations numbered from (row)
1: (column) 1 to (row) 6: (column) 4.
• The execution unit is responsible for carrying out all
computations.
• However, the execution unit can only operate on data
that has been loaded into one of the six registers (A, B,
C, D, E, or F).
• Let's say we want to find the product of two numbers -
one stored in location 2:3 and another stored in
location 5:2 - and then store the product back in the
location 2:3
• The CISC Approach. The primary goal of CISC
architecture is to complete a task in as few lines of
assembly as possible. This is achieved by building
processor hardware that is capable of understanding
and executing a series of operations.