Professional Documents
Culture Documents
03 Chapter 5
03 Chapter 5
4
Memory is typically determined using two parameter:
Number of memory locations >> 8
Size of each memory location >> 4
Address:
0000 0: 000B
1100 1: 001B
Example: 8x4 1111 2: 010B
Databus= 4 bits 3: 011B
Address bus = 3 bits 4 :100B
5: 101B
6:110B
7: 111B 5
Data Bus: 16
Address Bus: 12
MEMORY
4096 x 16
6
The processor memory stores _____________.
a) data
b) instructions
c) both
7
Reg.
Reg. Name Description #bits
Symbol
AC
DR
TR
IR
AR
PC
INPR
OUTR
8
9
10
5.2 INSTRUCTION FORMAT
11
PC: stores the address (12 bits) of the next
instruction
12
Instructions are – 16 bits.
13
IR
D7 D0…D6 : MEMORY
14
IR
D7 D0…D6 : MEMORY
15
Direct addressing: address in IR is the EA.
16
17
Given that the instructions below are stored in the
instruction register, indicated for each the effective address
and operand.
19
5.3 COMMON BUS SYSTEM
20
S2
S1 Bus
S0
Memory unit 7
4096 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
21
Complete the following table Considering the basic
computer shown in the previous figure.
Source Destination
Microinstruction
Name Read S2 S1 S0 Name Write LD INR CLR
DR TR
AR PC
IR M[AR]
AC AC+1
M[AR] DR
TR 0
22
Complete the following table Considering the basic
computer shown in the previous figure.
Source Destination
Microinstruction
Name Read S2 S1 S0 Name Write LD INR CLR
DR TR TR 0 1 1 0 DR 0 1 0 0
AR PC PC 0 0 1 0 AR 0 1 0 0
IR M[AR] M 1 1 1 1 IR 0 1 0 0
AC AC+1 AC 0 0 0 0 AC 0 0 1 0
M[AR] DR DR 0 0 1 1 M 1 0 0 0
TR 0 TR 0 0 0 0 TR 0 0 0 1
23
5.4 COMPUTER INSTRUCTIONS
A. Instruction Cycle
B. Register Instructions
C. Memory Instructions
D. I/O Instructions
24
BASIC COMPUTER INSTRUCTIONS
Hex Code
Symbol I = 0 I=1 Description
AND 0xxx 8xxx AND memory word to AC
ADD 1xxx 9xxx Add memory word to AC
LDA 2xxx Axxx Load AC from memory
MEMORY STA 3xxx Bxxx Store content of AC into memory
BUN 4xxx Cxxx Branch unconditionally
BSA 5xxx Dxxx Branch and save return address
ISZ 6xxx Exxx Increment and skip if zero
25
1. Programs run sequentially:
START: S1 //manually
END: S 0 //HALT
26
a)Fetch:
T0: AR PC
b) Decode:
T2: D7 D6 … D0 Decode(IR[12:14]), I
IR[15],
AR IR[0:11]
27
a)Memory:
I’D7’: Memory Direct
I D7’: Memory Indirect
b)Register
I’ D7
c) I/O:
I D7
28
We requires the fetch – decode – execute to be
performed in sequence.
29
INSTRUCTION
DECODING
TIMING
SEQUENCE
SC >> Decoder
0000
0001
0010
0011
..
1111 30
T0 T1 T2 T3 T4 T0
Clock
T0
T1
T2
T3
T4
D3
CLR
SC
31
32
r = I‘ D7T3 = (common to all register – reference instructions)
r: SC ← 0
CLA rB11: AC ← 0
CLE rB10: E←0
CMA rB9: AC ← AC’
CME rB8: E ← E’
CIR rB7: AC ← shr AC, AC(15) ← E, E ← AC(0)
CIL rB6: AC ← shl AC, AC(0) ← E, E ← AC(15)
INC rB5: AC ← AC + 1
SPA rB4: if (AC(15) = 0) then (PC ← PC+1)
SNA rB3: if (AC(15) = 1) then (PC ← PC+1)
SZA rB2: if (AC = 0) then (PC ← PC+1)
SZE rB1: if (E = 0) then (PC ← PC+1)
HLT rB0: S ← 0 (S is a start-stop flip-flop)
..
33
PC= 300h E=0 AC=A840h DR=4444h M[111]= 0005 h
M[A23]=7111h M[A88]= FFFFh, For the basic computer, complete
the table after the given independent instructions are executed.
Instruction Description PC AR AC DR
34
BASIC COMPUTER INSTRUCTIONS
Hex Code
Symbol I = 0 I=1 Description
AND 0xxx 8xxx AND memory word to AC
ADD 1xxx 9xxx Add memory word to AC
LDA 2xxx Axxx Load AC from memory
MEMORY STA 3xxx Bxxx Store content of AC into memory
BUN 4xxx Cxxx Branch unconditionally
BSA 5xxx Dxxx Branch and save return address
ISZ 6xxx Exxx Increment and skip if zero
35
MEMORY INSTRUCTIONS
D0. AND // AC AC ^ M[AR]
T0: AR PC
D0 T4: DR ← M[AR]
D0 T5: AC ← AC ˄ DR, SC ← 0
36
MEMORY INSTRUCTIONS
D1. ADD // AC AC + M[AR]
D1 T4: DR ← M[AR]
37
MEMORY INSTRUCTIONS
D2 T5: AC ← DR, SC ← 0
38
MEMORY INSTRUCTIONS
D6. ISZ //
D6 T4: DR ← M[AR]
D6 T5: DR ← DR + 1
D4. BUN // GO TO EA
D4 T4: PC ← AR, SC ← 0
40
MEMORY INSTRUCTIONS
44
BASIC COMPUTER INSTRUCTIONS
Hex Code
Symbol I = 0 I=1 Description
AND 0xxx 8xxx AND memory word to AC
ADD 1xxx 9xxx Add memory word to AC
LDA 2xxx Axxx Load AC from memory
MEMORY STA 3xxx Bxxx Store content of AC into memory
BUN 4xxx Cxxx Branch unconditionally
BSA 5xxx Dxxx Branch and save return address
ISZ 6xxx Exxx Increment and skip if zero
45
Considering only the indicated THREE instructions of the basic
computer, design the control circuits to generate the four control
signals: INR (PC) - LD (AC) - CLR (AC) - Read (Memory)
46
INC(PC) = R’ T1
LD(AC) = D0 T5 + D1 T5
CLR(AC) = D7 I’ T3 B11
READ(MEM)=R’ T1 + D0 T4 + D1 T4
47
Any interface between the PC and an I/O device must be
through the AC.
48
Polling: continuously asking the
students whether they have any
question.
wastes a lot of time
>>human: 10 char/sec
>>processor: fclk 5kHz == 5000inst./sec
OUTPUT :
FGO=1>> character ready in AC to be transferred to OUTR
FGO is cleared >> when OUTR AC(0-7)
51
Instruction cycle =0 Interrupt cycle
R =1
=0
Execute IEN
instructions Branch to location 1
=1
PC ← 1
=1
FGI
=0
=1 IEN ← 0
FGO R←0
=0
R←1
52
Interrupt Cycle:
53
Assume an interrupt occurs during the execution of the
instruction in address 0x255 (i.e. PC= ?? ).
1) A hardware BSA 0 operation is performed (PC = ?? )
2) Typically, address 0x001 has a BUN inst. to the I/O program.
3) Last line in I/O program is a indirect BUN to 0
1- M[0] PC
2- PC=1
3. IEN = 0, R=0
54
Interrupt Cycle:
RT0: AR ← 0, TR ← PC
RT1: M[AR] ← TR, PC ← 0
RT2: PC ← PC + 1, IEN ← 0, SC ← 0
1- M[0] PC
2- PC=1
3. IEN = 0, R=0
55
S2
S1 Bus
S0
Memory unit 7
4096 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
56
5.5 SUMMING UP
57
S2
S1 Bus
S0
Memory unit 7
4096 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
Cloc
LD k
16-bit common bus
58
start
SC ← 0, IEN ← 0, R ← 0
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
59
60