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
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” or PC contains the address of the next instruction.
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.
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
Decoding Instructions Recall instruction formats (chapter 2). We only looked at R-format (for register operations); 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).
First Approximation to Datapath Most of these lines actually represent 32 one-bit values
First Approximation to Datapath Here is where we “add 4” to the program counter, advancing to the next instruction.
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)
First Approximation to Datapath A “load” instruction requires several steps: first, calculate the memory address
First Approximation to Datapath Then transfer data from memory to a register
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.
First Approximation to Datapath A “store” instruction also requires several steps: first, calculate the memory address
First Approximation to Datapath Then transfer data from a register to memory
First Approximation to Datapath An “la” instruction (“load address”) first calculates the memory address
First Approximation to Datapath And then loads that address to a register. No memory access is needed.
A More Detailed Look ■ Can’t just join wires together ■ Use multiplexers
A More Detailed Look
Recommend
More recommend