CS 473

Homework 3: MIPS II

Due Monday, October 11, 2004

On Paper

The datapath we used for R-format and I-format instructions is in the book as Figure 5.10 (that figure doesn't include the PC or instruction memory, but that isn't important to this question)

  1. Why is this datapath unable to implement the lui instruction?

  2. Why is it unable to implement the ori instruction?

  3. Modify it so it can implement both of those instructions. It's probably a good idea to xerox page 299 and modify it (I keep thinking it ought to be on the CD someplace so you could print it from there, but I haven't been able to find it so far....).

Programming

Simulate the complete datapaths of the non-pipelined MIPS shown in Figure 5.11 of the text. This involves:

  1. Write a function to simulate each of the hardware pieces needed, using the methodology we described in class (we used the register file as an example). Each unit will require data and control inputs corresponding to the inputs given in the text. Just to keep things concrete, use the same control field values in your simulation as the text uses (so, for instance, the ALU has a 4-bit input, but only input values of 0000, 0001, 0010, 0110, 0111, and 1100 are defined as shown on page 301).

    The units you will need to simulate are an ALU (you only need to write the ALU code once; you can call that code three times to get the effect of the ALU, the PC adder, and the branch adder), the register file, the sign extender, the left-shifter,the data memory, a mux (again, the actual code only has to be written once), a control unit, and an ALU control unit. You've already written the PC itself and the instruction memory.

  2. Your functional units should be called in the following order on each cycle of the simulation:

    Instruction Memory
    PC adder
    Control Unit
    Register File
    Sign Extender
    Left Shifter
    Branch Adder
    ALU Mux
    ALU Control
    ALU
    Branch Mux
    Data Memory
    Register Mux
    PC Update
    Register File (yes, this is calling it twice per instruction)
    

  3. When each unit is called, it should print its name and all of its inputs; just before it returns, it should print all of its outputs.

    All integers should be printed as an eight digit, 0-extended hexadecimal value (a format string of %08x will do this).

    Instructions

    You should be able to handle all the instructions that my solution to HW2 can handle: that is, add, sub, addiu, lw, beq, j, and addi, and sw.

    Note that handling j will require a slight enhancement to the data paths.


Last modified: Sat Oct 9 12:35:43 MDT 2004