CSE211: COMPUTER ORGANIZATION AND DESIGN
Unit III
Central Processing Unit :
• General Register Organization,
• Stack Organization,
• instruction formats,
• Addressing mode.,
• Data Transfer and Manipulation,
• Program control,
• Reduced Instruction Set Computer and Complex Instruction Set Computer,
• Major components of central processing unit,
• Instruction pipelining
General Register Organization
Clock Input
R1
R2
R3
R4
R5
R6
R7
Load
(7 lines)
SELA { MUX MUX } SELB
3x8 A bus B bus
decoder
SELD
OPR ALU
Output
ALU Control Operations
Encoding of ALU operations Examples of ALU Micro-operations
Register Stack Organization
Memory Stack Organization
Reverse Polish Notation
➢ Any arithmetic expression can be expressed in parenthesis-free Polish
notation, including reverse Polish notation
(3 * 4) + (5 * 6) 34*56*+
Processor Organization
• In general, most processors are organized in one of 3 ways
– Single register (Accumulator) organization
• Basic Computer is a good example
• Accumulator is the only general purpose register
– General register organization
• Used by most modern computer processors
• Any of the registers can be used as the source or destination for computer
operations
– Stack organization
• All operations are done using the hardware stack
Instruction Format
• Instruction Fields
OP-code field - specifies the operation to be performed
Address field - designates memory address(es) or a processor register(s)
Mode field - determines how the address field is to be interpreted (to
get effective address or the operand)
• The number of address fields in the instruction format depends on the internal organization of CPU
• The three most common CPU organizations:
Single accumulator organization:
ADD X /* AC AC + M[X] */
General register organization:
ADD R1, R2, R3 /* R1 R2 + R3 */
ADD R1, R2 /* R1 R1 + R2 */
MOV R1, R2 /* R1 R2 */
ADD R1, X /* R1 R1 + M[X] */
Stack organization:
PUSH X /* TOS M[X] */
ADD
Three & Two Address Instruction
One Address Instruction
• One-Address Instructions
- Use an implied AC register for all data manipulation
- Program to evaluate X = (A + B) * (C + D) :
Zero Address Instruction
• Zero-Address Instructions
- Can be found in a stack-organized computer
- Program to evaluate X = (A + B) * (C + D) :
PUSH A /* TOS A*/
PUSH B /* TOS B*/
ADD /* TOS (A + B) */
PUSH C /* TOS C*/
PUSH D /* TOS D */
ADD /* TOS (C + D) */
MUL /* TOS (C + D) * (A + B) */
POP X /* M[X] TOS*/
Addressing Mode
Addressing Modes
- Specifies a rule for interpreting or modifying the address field of the instruction
(before the operand is actually referenced)
- Variety of addressing modes
- to give programming flexibility to the user
- to use the bits in the address field of the instruction efficiently
1. Implied Mode
- Address of the operands are specified implicitly in the definition of the instruction
- No need to specify address in the instruction
- EA = AC, or EA = Stack[SP]
- Examples from Basic Computer - CLA, CME, INP
2. Immediate Mode
- Instead of specifying the address of the operand, operand itself is specified
- No need to specify address in the instruction
- However, operand itself needs to be specified
- Sometimes, require more bits than the address
- Fast to acquire an operand
Addressing Mode
3. Register Mode
- Address specified in the instruction is the register address
- Designated operand need to be in a register
- Shorter address than the memory address
- Saving address field in the instruction
- Faster to acquire an operand than the memory addressing
- EA = IR(R) (IR(R): Register field of IR)
4. Register Indirect Mode
- Instruction specifies a register which contains the memory address of the operand
- Saving instruction bits since register address is shorter than the memory address
- Slower to acquire an operand than both the register addressing or memory
addressing
- EA = [IR(R)] ([x]: Content of x)
5. Auto increment or Auto decrement Mode
- When the address in the register is used to access memory, the value in the
register is incremented or decremented by 1 automatically
Addressing Mode
6. Direct Address Mode
- Instruction specifies the memory address which can be used directly to access the memory
- Faster than the other memory addressing modes
- Too many bits are needed to specify the address for a large physical memory space
- EA = IR(addr) (IR(addr): address field of IR)
7. Indirect Addressing Mode
- The address field of an instruction specifies the address of a memory location that contains the
address of the operand
- When the abbreviated address is used large physical memory can be addressed with a
relatively small number of bits
- Slow to acquire an operand because of an additional memory access
- EA = M[IR(address)]
Addressing Mode
8. Relative Addressing Modes
- The Address fields of an instruction specifies the part of the address (abbreviated address) which can
be used along with a designated register to calculate the address of the operand
- Address field of the instruction is short
- Large physical memory can be accessed with a small number of address bits
- EA = f(IR(address), R), R is sometimes implied
-3 different Relative Addressing Modes depending on R;
PC Relative Addressing Mode (R = PC)
- EA = PC + IR(address)
Indexed Addressing Mode (R = IX, where IX: Index Register)
- EA = IX + IR(address)
Base Register Addressing Mode
(R = BAR, where BAR: Base Address Register)
- EA = BAR + IR(address)
Address Memory
Addressing Mode - Example 200 Load to AC Mode
PC = 200 201
Address = 500
202 Next instruction
R1 = 400
399 450
XR = 100
400 700
AC
500 800
600 900
Addressing Effective Content 702 325
Mode Address of AC
Direct address 500 /* AC (500) */ 800
Immediate operand - /* AC 500 */ 500 800 300
Indirect address 800 /* AC ((500)) */ 300
Relative address 702 /* AC (PC+500) */ 325
Indexed address 600 /* AC (RX+500) */ 900
Register - /* AC R1 */ 400
Register indirect 400 /* AC (R1) */ 700
Autoincrement 400 /* AC (R1)+ */ 700
Autodecrement 399 /* AC -(R) */ 450
Data Transfer Instructions
Data Transfer Instructions
Data Manipulation Instructions
Arithmetic instructions
Logical and bit manipulation instructions
Shift Instructions
Program Control Instruction
Program Control Instruction
Conditional Branch Instruction
Mnemonic Branch condition Tested condition
BZ Branch if zero Z=1
BNZ Branch if not zero Z=0
BC Branch if carry C=1
BNC Branch if no carry C=0
BP Branch if plus S=0
BM Branch if minus S=1
BV Branch if overflow V=1
BNV Branch if no overflow V=0
Unsigned compare conditions (A - B)
BHI Branch if higher A>B
BHE Branch if higher or equal AB
BLO Branch if lower A<B
BLOE Branch if lower or equal AB
BE Branch if equal A=B
BNE Branch if not equal AB
Signed compare conditions (A - B)
BGT Branch if greater than A>B
BGE Branch if greater or equal AB
BLT Branch if less than A<B
BLE Branch if less or equal AB
BE Branch if equal A=B
BNE Branch if not equal AB
Subroutine Call and Return
Flag, Processor Status Word
RISC- Historical Background
IBM System/360, 1964
• The real beginning of modern computer architecture
• Distinction between Architecture and Implementation
• Architecture: The abstract structure of a computer seen by an assembly-language programmer
-program Hardware
Compiler Instruction
High-Level
Set Hardware
Language
Architecture
Hardware
Implementation
• Continuing growth in semiconductor memory and microprogramming
A much richer and complicated instruction sets
CISC(Complex Instruction Set Computer)
Complex Instruction Set Computers
Arguments Advanced at that time
• Richer instruction sets would simplify compilers
• Richer instruction sets would alleviate the software crisis
– move as much functions to the hardware as possible
• Richer instruction sets would improve architecture quality
• These computers with many instructions and addressing modes came to
be known as Complex Instruction Set Computers (CISC)
• One goal for CISC machines was to have a machine language instruction
to match each high-level language statement type
Complex Instruction Set Computers
• Another characteristic of CISC computers is that they have instructions that act directly on memory
addresses
– For example,
ADD L1, L2, L3
that takes the contents of M[L1] adds it to the contents of M[L2] and stores the result in location M[L3]
• An instruction like this takes three memory access cycles to execute
• That makes for a potentially very long instruction execution cycle
• The problems with CISC computers are
– The complexity of the design may slow down the processor,
– The complexity of the design may result in costly errors in the processor design and implementation,
– Many of the instructions and addressing modes are used rarely, if ever
Complex Instruction Set Computers
High Performance General Purpose Instructions
- Complex Instruction
→ Format, Length, Addressing Modes
→ Complicated instruction cycle control due to the complex decoding HW and decoding process
- Multiple memory cycle instructions
→ Operations on memory data
→ Multiple memory accesses/instruction
- Microprogrammed control is necessity
→ Microprogram control storage takes substantial portion of CPU chip area
→ Semantic Gap is large between machine instruction and microinstruction
- General purpose instruction set includes all the features required by individually different
applications
→ When any one application is running, all the features required by the other applications are extra burden
to the application
Complex Instruction Set Computers
Common features of CISC:
• many instructions that access memory directly
• large number of addressing modes
• variable length instruction encoding
• support for misaligned accesses
RISC – Reduced Instruction Set Computers
• In the late ‘70s and early ‘80s there was a reaction to the shortcomings of the CISC style of processors
• Reduced Instruction Set Computers (RISC) were proposed as an alternative
• The underlying idea behind RISC processors is to simplify the instruction set and reduce instruction
execution time
• RISC processors often feature:
– Few instructions
– Few addressing modes
– Only load and store instructions access memory
– All other operations are done using on-processor registers
– Fixed length instructions
– Single cycle execution of instructions
– The control unit is hardwired, not microprogrammed
RISC – Reduced Instruction Set Computers
RISC – Reduced Instruction Set Computers
RISC – Reduced Instruction Set Computers
Common RISC characteristics
• Load/store architecture
(also called register-register or RR architecture) which fetches operands and results indirectly from
main memory through a lot of scalar registers. Other architecture is storage-storage or SS in which
source operands and final results are retrieved directly from memory.
• Fixed length instructions
(a) which are easier to decode than variable length instructions, and
(b) use fast, inexpensive memory to execute a larger piece of code.
• Hardwired controller instructions
(as opposed to micro coded instructions). This is where RISC really shines as hardware
implementation of instructions is much faster and uses less silicon real estate than a micro store
area.
RISC – Reduced Instruction Set Computers
Common RISC characteristics
• Fused or compound instructions which are heavily optimized for
the most commonly used functions.
• Pipelined implementations with goal of executing one instruction
(or more) per machine cycle.
• Large uniform register set
• minimal number of addressing modes
• no/minimal support for misaligned accesses
Characteristics
- Single computer containing a control unit, processor and memory unit
- Instructions and data are stored in memory and executed sequentially
- may or may not have parallel processing
- parallel processing can be achieved by pipelining
SIMD
Characteristics
- Only one copy of the program exists
- A single controller executes one instruction at a time
Pipelining
A technique of decomposing a sequential process into sub operations, with each sub process being
executed in a special dedicated segment that operates concurrently with all other segments.
- It is the characteristic of pipelining that several computations can be in progress in distinct segments at
the same time.
- Each segment performs partial processing dictated by the way the task is dictated
- The result obtained from computation is in each segment is transferred to next segment in the
pipeline
- The final result is obtained after data has been passed through all segment
Pipelining
Simplest way to understand pipelining is to imagine that each segment consist of input register followed by
combinational circuit. The o/p of combinational circuit in a segment is applied to i/p register of next
segment Ai * Bi + Ci for i = 1, 2, 3, ... , 7
Ai Bi Memory Ci
Segment 1
R1 R2
Multiplier
Segment 2
R3 R4
Adder
Segment 3
R5
R1 Ai, R2 Bi Load Ai and Bi
R3 R1 * R2, R4 Ci Multiply and load Ci
R5 R3 + R4 Add
Operations in each Pipeline Stage
Pipeline Speedup
Pipeline Speedup