CS3421, Spring 2004

Lab Assignment 4
Register File / ALU

Due Monday, March 15, 2004 at 10 PM

There is a new version of lsgui that you must use for this assignment. It has several bug fixes. To use it, type /classes/cs3421/bin/newlsgui. You must also use /classes/cs3421/bin/newlsim, not the old lsim.

DO NOT use the old lsgui or the old lsim.
DO NOT use logicsim directly.

The Problem

Implement, using newlsgui (or newlsim directly), a register file with four 32-bit registers, and an ALU that has eight different functions. To control the register file and ALU, implement a 16-bit register into which you can put an operation to perform, two register numbers to pick the sources of the data for the operation, and a single register number to pick the register in which to put the result of the operation.

Name the 16-bit operation register INST and the four 32-bit registers REG0, REG1, REG2 and REG3.

The bits INST are assigned as follows:

where iii is a three bit code for the operation, xx and yy are two-bit register numbers for the sources of data for the operations, and dd is a two-bit number for the destination register for the result. The "." in the register are bits that are not used and can be either 0 or 1 without affecting the operation of your circuit (i.e., your circuit should ignore them).

The codes for the operations are:

For example, if the INST register contains 00110001001000112, then the operation is 011 (+), xx is 01 (REG1), yy is 10 (REG2) and dd is 11 (REG3). The result of "executing" this instruction is to put the sum of the contents of REG1 and REG2 into REG3.

Your circuit should be able to "execute" one instruction in one cycle (even the shift), then stop. It should not have any registers other than INST (16 bits), REG0 (32 bits), REG1 (32 bits), REG2 (32 bits) and REG3 (32 bits).

To test your circuit, edit the exported .spec file and put various values in the INST and REGx registers, then run newlsim as you did in the previous lab assignment.

You can use any element supported by newlsgui/newlsim that you like. Multiplexors, adders, splitters and binders, and decoders should be especially useful.

Getting Started

In /classes/cs3421/common you will find three files: lab4.linux.lsg, lab4.solaris.lsg, and lab4.spec. If you use newlsgui on a linux machine, copy lab4.linux.lsg to your account and start drawing. If you use newlsgui on a Sun workstation, copy lab4.solaris.lsg to your account and start drawing. If you don't use newlsgui at all, copy lab4.spec to your account and start editing.

Submitting

If you write newlsim input directly, then the file must be named "lab4.spec" and must refer to the registers by the names shown above. The registers must have initial values (but any value is ok), and there must be a "*" before "reg". For example, your lab4.spec file must have the lines:

We have an automated grading script that searches for these names, changes the the initial values, and runs newlsim. If you don't have these lines exactly as shown (except for initial values), the script won't work and you won't get credit for a circuit that otherwise works just fine. The lines don't have to be in this order either.

Also, do not delete the element called CLOCK from the circuit, and don't delete any connections that are already there. Your circuit won't work if you do.

Then use the submit command to electronically submit your "lab4.linux.lsg", "lab4.solaris.lsg", or "lab4.spec" file to "cs3421", assignment "lab4" by the due date.

You must submit your program by the due date/time in order to receive credit.

Late assignments will get a grade of 0.