SLIDE 1
Tuesday, 24 November 2015
Schedule for rest of semester: ■ Today: quick look at Chapter 4--the datapath ■ Monday, Nov 30: lab time for project work ■ Tuesday, Dec 1: review sheets for exam ■ Thursday, Dec 3: review; project reports ■ Monday, Dec 7: COOKIES!, project reports
SLIDE 2 Executing a MIPS Program
Recall: programs consist of a set of
- instructions. In MIPS, each instruction is a 32-
bit word. Instructions are stored in an area of memory separate from the data area. A special register called the “program counter”
- r PC contains the address of the next
instruction.
SLIDE 3 Executing a MIPS Program
All calculations take place in the ALU, or Arithmetic Logic Unit. These calculations use the registers. All of the logic needed to perform addition, subtraction, “or”, “and”, comparisons,
- etc. is contained in the ALU.
Data stored in memory must be transferred back and forth between the registers and memory in order to perform calculations with it.
SLIDE 4
Steps to Execute a MIPS Instruction
■ Fetch an instruction from memory address stored in the PC and add 4 to the PC (advance to next instruction) ■ Decode the instruction ■ Execute the instruction:
■ If it’s a load, fetch operand from memory to register ■ If it’s a store, store result from register to memory ■ Everything else: carry out the instruction in registers
SLIDE 5 Decoding Instructions
Recall instruction formats (chapter 2). We
- nly looked at R-format (for register
- perations); there are two others (I-format for
immediate instructions; J-format for jump instructions). To decode an instruction we look at the leftmost 6 bits (the op code). E.g., “000000” indicates an R-format instruction (to determine which one, we look at the rightmost 6 bits).
SLIDE 6 First Approximation to Datapath
Most of these lines actually represent 32
SLIDE 7
First Approximation to Datapath
Here is where we “add 4” to the program counter, advancing to the next instruction.
SLIDE 8
First Approximation to Datapath
In the case of a jump instruction, we must alter the PC by adding an “offset” (which is contained in the jump instruction)
SLIDE 9
First Approximation to Datapath
A “load” instruction requires several steps: first, calculate the memory address
SLIDE 10
First Approximation to Datapath
Then transfer data from memory to a register
SLIDE 11
What Is “Calculate an Address”?
In a MIPS instruction there is not enough room to hold an entire address; instead, the instruction contains an OFFSET that must be added to the base address of the data memory in order to compute the actual address.
SLIDE 12
First Approximation to Datapath
A “store” instruction also requires several steps: first, calculate the memory address
SLIDE 13
First Approximation to Datapath
Then transfer data from a register to memory
SLIDE 14
First Approximation to Datapath
An “la” instruction (“load address”) first calculates the memory address
SLIDE 15
First Approximation to Datapath
And then loads that address to a register. No memory access is needed.
SLIDE 16 A More Detailed Look
■ Can’t just join
wires together
■ Use multiplexers
SLIDE 17
A More Detailed Look