300 likes | 402 Views
Let’s make a Computer. Let’s make a CPU. Pentium. Input A. Input B. 3. 3. 2. 2. add. sub. 5. 1. Output. Arithmetic Logic Unit. ALU. Integer Execution Unit. Input A. Input B. ALU. Output. Multimedia MMX. ALU. 0. 1. 2. 3. 3. 2. 3. 2. 4. add. 5. 5.
E N D
Let’s make a Computer Comp 1017 Digital Technologies
Let’s make a CPU Comp 1017 Digital Technologies
Pentium Comp 1017 Digital Technologies
Input A Input B 3 3 2 2 add sub 5 1 Output Arithmetic Logic Unit ALU Integer Execution Unit Comp 1017 Digital Technologies
Input A Input B ALU Output Multimedia MMX ALU Comp 1017 Digital Technologies
0 1 2 3 3 2 3 2 4 add 5 5 Processing Idea Nr. 1 Move data in and out of data memory 1. Move data from memory Data Memory 2. 3. Move data into memory Comp 1017 Digital Technologies
IP 0 1 2 3 3 2 3 2 4 add 5 5 Processing Idea Nr.2 Move instructions into CPU from code memory Instruction Memory (Code Memory) Program Comp 1017 Digital Technologies
Registers-1 AX BX 0 6 6 8 1 8 4 Comp 1017 Digital Technologies
0 6 6 8 1 8 4 4 Registers-2 AX BX MAR Comp 1017 Digital Technologies
0 1 Instruction Memory Data Memory mar 4 Our CPU so far … ip Comp 1017 Digital Technologies
SAM-2 Comp 1017 Digital Technologies
Hierarchy of Programming 1. Application mov ax,[x] mov bx,[y] add ax, bx mov [w],ax 2. Written in HLL (C) w = x + y ; 3. CPU executes machine code Comp 1017 Digital Technologies
0 1 2 mar 3 Instruction Memory 4 Moving data into Registers For example … mov ax , [1] AX BX mov bx , [2] mov ax , [1] 5 mov bx , [2] 7 8 8 7 6 1 Comp 1017 Digital Technologies
0 1 2 mar 3 Instruction Memory 4 Moving data into Memory For example … mov [3] , ax mov [0], bx AX BX mov [3] , ax 5 7 mov [0] , bx 7 8 8 7 6 8 1 Comp 1017 Digital Technologies
0 1 2 mar 3 Instruction Memory 4 Adding Numbers For example … add ax , bx AX BX Add ax,bx 5 7 8 8 7 8 7 15 6 1 Comp 1017 Digital Technologies
I’ve never wrestled with such a complex problem before It must take a lot of organization and control ! Comp 1017 Digital Technologies
Pentium Organization and control Comp 1017 Digital Technologies
Fetch-Execute Cycle 1. Fetch instruction from memory 5. Write back results to registers ax <- ALU add ax , bx 4. Do any Memory Access 2. Decode the instruction and read any registers (Data cache) None needed ALU <- ax ALU <- bx 3. Do any ALU operations (execute units) ax + bx Comp 1017 Digital Technologies
0 1 2 3 4 Fetch-Exec : State 1 Instruction Fetch add ax , bx ax bx add AX BX 3 add ax,bx 3 1 8 7 1 9 Comp 1017 Digital Technologies
0 1 2 3 4 Fetch-Exec : State 2 Decode, Register Operations add ax , bx ax bx add AX BX 3 add ax,bx 3 1 8 7 1 3 1 9 Comp 1017 Digital Technologies
0 1 2 3 4 Fetch-Exec : State 3 ALU Operation add ax , bx ax bx add AX BX 3 add ax,bx 8 7 1 3 1 4 9 Comp 1017 Digital Technologies
0 1 2 3 4 Fetch-Exec : State 4 Memory Access add ax , bx ax bx add AX BX 3 add ax,bx 8 7 1 3 1 4 9 Comp 1017 Digital Technologies
0 1 2 3 4 Fetch-Exec : State 5 Register Write add ax , bx ax bx add BX 3 add ax,bx 4 8 7 1 3 1 4 9 Comp 1017 Digital Technologies
Fetch-Execute Cycle (Organization and Control) 1. Fetch instruction from memory 5. Write back results to registers Data into ax mov ax , [1] 4. Do any Memory Access 2. Decode the instruction and read any registers Read memory at addr ‘1’ Read the ‘1’ 3. Do any ALU operations (execute units) Put ‘1’ into MAR Comp 1017 Digital Technologies
0 1 2 3 4 Fetch-Exec : State 1 Instruction Fetch mov ax , [1] mov ax 1 mov ax , [1] 3 8 7 1 9 Comp 1017 Digital Technologies
0 1 2 3 4 Fetch-Exec : State 2 Decode, Register Operations mov ax , [1] mov ax 1 mov ax , [1] 3 8 7 1 9 Comp 1017 Digital Technologies
0 1 2 3 4 Fetch-Exec : State 3 ALU Operation mov ax , [1] mov ax 1 mov ax , [1] 3 8 7 1 1 9 Comp 1017 Digital Technologies
0 1 2 3 4 Fetch-Exec : State 4 Memory Access mov ax , [1] mov ax 1 mov ax , [1] 3 8 8 7 1 1 9 Comp 1017 Digital Technologies
0 1 2 3 4 Fetch-Exec : State 5 Register Write mov ax , [1] mov ax 1 mov ax , [1] 3 8 8 8 7 1 1 9 Comp 1017 Digital Technologies
1 Pentium 2 • Fetch • Decode • ALU • Mem Ops • Reg Write 3 4 5 Comp 1017 Digital Technologies