10/18/2005comp 120 fall 20051 26 october questions? instruction execution
Post on 21-Dec-2015
221 views
TRANSCRIPT
![Page 1: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/1.jpg)
10/18/2005 Comp 120 Fall 2005 1
26 October
• Questions?• Instruction Execution
![Page 2: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/2.jpg)
10/18/2005 Comp 120 Fall 2005 2
Five Execution Steps
• Instruction Fetch
• Instruction Decode and Register Fetch
• Execution, Memory Address Computation, or Branch Completion
• Memory Access or R-type instruction completion
• Memory Read Completion
INSTRUCTIONS TAKE FROM 3 - 5 CYCLES!• A FSM looks at the op-code to determine how many...
![Page 3: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/3.jpg)
10/18/2005 Comp 120 Fall 2005 3
• Use PC to get instruction and put it in the Instruction Register.• Increment the PC by 4 and put the result back in the PC.• Can be described succinctly using RTL "Register-Transfer Language"
IR = Memory[PC]; IR is “Instruction Register”PC = PC + 4;
What is the advantage of updating the PC now?
Step 1: Instruction Fetch
![Page 4: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/4.jpg)
10/18/2005 Comp 120 Fall 2005 4
• Read registers rs and rt in case we need them
• Compute the branch address in case the instruction is a branch
• RTL:
A = Reg[IR[25-21]];B = Reg[IR[20-16]];ALUOut = PC + (sign-extend(IR[15-0]) << 2);
• We aren't setting any control lines based on the instruction type (we are busy "decoding" it in our control logic)
Step 2: Instruction Decode and Register Fetch
![Page 5: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/5.jpg)
10/18/2005 Comp 120 Fall 2005 5
• ALU is performing one of three functions, based on instruction type
• Memory Reference:
ALUOut = A + sign-extend(IR[15-0]);
• R-type:
ALUOut = A op B;
• Branch:
if (A==B) PC = ALUOut;
Step 3 (instruction dependent)
![Page 6: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/6.jpg)
10/18/2005 Comp 120 Fall 2005 6
• Loads and stores access memory
MDR = Memory[ALUOut]; MDR is Memory Data Register
orMemory[ALUOut] = B;
• R-type instructions finish
Reg[IR[15-11]] = ALUOut;
Step 4 (R-type or memory-access)
![Page 7: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/7.jpg)
10/18/2005 Comp 120 Fall 2005 7
• Reg[IR[20-16]]= MDR;
Step 5 Memory Read Completion
![Page 8: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/8.jpg)
10/18/2005 Comp 120 Fall 2005 8
Summary:
Step nameAction for R-type
instructionsAction for memory-reference
instructionsAction for branches
Action for jumps
Instruction fetch IR = Memory[PC]PC = PC + 4
Instruction A = Reg [IR[25-21]]decode/register fetch B = Reg [IR[20-16]]
ALUOut = PC + (sign-extend (IR[15-0]) << 2)
Execution, address ALUOut = A op B ALUOut = A + sign-extend if (A ==B) then PC = PC [31-28] IIcomputation, branch/ (IR[15-0]) PC = ALUOut (IR[25-0]<<2)jump completion
Memory access or R-type Reg [IR[15-11]] = Load: MDR = Memory[ALUOut]completion ALUOut or
Store: Memory [ALUOut] = B
Memory read completion Load: Reg[IR[20-16]] = MDR
![Page 9: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/9.jpg)
10/18/2005 Comp 120 Fall 2005 9
Data Path with Control (5.28)
![Page 10: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/10.jpg)
10/18/2005 Comp 120 Fall 2005 10
FSM Control (5.31)
![Page 11: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/11.jpg)
10/18/2005 Comp 120 Fall 2005 11
IFetch and Decode (5.32)
![Page 12: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/12.jpg)
10/18/2005 Comp 120 Fall 2005 12
Memory Ref (5.33)
![Page 13: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/13.jpg)
10/18/2005 Comp 120 Fall 2005 13
R-type (5.34)
![Page 14: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/14.jpg)
10/18/2005 Comp 120 Fall 2005 14
Branch (5.35)
![Page 15: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/15.jpg)
10/18/2005 Comp 120 Fall 2005 15
Jump (5.36)
![Page 16: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/16.jpg)
10/18/2005 Comp 120 Fall 2005 16
Full State Diagram
![Page 17: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/17.jpg)
10/18/2005 Comp 120 Fall 2005 17
FSM
![Page 18: 10/18/2005Comp 120 Fall 20051 26 October Questions? Instruction Execution](https://reader036.vdocuments.mx/reader036/viewer/2022062421/56649d5a5503460f94a3a37b/html5/thumbnails/18.jpg)
10/18/2005 Comp 120 Fall 2005 18
Highlight
• Who’s been to the fair?• Go!• You can have your picture taken with W!