G22.2233 - Prof. Grishman

Assignment 4 - MIPS Data Path

As the next step in building our simulated MIPS CPU, you are to use the Java simulator to construct the MIPS data path as shown in Figure 5.11.  You are to define a class DataPath with constructor
DataPath (Bus regNo1, Bus regNo2, Bus writeRegNo, Bus immconst,
     Wire RegWrite, Wire MemWrite, Wire ALUSrc, Bus ALUOp, Wire MemtoReg, Wire clock)
The 'instruction' input in Figure 5.11 has been broken down into its constituent fields.  The busses regNo1, regNo2, and writeRegNo are each 5 bits and specify the register numbers to read/write;  immconst is an 18-bit bus which provides the input to the signextend unit in the data path.  The remaining inputs correspond directly to those shown in the figure (bus ALUOp is 3 bits wide).  There is no MemRead signal;  our simple simulated memory is constantly performing a read.  The clock input is not shown in the figure, but implicitly controls the flip-flops in the register file and memory.

You should use the ALU you built for assignment 2, and the register, memory, and sign-extension primitives provided in the latest version of the simulator.  You need to define a Module for an n-bit, 2-way multiplexer (you'll need two of these for the data path), and then define a DataPath Module.  The data memory component of the DataPath module should be given the component name "dmemory".

Testing this class is more complicated than the earlier classes you constructed.  The circuit does not have any outputs;  however, the simulator provides methods (Sim.get and Sim.getBus) for testing the value of any wire or bus inside the module, and new methods (Sim.setMemory and Sim.getMemory) for setting and testing the memory.  This is a sequential circuit, so testing will have to be performed over a series of clock cycles.  For each cycle, you

A suggestion:  you may find it convenient to have a method like the following, which toggles the clock and then prints out various busses in the data path;  of course, your choice of what busses to print may be different. You are required to code and submit at least one (4 cycle) test, which corresponds to the sequence of instructions
lw    16,1
lw    17,2
add   18,16,17
sw    18,3
This test adds the contents of locations 1 and 2 of main memory and stores the result in location 3.  Please code this test as (static) method test (with no arguments) of class Asgn4Test.

You should send email to grishman@cs.nyu.edu which contains a single attachment containing the definitions of the DataPath class, the Asgn4Test class, and any other classes you needed to define DataPath.  The subject line of the message should be "Assignment 4".  It will be easier for me if the attachment file name is yourname.java.

We will test your submission in two ways:  by running our own tests on DataPath, and by initializing memory locations 1 and 2, running your test method, and examining memory location 3.

This assignment is due April 1st, and is worth 9 points towards your final grade.  There is a penalty of 1/2 point for each school day the assignment is late.

Simulator for Assignment 3:  This is an upgrade of the simulator, which includes additional primitives for registers, memory, and sign extension. Upgrade documentationJava code (release 3.0).

An ALU Primitive is now also available.