Академический Документы
Профессиональный Документы
Культура Документы
• Introduction
• Stack Organization
• Instruction Formats
• Addressing Modes
• Program Control
1
Central Processing Unit Introduction
Transfer Components
Bus
Control Components
Control Unit
Register
File ALU
Control Unit
2
Central Processing Unit 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
3
Central Processing Unit Control
ALU CONTROL
Encoding of ALU operations OPR
Select Operation Symbol
00000 Transfer A TSFA
00001 Increment A INCA
00010 ADD A + B ADD
00101 Subtract A - B SUB
00110 Decrement A DECA
01000 AND A and B AND
01010 OR A and B OR
01100 XOR A and B XOR
01110 Complement A COMA
10000 Shift right A SHRA
11000 Shift left A SHLA
5
Central Processing Unit Stack Organization
FULL EMPTY
Stack pointer 4
SP C 3
B 2
A 1
Push, Pop operations 0
DR
/* Initially, SP = 0, EMPTY = 1, FULL = 0 */
PUSH POP
SP ← SP + 1 DR ← M[SP]
M[SP] ← DR SP ← SP – 1
If (SP = 0) then (FULL ← 1) If (SP = 0) then (EMPTY ← 1)
EMPTY ← 0 FULL ← 0
6
Central Processing Unit Stack Organization
3000
stack
3997
SP 3998
3999
4000
- A portion of memory is used as a stack 4001
with a processor register as a stack pointer DR
- PUSH: SP ← SP - 1
M[SP] ← DR
- POP: DR ← M[SP]
SP ← SP + 1
(3 * 4) + (5 * 6) ⇒ 34*56*+
6
4 5 5 30
3 3 12 12 12 12 42
3 4 * 5 6 * +
8
Central Processing Unit Instruction Format
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 - specifies the way the operand or the
effective address is determined
Program to evaluate X = (A + B) * (C + D) :
ADD R1, A, B /* R1 ← M[A] + M[B] */
ADD R2, C, D /* R2 ← M[C] + M[D] */
MUL X, R1, R2 /* M[X] ← R1 * R2 */
Two-Address Instructions
Program to evaluate X = (A + B) * (C + D) :
10
Central Processing Unit Instruction Format
ADDRESSING MODES
Addressing Modes
12
Central Processing Unit Addressing Modes
Implied Mode
Opcode Mode
Immediate Mode
13
Central Processing Unit Addressing Modes
Opcode Mode R1
Register field
R1
Mem Address Operand
14
Central Processing Unit Addressing Modes
Opcode Mode R1
Memory
R1
Before memory access Address Operand
R1
After memory access Address + 1
15
Central Processing Unit Addressing Modes
Operand
100
100 Operand
16
Central Processing Unit Addressing Modes
+ Operand
PC
17
Central Processing Unit Addressing Modes
+ Operand
Index Register
18
Central Processing Unit Addressing Modes
+ Operand
Base Register
19
Central Processing Unit Addressing Modes
399 450
XR = 100
400 700
AC
500 800
600 900
21
Central Processing Unit Data Transfer and Manipulation
A B
Status Flag Circuit 8 8
c7
c8 8-bit ALU
F7 - F0
V Z S C
F7
Check for 8
zero output
F
23
Central Processing Unit Program Control
24
Central Processing Unit
Subroutines
• Subroutine Call
– SP Í SP -1
– M[SP] Í PC
– PC Í EA
• Return From Subroutine
– PC Í M[SP]
– SP Í SP+1
25
Central Processing Unit
PROGRAM INTERRUPT
Types of Interrupts:
26
Central Processing Unit
INTERRUPT PROCEDURE
• Interrupt Procedure and Subroutine Call
– The interrupt is usually initiated by an internal or an external signal rather
than from the execution of an instruction (except for the software interrupt)
– The address of the interrupt service program is determined by the
hardware rather than from the address field of an instruction
27
Central Processing Unit
Compiler µ-program
High-Level Instruction
Language Hardware
Set
Architecture Implementation
28
Central Processing Unit
CISC Features
Characteristics of CISC:
1. A large number of instructions (from 100-250 usually)
2. Some instructions that performs a certain tasks are not used frequently
3. Many addressing modes are used (5 to 20)
4. Variable length instruction format
5. Instructions that manipulate operands in memory
29
Central Processing Unit
PHYLOSOPHY OF RISC
• Reduce the semantic gap between machine instruction and µ-instruction
– 1-Cycle instruction
– Most instructions complete their execution in 1 CPU clock cycle - like a µ-operation
• Register-Register Instructions
– Avoid memory reference instructions except Load and Store instructions
– Most of the operands can be found in the registers instead of main memory
» Shorter instructions
» Uniform instruction cycle
» Requirement of large number of registers
•
• Employ instruction pipeline
30
Central Processing Unit
RISC Features
31
Central Processing Unit
32
Central Processing Unit
Berkeley RISC I
8 5 5 1 8 5
Register Mode
OP Code Rd Rs 1 S2
Register-immediate Mode
OP Code COND Y
PC Relative Mode
33
Central Processing Unit
Example Instructions
• Manipulation
– ADD Rs,S2,Rd // Rd Å Rs + S2
– XOR Rs,S2,Rd // Rd Å Rs XOR S2
– SRA Rs,S2,Rd // Rd Å Rs shifted by S2 (arithmetic shift)
• Transfer
– LDL (Rs)S2,Rd // Rd Å M[ Rs + S2 ]
– STL Rd, (Rs)S2 // M[ Rs +S2 ] Å Rd
• Program Control
– JMP COND,S2(Rs) // PC Å Rs + S2
– CALL Rd,S2(Rs) // Rd Å PC, PC Å Rs + S2, CWP Å CWP-1
– CALLR Rd,Y // Rd Å PC, PCÅ Y+PC, CWPÅ CWP-1
– RET Rd,S2 // PC Å Rd + S2, CWP Å CWP+1
34