Chapter 5( Comp.arch)
Chapter 5( Comp.arch)
Chapter 5( Comp.arch)
ELE5361
• Computer Registers
• Computer Instructions
• Instruction Cycle
CPU
0
RAM
15 0
4095
• Program
– A sequence of (machine) instructions
• (Machine) Instruction
– A group of bits that tell the computer to perform a specific operation
(a sequence of micro-operation)
• The instructions of a program, along with any needed
data are stored in memory
• The CPU reads the next instruction from memory
• It is placed in an Instruction Register (IR)
• Control circuitry in control unit then translates
the instruction into the sequence of
microoperations necessary to implement it
Instruction Format
15 14 12 11 0
I Opcode Address
Addressing
mode
300 1350
457 Operand
1350 Operand
+ +
AC AC
11 0
PC
Memory
11 0
AR
4096 x 16
15 0
IR
CPU
15 0
15
0
TR DR
7 0 7 0
15 0
OUTR INPR AC
List of BC Registers
COMMON
S2
BUS S1
S0
Bus
Memory unit 7
SYSTEM4096 x 16 Address
Write Read
AR 1
LD INR CLR
PC 2
LD INR CLR
DR 3
LD INR CLR
E
ALU AC 4
LD INR CLR
INPR
IR 5
LD
TR 6
LD INR CLR
OUTR
Clock
LD
16-bit common bus
Read INPR
Memory Write
4096 x 16
Address E
ALU
AC
L I C
L I C L
L I C DR IR L I C
PC TR
AR OUTR LD
L I C
7 1 2 3 5 6
4
16-bit Common Bus
S0 S1
S2
Computer Arch. & Org.
Basic Computer Organization & Design 13
COMMON BUS
SYSTEM
• Three control lines, S2, S1, and S0 control which register the
bus selects as its input
S2 S1 S0 Register
0 0 0 x
0 0 1 AR
0 1 0 PC
0 1 1 DR
1 0 0 AC
1 0 1 IR
1 1 0 TR
1 1 1 Memory
BSA
ISZ
CLA 7800 Clear AC
CLE 7400 Clear E
CMA 7200 Complement AC
CME 7100 Complement E
CIR 7080 Circulate right AC and E
CIL 7040 Circulate left AC and E
INC 7020 Increment AC
SPA 7010 Skip next instr. if AC is positive
SNA 7008 Skip next instr. if AC is negative
SZA 7004 Skip next instr. if AC is zero
SZE 7002 Skip next instr. if E is zero
HLT 7001 Halt computer
• Instruction Types
Functional Instructions
- Arithmetic, logic, and shift instructions
- ADD, CMA, INC, CIR, CIL, AND, CLA
Transfer Instructions
- Data transfers between the main
memory and the processor registers
- LDA, STA
Control Instructions
- Program sequencing and control
- BUN, BSA, ISZ
Input/Output Instructions
- Input and output
- INP, OUT
3x8
decoder
76543
210
D0
I Combinational
D7 Control
Control
logic signals
T15
T0
15 14 . . . . 2 1 0
4 x 16
decoder
T0
T1
T2
T3
T4
D3
CLR
SC
Computer Arch. & Org.
Basic Computer Organization & Design 20
INSTRUCTION CYCLE
T1 S2
T0
S1 Bus
S0
Memory
7
unit
Address
Read
AR 1
LD
PC 2
INR
IR 5
LD Clock
Common bus
T0
AR PC
T1
IR M[AR], PC PC + 1
T2
Decode Opcode in IR(12-14),
AR IR(0-11), I
IR(15)
(indirect) = 1 = 0 (direct)
(I/O) = 1 I = 0 (register) I
T3 T3 T3 T3
Execute Execute AR M[AR] Nothing
input-output register-reference
instruction instructi
SC 0 on Execute T4
SC 0 memory-reference
instructi
on
SC 0
BSA:
D5T4: M[AR] PC, AR
AR + 1 D5T5: PC AR, SC 0
D0 T4 D1 T4 D3 T4
DR M[AR] DR M[AR] DR M[AR] M[AR] AC
SC 0
D2T4
D0 T5 D1 T5 D2 T5
AC AC DR AC AC + DR AC DR
SC 0 E Cout SC 0
SC 0
D4 T4 D5 T4 D6 T4
PC AR M[AR] PC DR M[AR]
SC 0 AR AR + 1
D5 T5 D6 T5
PC AR DR DR + 1
SC 0
D6 T6
M[AR] DR
If (DR = 0)
then (PC
PC + 1)
SC 0
Computer Arch. & Org.
Basic Computer Organization & Design 28
AC
Transmitter
Keyboard interface INPR FGI
INPR Input register - 8 bits
OUTR Output register - 8 bits Serial Communications Path
FGI Input flag - 1 bit Parallel Communications Path
FGO Output flag - 1 bit
IEN Interrupt enable - 1
bit
- The terminal sends and receives serial information
- The serial info. from the keyboard is shifted into INPR
- The serial info. for the printer is stored in the OUTR
- INPR and OUTR communicate with the terminal
serially and with the AC in parallel.
- The flags are needed to synchronize the timing
difference between I/O device and the
computer
Computer Arch. & Org.
Basic Computer Organization & Design 29
FGO=1
Start Input
Start Output
FGI 0 OUTR AC
AC Data
FGO 0
yes yes
FGI=0 FGO=0
no
no
D7IT3 = p
IR(i) = Bi, i = 6, …, 11
p: SC 0 Clear SC
INP pB11: AC(0-7) INPR, FGI 0 Input char. to AC
OUT pB10: OUTR AC(0-7), FGO 0 Output char. from AC
SKI pB9: if(FGI = 1) then (PC PC + 1) Skip on input flag
SKO pB8: if(FGO = 1) then (PC PC + 1) Skip on output flag
ION pB7: IEN 1 Interrupt enable on
IOF pB6: IEN 0 Interrupt enable off
PROGRAM-CONTROLLED INPUT/OUTPUT
Input
LOOP, SKI
BUN LOOP
INP
Output
LOOP, LDA DATA
LOP, SKO
BUN LOP
OUT
• Program-controlled I/O
- Continuous CPU involvement
I/O takes valuable CPU time
- CPU slowed down to I/O speed
- Simple
- Least hardware
- The I/O interface, instead of the CPU, monitors the I/O device.
- When the interface founds that the I/O device is ready for data transfer,
it generates an interrupt request to the CPU
Execute =0
IEN
instructions
=1 Branch to location 1
PC 1
=1
FGI
=0
=1 IEN 0
FGO R0
=0
R
1
1 BUN 0 1 BUN 0
=0(Instruction =1(Interrupt
R
Cycle) Cycle)
R’T0 RT0
AR PC AR 0, TR PC
R’T1 RT1
IR M[AR], PC PC + 1 M[AR] TR, PC 0
R’T2 RT2
AR IR(0~11), I IR(15) PC PC + 1, IEN 0
D0...D7 Decode IR(12 ~ 14) R 0, SC 0
Fetch RT0: AR PC
IR M[AR], PC PC + 1
Decode RT1: D0, ..., D7 Decode IR(12 ~ 14),
AR IR(0 ~ 11), I IR(15)
Indirect RT2: AR M[AR]
Interrupt
T0 T1 T2 ( IEN
D7)IT
(F G I + R1
FGO): 3:
AR 0, TR PC
RT0: M[AR] TR, PC 0
RT2: PC PC + 1, IEN
Memory-ReferenceRT1: 0, R 0, SC 0
AND D0T4: DR M[AR]
D0T5: AC AC DR, SC 0
ADD DR M[AR]
D1T4: AC AC + DR, E Cout, SC 0
LDA DR M[AR]
D1T5: AC DR, SC 0
STA M[AR] AC, SC 0
BUN D2T4: PC AR, SC 0
M[AR] PC, AR AR + 1
BSA D2T5: PC AR, SC 0
ISZ DR M[AR]
D3T4: DR DR + 1
M[AR] DR, if(DR=0) then (PC PC + 1),
D4T4: SC 0
D5T4:
D5T5:
Computer Arch. & Org.
Basic Computer Organization & Design 38
COMPLETE COMPUTER DESCRIPTION
Microoperations
Register-Reference
D7 I T 3= (Common to all register-reference instr)
r IR(i) = (i = 0,1,2, ..., 11)
Bi SC 0
CLA rB
r: 11: AC 0
CLE E 0
CMA rB10: AC AC’
rB9: E E’
CME rB8: AC shr
CIR rB7: AC,
CIL rB6: AC(15)
INC rB5: E, E
SPA rB4: AC(0)
SNA rB3: AC shl AC, AC(0) E, E AC(15)
SZA rB2: AC AC + 1
SZE rB1: If(AC(15) =0) then (PC PC + 1)
HLT rB0: If(AC(15) =1) then (PC PC + 1)
Input-Output If(AC
(Common= 0) then
to all(PC PC + 1) instructions)
input-output
D7IT3 = p If(E=0) then (PC
(i = 6,7,8,9,10,11) PC + 1)
IR(i) = S
SC0 0
INP B i AC(0-7) INPR, FGI 0
OUT p: OUTR AC(0-7), FGO 0
SKI pB11: If(FGI=1) then (PC PC + 1)
SKO If(FGO=1) then (PC PC + 1)
ION pB10: IEN 1
IOF pB9: IEN 0
pB8:
pB7:
pB6:
Computer Arch. & Org.
Basic Computer Organization & Design 39
R
T0
D
5
Computer Arch. &TOrg.
Basic Computer Organization & Design 41
CONTROL OF FLAGS
IEN: Interrupt Enable Flag
pB7: IEN 1 (I/O Instruction)
pB6: IEN 0 (I/O Instruction)
RT2: IEN 0 (Interrupt)
p = D7IT3 (Input/Output
Instruction)
D7 p
J Q IEN
B7
I
T3 B6
K
R
T
2
x2 S2
x3 Encoder
Multiplexer S 1
x4
bus select
x5
inputs
selected
x6 x1 x2 x3 x4 x5 x6 x7 S2 S1 SS00 register
0 0 0 0 0 0 0 0 0 0 none
x7 1 0 0 0 0 0 0 0 0 1 AR
0 1 0 0 0 0 0 0 1 0 PC
0 0 1 0 0 0 0 0 1 1 DR
0 0 0 1 0 0 0 1 0 0 AC
0 0 0 0 1 0 0 1 0 1 IR
0 0 0 0 0 1 0 1 1 0 TR
0 0 0 0 0 0 1 1 1 1 Memory
For AR D4T4: PC AR
D5T5: PC AR
x1 = D4T4 + D5T5
Control
gates
CONTROL OF AC REGISTER
16 To bus
From Adder 16 AC
and Logic
D0 LD Clock
INR
AND CLR
T5
D1
ADD
D2
DR
T5
p
INPR
B11
r COM
B9
Computer Arch. & Org. SHR
Basic Computer Organization & Design 45
AND
Ci ADD LD
J Q
FA Ii AC(i)
C
DR
i+1
From
INPR INPR K
bit(i)
COM
SH
R
AC(i+1)
SH
L
AC(i-1)