View
214
Download
0
Embed Size (px)
Citation preview
21
1-Bit Logic Circuit
b
c
NOT
b c NOT AND OR XOR0 0 1 0 0 00 1 1 0 1 11 0 0 0 1 11 1 0 1 1 0
AND
OR
XOR
22
1-Bit Logic Circuit
b
VNOT
AND
OR
XOR
c
b c NOT AND OR XOR0 0 1 0 0 00 1 1 0 1 11 0 0 0 1 11 1 0 1 1 0
23
1-Bit Logic Circuit
b
V
c
NOT
AND
OR
XOR
b c NOT AND OR XOR0 0 1 0 0 00 1 1 0 1 11 0 0 0 1 11 1 0 1 1 0
24
1-Bit Logic Circuit
b
V
c
NOT
AND
OR
XOR
b c NOT AND OR XOR0 0 1 0 0 00 1 1 0 1 11 0 0 0 1 11 1 0 1 1 0
25
1-Bit Logic Circuit
b
V
c
NOT
AND
OR
XOR
b c NOT AND OR XOR0 0 1 0 0 00 1 1 0 1 11 0 0 0 1 11 1 0 1 1 0
26
1-Bit Logic Circuit
b
V
c
NOT
AND
OR
XOR
b c NOT AND OR XOR0 0 1 0 0 00 1 1 0 1 11 0 0 0 1 11 1 0 1 1 0
27
1-Bit Logic Circuit
b
V
c
NOT
AND
OR
XOR
b c NOT AND OR XOR0 0 1 0 0 00 1 1 0 1 11 0 0 0 1 11 1 0 1 1 0
28
1-Bit Logic Circuit
b
V
c
NOT
AND
OR
XOR
b c NOT AND OR XOR0 0 1 0 0 00 1 1 0 1 11 0 0 0 1 11 1 0 1 1 0
29
AND7
OR7
Eight 1-bit circuits can be combinedto build an...
8-Bit Logic Circuit
LogicCircuit
NOT7
B7 C7
• • •
XOR7
AND1
OR1
LogicCircuit
NOT1
B1 C1
XOR1
AND0
OR0
LogicCircuit
NOT0
B0 C0
XOR0
30
The “Full Adder” Circuit
CarryinCarryout FullAdder
Sum
B CCyin B C Cyout Sum
0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1
32
8 full-adders can be combined to build an...
8-Bit Adder
CarryFull
AdderFull
Adder
B0 C0
Sum0Sum1
B1 C1
FullAdder
Sum7
B7 C7
• • • 0Carry Carry
33
8 full-adders can be combined to build an...
8-Bit Adder
CarryFull
AdderFull
Adder
B0 C0
Sum0Sum1
B1 C1
CarryFull
Adder
Sum7
B7 C7
• • •
+B
88
8C
SumCarry
Carry0
40
3-to-8 Decoder
f0 f1 f2 OUTPUT
0 0 0 1 0 0 0 0 0 0 00 0 1 0 1 0 0 0 0 0 00 1 0 0 0 1 0 0 0 0 00 1 1 0 0 0 1 0 0 0 01 0 0 0 0 0 0 1 0 0 01 0 1 0 0 0 0 0 1 0 01 1 0 0 0 0 0 0 0 1 01 1 1 0 0 0 0 0 0 0 1
41
3-to-8 Decoder
f1
Vf0
f2
f0 f1 f2 OUTPUT
0 0 0 1 0 0 0 0 0 0 00 0 1 0 1 0 0 0 0 0 00 1 0 0 0 1 0 0 0 0 00 1 1 0 0 0 1 0 0 0 01 0 0 0 0 0 0 1 0 0 01 0 1 0 0 0 0 0 1 0 01 1 0 0 0 0 0 0 0 1 01 1 1 0 0 0 0 0 0 0 1
42
3-to-8 Decoder
f1
Vf0
f2
INCANDORXORNOTSHL<unused>
ADD
f0 f1 f2 OUTPUT
0 0 0 1 0 0 0 0 0 0 00 0 1 0 1 0 0 0 0 0 00 1 0 0 0 1 0 0 0 0 00 1 1 0 0 0 1 0 0 0 01 0 0 0 0 0 0 1 0 0 01 0 1 0 0 0 0 0 1 0 01 1 0 0 0 0 0 0 0 1 01 1 1 0 0 0 0 0 0 0 1
01:07
43CarrySign
Arithmetic Logic Unit (ALU) B 8
8
8C
Data Bus
3
Zero
8-bitLogic
8-bitAdder
Enable En En En En EnEn
AN
D
OR
XO
R
NO
T
SH
L
INC
AD
D
Function
3-to-8Decoder
Zero-Detect
44
CarrySign
An 8-Bit ALU
ALUB
8
8
8C
Result
Function Code 000 add 001 inc 010 and 011 or 100 xor 101 not 110 shl 111 <nop>
3
Zero
55
SystemArchitecture
A B C D M1
M2 M
X
Y XY
8-bitALU
8-b
it D
ata
Bu
sZ Cy S
16-b
it A
dd
ress
Bu
s
56
SystemArchitecture
A B C D M1
M2 M
X
Y XY
8-bitALU
8-b
it D
ata
Bu
sZ Cy S
Inst
PC
16-b
it A
dd
ress
Bu
s
57
SystemArchitecture
M1
M2 M
X
Y XY
8-bitALU
8-b
it D
ata
Bu
sZ Cy S
Inst
PC
Memory
AddrData
A B C D
16-b
it A
dd
ress
Bu
s
58
SystemArchitecture
M1
M2 M
X
Y XY
8-bitALU
8-b
it D
ata
Bu
sZ Cy S
Inst
PC
Memory
AddrData
16-bitIncrement
Inc
A B C D
16-b
it A
dd
ress
Bu
s
59
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
SystemArchitecture
8-b
it D
ata
Bu
s
A B C D
16-b
it A
dd
ress
Bu
s
60
QuickTime™ and aTIFF (LZW) decompressor
are needed to see this picture.
32K Byte Static RAM Chip
LEDs
8 FET Power Transistors(to drive relays during
a memory-read operation)
61
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
16-b
it A
dd
ress
Bu
s
Example:The ALU
Instruction
62
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
Step 1:Fetch Instruction
16-b
it A
dd
ress
Bu
s
63
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
Step 1:Fetch Instruction
SELECT 16-b
it A
dd
ress
Bu
s
64
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
Step 1:Fetch Instruction
SELECT 16-b
it A
dd
ress
Bu
s
65
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
Step 1:Fetch Instruction
MEM-READ
PC
SELECT 16-b
it A
dd
ress
Bu
s
66
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
Step 1:Fetch Instruction
MEM-READ
PC
SELECT 16-b
it A
dd
ress
Bu
s
67
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
Step 1:Fetch Instruction
MEM-READ
PC
SELECT
LOAD
16-b
it A
dd
ress
Bu
s
68
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
Step 1:Fetch Instruction
8-b
it D
ata
Bu
s
A B C D
MEM-READSELECT
LOAD
16-b
it A
dd
ress
Bu
s
69
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
Step 2:Increment PC
16-b
it A
dd
ress
Bu
s
70
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
Step 2:Increment PC
SELECT 16-b
it A
dd
ress
Bu
s
71
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
Step 2:Increment PC
SELECT 16-b
it A
dd
ress
Bu
s
72
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
Step 2:Increment PC
SELECT
LOAD
16-b
it A
dd
ress
Bu
s
73
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
Step 2:Increment PC
SELECT
LOAD 16-bitIncrement
16-b
it A
dd
ress
Bu
s
74
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
Step 3:Update PC
16-b
it A
dd
ress
Bu
s
75
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
SELECT
Step 3:Update PC
16-b
it A
dd
ress
Bu
s
76
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
SELECT
Step 3:Update PC
16-b
it A
dd
ress
Bu
s
77
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
LOAD
SELECT
Step 3:Update PC
16-b
it A
dd
ress
Bu
s
78
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
8-bitALU
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A B C D
LOAD
SELECT
Step 3:Update PC
16-b
it A
dd
ress
Bu
s
79
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A
D
Step 4:Execute Instruction
B C
8-bitALU
16-b
it A
dd
ress
Bu
s
80
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A
D
Step 4:Execute Instruction
FUNCTION
B C
8-bitALU
16-b
it A
dd
ress
Bu
s
81
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A
D
Step 4:Execute Instruction
FUNCTION
B C
8-bitALU
16-b
it A
dd
ress
Bu
s
82
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A
D
Step 4:Execute Instruction
FUNCTION
B C
8-bitALU
16-b
it A
dd
ress
Bu
s
83
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A
D
Step 4:Execute Instruction
FUNCTION
LOAD
LOAD
B C
8-bitALU
16-b
it A
dd
ress
Bu
s
84
16-bitIncrement
Inst
M1
M2 M
X
Y XY
J1
J2 J
PC
Inc
Memory
AddrData
Z Cy S
8-b
it D
ata
Bu
s
A
D
Step 4:Execute Instruction
FUNCTION
LOAD
LOAD
B C
8-bitALU
16-b
it A
dd
ress
Bu
s
01:07
110
Instruction Timing - ALU Instruction
Select PC
Memory Read
Load Instr
Load Inc
Select Inc
Load PC
ALU Function
Load A
Load Cond.Code Reg.
2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 31
111
Instruction Timing - ALU Instruction
Select PC
Memory Read
Load Instr
Load Inc
Select Inc
Load PC
ALU Function
Load Cond.Code Reg.
2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 31
Fetch
Load A
112
Instruction Timing - ALU Instruction
Select PC
Memory Read
Load Instr
Load Inc
Select Inc
Load PC
ALU Function
Load Cond.Code Reg.
2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 31
Increment
Load A
113
Instruction Timing - ALU Instruction
Select PC
Memory Read
Load Instr
Load Inc
Select Inc
Load PC
ALU Function
Load Cond.Code Reg.
2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 31
Load A
Execute
114
Instruction Decoding
Instruction RegisterFinite State Machine
Control Signals(Load, Select, Mem-Read, etc.)
1 2 3 4 5 6 • • • 7 6 5 4 3 2 1 0
115
Instruction Decoding
Instruction RegisterFinite State Machine
Control Signals(Load, Select, Mem-Read, etc.)
CombinationalLogic
1 2 3 4 5 6 • • • 7 6 5 4 3 2 1 0
116
1 2 3 4 5 6 7 8 9 10
Instruction Timing - 16-bit Move
Select PC
Memory Read
Load Instr
Load Inc
Select Inc
Load PC
Select Source-Register
2 3 4 5 6 7 8 11
Load Dest-Register
(Same asbefore)
119
Instruction Decoding and Control
Clock
InstructionRegister
Finite StateMachine
Control Lines
Instruction Decoding
Dat
a B
us
120
The Instruction Set (1)
0 0 d d d s s s
1 0 0 0 r f f f
0 1 r d d d d d
1 0 1 1 0 0 0 0
Move
ALU
Load Immediate
16-bit Increment
ddd = destination registersss = source register (A, B, C, D, M1 ,M2 ,X or Y)
r = destination register (A or D)fff = function code (add, inc, and, or, xor, not, shl)
r = destination register (A or B)ddddd = value (-16..15)
XY XY + 1
121
The Instruction Set (2)
1 0 0 1 0 0 r r
1 0 0 1 1 0 r r
1 1 0 0 0 0 0 0
1 0 1 0 1 1 1 0
Load
Store
Load 16-bit Immediate
Halt
rr = destination register (A, B, C, D)reg [M]
rr = source register (A, B, C, D)[M] reg
Load the immediate value into M (i.e., M1 and M2)
v v v v v v v v v v v v v v v v
122
The Instruction Set (3)
1 1 1 0 0 1 1 0
1 0 1 0 d s s 0
1 0 1 0 1 0 1 0
Goto
Call
16-Bit Move
Return / Branch Indirect
a a a a a a a a a a a a a a a a
Branch to the given address
1 1 1 0 0 1 1 1 a a a a a a a a a a a a a a a a
Branch to the given addressSave return location in XY register
PC XY
d = destination register (PC or XY)ss = source register (M, XY or J)
123
The Instruction Set (4)
1 1 1 1 0 0 0 0
Branch If Negative
Branch If Carry
Branch If Zero
Branch If Not Zero
a a a a a a a a a a a a a a a a
Branch to the given address if S = 1
1 1 1 0 1 0 0 0 a a a a a a a a a a a a a a a a
Branch to the given address if Cy = 1
Branch to the given address if Z = 1
Branch to the given address if Z = 0
1 1 1 0 0 1 0 0 a a a a a a a a a a a a a a a a
1 1 1 0 0 0 1 0 a a a a a a a a a a a a a a a a
124
An Example Program
address instr assembly comment 0000 0000 0011 1001 Y=B Y B 0000 0001 0011 0110 X=0 X 0 0000 0010 1000 0101 A=¬B If sign(Y)==1 0000 0011 1111 0000 BNEG Else . 0000 0100 0000 0000 . . 0000 0101 0000 0111 . . 0000 0110 0011 0010 X=C X C Else: . 0000 0111 0101 1001 A=-7 D -7 0000 1000 0001 1000 D=A . Loop: Loop: 0000 1001 0000 1110 B=X Shift X left (circular) 0000 1010 1000 0110 A=B<<1 . 0000 1011 0011 0000 X=A . 0000 1100 0000 1111 B=Y Shift Y left (circular) 0000 1101 1000 0110 A=B<<1 . 0000 1110 0011 1000 Y=A . 0000 1111 0000 1111 B=Y If sign(Y)==1 0001 0000 1000 0101 A=¬B . 0001 0001 1111 0000 BNEG Else2 . 0001 0010 0000 0000 . . 0001 0011 0001 0111 . . 0001 0100 0000 1110 B=X X X + C 0001 0101 1000 0000 A=B+C . 0001 0110 0011 0000 X=A . Else2: . 0001 0111 0000 1011 B=D D D + 1 0001 1000 1000 1001 D=B+1 . 0001 1001 1110 0010 BNZ Loop If D != 0 goto Loop 0001 1010 0000 0000 . . 0001 1011 0000 1001 . . 0001 1100 1010 1110 HALT HALT