Professional Documents
Culture Documents
Instruction Formats
Addressing Modes
Computer Organization
Introduction
Transfer Components
Bus
Control Components
Control Unit
Register
File
ALU
Control Unit
Computer Organization
REGISTERS
In Basic Computer, there is only one general purpose register,
the Accumulator (AC)
In modern CPUs, there are many general purpose registers
It is advantageous to have many registers
Transfer between registers within the processor are relatively fast
Going off the processor to access memory is much slower
Computer Organization
Clock
R1
R2
R3
R4
R5
R6
R7
Load
(7 lines)
SELA
3x8
decoder
MUX
MUX
A bus
SELD
OPR
} SELB
B bus
ALU
Output
Computer Organization
Control
3
SELA
3
SELB
3
SELD
5
OPR
SELA
Input
R1
R2
R3
R4
R5
R6
R7
SELB
Input
R1
R2
R3
R4
R5
R6
R7
SELD
None
R1
R2
R3
R4
R5
R6
R7
Computer Architectures Lab
Control
ALU CONTROL
Encoding of ALU operations
OPR
Select
00000
00001
00010
00101
00110
01000
01010
01100
01110
10000
11000
Operation
Transfer A
Increment A
ADD A + B
Subtract A - B
Decrement A
AND A and B
OR A and B
XOR A and B
Complement A
Shift right A
Shift left A
Symbol
TSFA
INCA
ADD
SUB
DECA
AND
OR
XOR
COMA
SHRA
SHLA
Computer Organization
SELA SELB
R2
R4
R6
R1
R2
Input
R4
R5
R3
R5
R5
SELD
OPR
Control Word
R1
R4
R6
R7
SUB
OR
INCA
TSFA
010
100
110
001
011
101
000
000
001
100
110
111
00101
01010
00001
00000
None
None
R4
R5
TSFA
TSFA
SHLA
XOR
010
000
100
101
000
000
000
101
000
000
100
101
00000
00000
11000
01100
Stack Organization
Register Stack
63
Flags
FULL
Address
EMPTY
Stack pointer
SP
6 bits
C
B
A
4
3
2
1
0
DR
PUSH
SP SP + 1
M[SP] DR
If (SP = 0) then (FULL 1)
EMPTY 0
Computer Organization
POP
DR M[SP]
SP SP 1
If (SP = 0) then (EMPTY 1)
FULL 0
Computer Architectures Lab
Stack Organization
PC
Program
(instructions)
AR
Data
(operands)
SP
3000
stack
3997
3998
3999
4000
4001
Stack grows
In this direction
SP SP - 1
M[SP] DR
- POP:
DR M[SP]
SP SP + 1
- Most computers do not provide hardware to check stack overflow (full
stack) or underflow (empty stack) must be done in software
- PUSH:
Computer Organization
Stack Organization
Infix notation
Prefix or Polish notation
Postfix or reverse Polish notation
- The reverse Polish notation is very suitable for stack
manipulation
(3 * 4) + (5 * 6)
34*56*+
4
3
12
5
12
6
5
12
Computer Organization
30
12
42
10
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
Stack organization
All operations are done using the hardware stack
For example, an OR instruction will pop the two top elements from the
stack, do a logical OR on them, and push the result on the stack
Computer Organization
11
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
- determines how the address field is to be interpreted (to
get effective address or the operand)
12
Instruction Format
*/
*/
*/
Two-Address Instructions
Program to evaluate X = (A + B) * (C + D) :
MOV
ADD
MOV
ADD
MUL
MOV
Computer Organization
R1, A
R1, B
R2, C
R2, D
R1, R2
X, R1
/* R1 M[A]
/* R1 R1 + M[A]
/* R2 M[C]
/* R2 R2 + M[D]
/* R1 R1 * R2
/* M[X] R1
*/
*/
*/
*/
*/
*/
Computer Architectures Lab
13
Instruction Format
Zero-Address Instructions
- Can be found in a stack-organized computer
- Program to evaluate X = (A + B) * (C + D) :
PUSH
PUSH
ADD
PUSH
PUSH
ADD
MUL
POP
Computer Organization
A
B
C
D
X
/*
/*
/*
/*
/*
/*
/*
/*
TOS A
*/
TOS B
*/
TOS (A + B)
*/
TOS C
*/
TOS D
*/
TOS (C + D)
*/
TOS (C + D) * (A + B) */
M[X] TOS
*/
Computer Architectures Lab
14
Addressing Modes
ADDRESSING MODES
Addressing Modes
* Specifies a rule for interpreting or modifying the
address field of the instruction (before the operand
is actually referenced)
Computer Organization
15
Addressing Modes
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
Computer Organization
16
Addressing Modes
Indirect Mode
17
Addressing Modes
Computer Organization
18
Addressing Modes
Computer Organization
19
Addressing Modes
ADDRESSING MODES
- EXAMPLES Address
PC = 200
200
201
202
Memory
Load to AC Mode
Address = 500
Next instruction
R1 = 400
XR = 100
399
400
450
700
500
800
600
900
702
325
800
300
AC
Addressing
Effective
Mode
Address
Direct address
500
Immediate operand Indirect address
800
Relative address
702
Indexed address
600
Register
Register indirect
400
Autoincrement
400
Autodecrement
399
Computer Organization
/* AC (500)
/* AC 500
/* AC ((500))
/* AC (PC+500)
/* AC (RX+500)
/* AC R1
/* AC (R1)
/* AC (R1)+
/* AC -(R)
*/
*/
*/
*/
*/
*/
*/
*/
*/
Content
of AC
800
500
300
325
900
400
700
700
450
20
Mnemonic
LD
ST
MOV
XCH
IN
OUT
PUSH
POP
Mode
Computer Organization
Register Transfer
AC M[ADR]
AC M[M[ADR]]
AC M[PC + ADR]
AC NBR
AC M[ADR + XR]
AC R1
AC M[R1]
AC M[R1], R1 R1 + 1
R1 R1 - 1, AC M[R1]
Computer Architectures Lab
21
Arithmetic Instructions
Name
Increment
Decrement
Add
Subtract
Multiply
Divide
Add with Carry
Subtract with Borrow
Negate(2s Complement)
Mnemonic
INC
DEC
ADD
SUB
MUL
DIV
ADDC
SUBB
NEG
Shift Instructions
Name
Logical shift right
Logical shift left
Arithmetic shift right
Arithmetic shift left
Rotate right
Rotate left
Rotate right thru carry
Rotate left thru carry
Mnemonic
SHR
SHL
SHRA
SHLA
ROR
ROL
RORC
ROLC
22
c7
c8
V Z S C
8-bit ALU
F7 - F0
F7
8
Check for
zero output
F
Computer Organization
23
Program Control
Mnemonic
BR
JMP
SKP
CALL
RTN
CMP
TST
24
Program Control
BZ
BNZ
BC
BNC
BP
BM
BV
BNV
Branch if zero
Branch if not zero
Branch if carry
Branch if no carry
Branch if plus
Branch if minus
Branch if overflow
Branch if no overflow
Tested condition
Z=1
Z=0
C=1
C=0
S=0
S=1
V=1
V=0
Computer Organization
25
Program Control
Computer Organization
CALL
SP SP - 1
M[SP] PC
PC EA
RTN
PC M[SP]
SP SP + 1
Computer Architectures Lab
26
Program Control
PROGRAM INTERRUPT
Types of Interrupts
External interrupts
External Interrupts initiated from the outside of CPU and Memory
- I/O Device Data transfer request or Data transfer complete
- Timing Device Timeout
- Power Failure
- Operator
Software Interrupts
Both External and Internal Interrupts are initiated by the computer HW.
Software Interrupts are initiated by the executing an instruction.
- Supervisor Call Switching from a user mode to the supervisor mode
Allows to execute a certain class of operations
which are not allowed in the user mode
Computer Organization
27
Program Control
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
- An interrupt procedure usually stores all the
information necessary to define the state of CPU
rather than storing only the PC.
The state of the CPU is determined from;
Content of the PC
Content of all processor registers
Content of status bits
Many ways of saving the CPU state
depending on the CPU architectures
Computer Organization
28
RIS
C
-program
Compiler
Instruction
Set
Hardware
Architecture
Hardware
Implementation
29
Computer Organization
30
RISC
ARCHITECTURE DESIGN PRINCIPLES - IN 70s Large microprograms would add little or nothing
to the cost of the machine
Rapid growth of memory technology
Large General Purpose Instruction Set
Computer Organization
31
RISC
Data: 32-bit
Register-to-register
8
Load
Load
Add
Store
16
rB
rC
rA
rA
B
C
rC
A
rB
Memory-to-register
8
Load
Add
Store
16
B
C
A
Memory-to-memory
8
16
16
16
Add
32
RISC
IBM 370/168
DEC
VAX-11/780
Intel
Xerox
Dorado
iAPX-432
Year
1973
1978
1978
1982
# of instrs.
208
303
270
222
420 Kb
480 Kb
136 Kb
420 Kb
16-48
16-456
8-24
6-321
Technology
ECL MSI
TTL MSI
ECL MSI
NMOS VLSI
Execution model
reg-mem
mem-mem
reg-reg
reg-mem
mem-mem
reg-reg
stack
stack
mem-mem
Cache size
Computer Organization
64 Kb
64 Kb
64 Kb
64 Kb
33
Computer Organization
34
Computer Organization
35
36
Computer Organization
37
RISC
Computer Organization
38
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
Computer Organization
39
40
RISC
ARCHITECTURAL METRIC
AB+C
BA+C
DD -B
Load
Load
Add
Store
Add
Store
Load
Sub
Store
16
rB
B
C
rC
rA rB rC
rA
A
rB rA rC
rB
B
rD
D
rD rD rB
rD
D
I = 228b
D = 192b
M = 420b
Add
Add
Sub
rA
rB
rD
rB
rA
rD
rC
rC
rB
I = 60b
D = 0b
M = 60b
Memory-to-memory
8
16
16
16
Add
Add
Sub
B
A
B
C
C
D
A
B
D
Computer Organization
I = 168b
D = 288b
M = 456b
Computer Architectures Lab
41
RISC
Year
Number of
instructions
Control memory
size
Instruction
size (bits)
Technology
Execution model
Computer Organization
IBM 801
1980
RISC I
1982
MIPS
1983
120
39
55
32
ECL MSI
reg-reg
32
NMOS VLSI
reg-reg
32
NMOS VLSI
reg-reg
42
RISC
AB+C
AA+1
DD-B
OP
RISC 1
VAX
DEST
rA
rB
register
operand
rC
ADD
rA
rA
immediate
operand
SUB
rD
rD
register
operand
rB
ADD
(3 operands)
register
operand
INC
(1 operands)
register
operand
SUB
(2 operands)
register
operand
register
operand
C ...
... C
1 operand
in memory
2 operands
in memory
... D
Computer Organization
register
operand
3 operands
in memory
A
D
D
I
N
C
SOUR2
ADD
register
operand
432
SOUR1
A
D
D
I
N
C
D ...
SUB
43
REGISTERS
By simplifying the instructions and addressing modes, there is
space available on the chip or board of a RISC CPU for more
circuits than with a CISC processor
This extra capacity is used to
Pipeline instruction execution to speed up instruction execution
Add a large number of registers to the CPU
Computer Organization
44
PIPELINING
Computer Organization
45
PIPELINING
For instance, at one time, a pipelined processor may be
Executing instruction it
Decoding instruction it+1
Fetching instruction it+2 from memory
Computer Organization
46
REGISTERS
By having a large number of general purpose registers, a
processor can minimize the number of times it needs to access
memory to load or store a value
This results in a significant speed up, since memory accesses
are much slower than register accesses
Register accesses are fast, since they just use the bus on the
CPU itself, and any transfer can be done in one clock cycle
To go off-processor to memory requires using the much slower
memory (or system) bus
It may take many clock cycles to read or write to memory
across the memory bus
The memory bus hardware is usually slower than the processor
There may even be competition for access to the memory bus by other
devices in the computer (e.g. disk drives)
Computer Organization
47
RISC
Pascal
45
5
15
29
6
C
38
3
12
43
3
1
MachineInstruction
Weighted
Pascal
C
13
13
42
32
31
33
11
21
3
Memory
Reference
Weighted
Pascal
C
14
15
33
26
44
45
7
13
2
Computer Organization
48
RISC
CALL-RETURN BEHAVIOR
Call-return behavior as a function of nesting depth and time
Computer Organization
49
RISC
Solution
50
RISC
Computer Organization
51
RISC
R73
Local to D
R64
R63
R16
R15
R31
R58
R57
R10
R26
Proc D
R25
Common to C and D
Local to C
R48
R47
R16
R15
R31
R42
R41
R10
R26
Proc C
R25
Common to B and C
Local to B
R32
R16
R31
R15
R31
R26
R10
R26
R25
Proc B
R25
Common to A and B
Local to A
R16
R15
R10
R9
R16
R31
R15
Common
R26 to D and A
R10
R9
Common to A and D
Proc A
Common to all
procedures
R0
Computer Organization
R0
Global
registers
52
53
This saves
Accesses to memory to access the stack.
The cost of copying the register contents at all
Computer Organization
54
RISC
BERKELEY RISC I
- 32-bit integrated circuit CPU
- 32-bit address, 8-, 16-, 32-bit data
- 32-bit instruction format
- total 31 instructions
- three addressing modes:
register; immediate; PC relative addressing
- 138 registers
10 global registers
8 windows of 32 registers each
Opcode
Rd
Rs
5 4
Not used
8
Rd
PC relative mode
31
24 23
Opcode
COND
Computer Organization
Rs
S2
13
19 18
5
S2
5
Opcode
Y
19
55
BERKELEY RISC I
Register 0 was hard-wired to a value of 0.
There are eight memory access instructions
Five load-from-memory instructions
Three store-to-memory instructions.
Computer Organization
store long
store short
store byte
56
Berkeley RISC I
LDL
LDSU
LDSS
LDBU
LDBS
STL
STS
STB
Computer Organization
57
RISC
Operands
Register Transfer
Description
Integer add
Add with carry
Integer subtract
Subtract with carry
Subtract reverse
Subtract with carry
AND
OR
Exclusive-OR
Shift-left
Shift-right logical
Shift-right arithmetic
Load long
Load short unsigned
Load short signed
Load byte unsigned
Load byte signed
Load immediate high
Store long
Store short
Store byte
Load status word
Set status word
Computer Organization
Rd M[Rs + S2]
Rd M[Rs + S2]
Rd M[Rs + S2]
Rd M[Rs + S2]
Rd M[Rs + S2]
Rd Y
M[Rs + S2] Rd
M[Rs + S2] Rd
M[Rs + S2] Rd
Rd PSW
PSW Rd
58
Operands
Register Transfer
Description
Computer Organization
59
RISC
CHARACTERISTICS OF RISC
RISC Characteristics
- Relatively few instructions
- Relatively few addressing modes
- Memory access limited to load and store instructions
- All operations done within the registers of the CPU
- Fixed-length, easily decoded instruction format
- Single-cycle instruction format
- Hardwired rather than microprogrammed control
Advantages of RISC
- VLSI Realization
- Computing Speed
- Design Costs and Reliability
- High Level Language Support
Computer Organization
60
RISC
ADVANTAGES OF RISC
VLSI Realization
Control area is considerably reduced
Example:
RISC I: 6%
RISC II: 10%
MC68020: 68%
general CISCs: ~50%
Computing Speed
- Simpler, smaller control unit faster
- Simpler instruction set; addressing modes; instruction format
faster decoding
- Register operation faster than memory operation
- Register window enhances the overall speed of execution
- Identical instruction length, One cycle instruction execution
suitable for pipelining faster
Computer Organization
61
RISC
ADVANTAGES OF RISC
Design Costs and Reliability
- Shorter time to design
reduction in the overall design cost and
reduces the problem that the end product will
be obsolete by the time the design is completed