cbp 2013-14comp 1017 digital technologies1 let’s make a computer
TRANSCRIPT
Comp 1017 Digital Technologies 1CBP 2013-14
Let’s make a Computer
Comp 1017 Digital Technologies 2CBP 2013-14
Let’s make a CPU
CBP 2004-5 Comp 1017 Digital Technologies 3
Pentium
CBP 2004-5 Comp 1017 Digital Technologies 4
Arithmetic Logic Unit
Input A Input B
Output
ALU Integer Execution Unit
5
3 2
add 1
3 2
sub
CBP 2004-5 Comp 1017 Digital Technologies 5
Input A Input B
Output
ALU
ALU
Multimedia MMX
CBP 2004-5 Comp 1017 Digital Technologies 6
5
3 2
add
0
1
2
3
4
3
2
5
Processing Idea Nr. 1
Move data from memory
Move data into memory3.
2.
1.
Data Memory
Move data in and out of data memory
CBP 2004-5 Comp 1017 Digital Technologies 7
5
3 2
add
0
1
2
3
4
3
2
5
Processing Idea Nr.2
IP
(Code Memory)
mov 3 in from memory
mov 2 in from memory
add the two numbers
mov the result to memory
Instruction Memory
Program
Move instructions into CPU from code memory
CBP 2004-5 Comp 1017 Digital Technologies 8
Registers-1
0
1
4
6 8
6
8
AX BX
CBP 2004-5 Comp 1017 Digital Technologies 9
Registers-2
0
1
4
6 8
6
8
4
AX BX
MAR
CBP 2004-5 Comp 1017 Digital Technologies 10
ip
Data Memory
Instruction
Memory
0
1
4
mar
Our CPU so far …
CBP 2004-5 Comp 1017 Digital Technologies 11
SAM-2
CBP 2004-5 Comp 1017 Digital Technologies 12
Hierarchy of Programming
2. Written in HLL (C)
3. CPU executes machine code
mov ax,[x]
mov bx,[y]
add ax, bx
mov [w],axw = x + y ;
1. Application
CBP 2004-5 Comp 1017 Digital Technologies 13
Moving data into Registers
Instruction
Memory
0
1
2
mar 3
4
mov ax , [1]
85
8
7
6
1
BXAXmov ax , [1] mov bx , [2]mov bx , [2] 7
For example …
Comp 1017 Digital Technologies 14CBP 2004-5
Moving data into Memory
Instruction
Memory
0
1
2
mar 3
4
mov [3] , ax
85
8
7
6
1
BXAXmov [3] , axmov [0], bx
mov [0] , bx 7
For example …
8
7
Comp 1017 Digital Technologies 15CBP 2004-5
Adding Numbers
Instruction
Memory
0
1
2
mar 3
4
add ax , bx
85
7
6
1
BXAXAdd ax,bx
7
For example …
8
8 7
15
Comp 1017 Digital Technologies 16CBP 2004-5
I’ve never wrestled with
such a complex
problem before
It must take a lot of organization and control !
CBP 2004-5 Comp 1017 Digital Technologies 17
Pentium
Organization and control
CBP 2004-5 Comp 1017 Digital Technologies 18
Fetch-Execute Cycle
1. Fetch instruction from memory
2. Decode the instruction and read any registers
3. Do any ALU operations (execute units)
5. Write back results to registers
add ax , bx
4. Do any Memory Access
ALU <- ax ALU <- bx
ax + bx
(Data cache)
ax <- ALU
None needed
CBP 2004-5 Comp 1017 Digital Technologies 19
add ax , bx
add ax,bx
add ax
0
1
4
3
2
bx
Fetch-Exec : State 1
Instruction Fetch
8
3
7
1
9
3 1
AX BX
CBP 2004-5 Comp 1017 Digital Technologies 20
0
1
4
3
2
Fetch-Exec : State 2
Decode, Register Operations
8
3
7
1
9
add ax , bx
add ax,bx
add ax bx
3 1
3 1
AX BX
CBP 2004-5 Comp 1017 Digital Technologies 21
0
1
4
3
2
Fetch-Exec : State 3
ALU Operation
8
3
7
1
9
add ax , bx
add ax,bx
add ax bx
AX BX
3 1
4
CBP 2004-5 Comp 1017 Digital Technologies 22
0
1
4
3
2
Fetch-Exec : State 4
Memory Access
8
3
7
1
9
add ax , bx
add ax,bx
add ax bx
AX BX
3 1
4
CBP 2004-5 Comp 1017 Digital Technologies 23
0
1
4
3
2
Fetch-Exec : State 5
Register Write
8
3
7
1
9
add ax , bx
add ax,bx
add ax bx
BX
3 1
4
4
CBP 2004-5 Comp 1017 Digital Technologies 24
Fetch-Execute Cycle
1. Fetch instruction from memory
2. Decode the instruction and read any registers
3. Do any ALU operations (execute units)
5. Write back results to registers
(Organization and Control)
mov ax , [1]
4. Do any Memory Access
Read the ‘1’
Put ‘1’ into MAR
Data into ax
Read memory at addr ‘1’
CBP 2004-5 Comp 1017 Digital Technologies 25
mov ax , [1]
mov ax , [1]mov ax
0
1
4
3
2
1
Fetch-Exec : State 1
Instruction Fetch
8
3
7
1
9
CBP 2004-5 Comp 1017 Digital Technologies 26
mov ax , [1]
mov ax , [1]mov ax
0
1
4
3
2
1
Fetch-Exec : State 2
Decode, Register Operations
8
3
7
1
9
CBP 2004-5 Comp 1017 Digital Technologies 27
mov ax , [1]
mov ax , [1]mov ax
0
1
4
3
2
1
Fetch-Exec : State 3
ALU Operation
1
8
3
7
1
9
CBP 2004-5 Comp 1017 Digital Technologies 28
mov ax , [1]
mov ax , [1]mov ax
0
1
4
3
2
1
Fetch-Exec : State 4
Memory Access
1
8
3
7
1
9
8
Comp 1017 Digital Technologies 29CBP 2004-5
mov ax , [1]
mov ax , [1]mov ax
0
1
4
3
2
1
Fetch-Exec : State 5
Register Write
1
8
3
7
1
9
88
CBP 2004-5 Comp 1017 Digital Technologies 30
Pentium
5
1
2
3
4
1. Fetch
2. Decode
3. ALU
4. Mem Ops
5. Reg Write