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)
Why is this datapath unable to implement the lui
instruction?
Why is it unable to implement the ori
instruction?
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....).
Simulate the complete datapaths of the non-pipelined MIPS shown in Figure 5.11 of the text. This involves:
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.
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)
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).
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.