Author: Zack Kurmas, with modifications by Andrew Kalafut
Objective: Use JLS to extend the the Single Cycle CPU from project 2 to support additional instructions, so that it will run code generated by a compiler. Additionally, this time you must write your own control unit.
jlsfiles that includes
.jlsfiles (please include a seperate JLS file for your control unit), bug reports, and assembly code to the assignment on Blackboard by 11:59 PM on
This project should be done in groups of 2. A group of 3 may be acceptable with permission of the instructor if there are an odd number of students.
You will need a working version of the CPU from project 2.
Add the following instructions to your single-cycle CPU. Your CPU must continue to support the instructions from the previous project as well.
jr are needed to call procedures.
used to implement the
jal should save the value PC+4 into register
31. Some instruction references say PC + 8. The "+8" is needed when
implementing a delay slot after the jump. Your CPU doesn't have a
delay slot, so the correct increment is 4, not 8.
Additionally, build a hard-wired control unit using JLS, then compute the number of gates used and the maximum time required by your control. Try to make your control as small and fast as possible. This control unit must be a separate JLS circuit that has the same interface as the starter control unit from project 2. (Your circuit may have as many sub-circuits as you like.) You must build a hard-wired control. You may not build a control that is effectively microcode. Specifically, your controller may not contain a ROM element, nor may effectively behave like a ROM element (e.g., you may not feed a bunch of constant values into a big mux). If you are not sure whether your design meets the spirit of the rules, please ask.
As with project 2, you are responsible for writing the code used to test your CPU. Your will need to write new tests for your new instructions.
When you are convinced your CPU works, upload your PHSingleCycleCPU.jls file. I will run my test scripts on your file. If my scripts show no errors, you will receive 10 points for your testing component. If my scripts turn up an error, you will get a chance to fix your code, but will lose 5 of these points. If the errors are still in your final project submission, you will lose the remaining 5 testing points. I will only do this once for each group, so do not submit until you are ready. This early submission must be before 11:59 PM on
Monday, Apr 1 Friday, Apr 5. Remember, the earlier you submit, the more time you will have to fix any errors. If you know a particular instruction doesn't work, be sure to include a note explaining so with your early submission. I will exclude it from testing. You will loose testing points only for bugs that you have not identified yourself. However, do not submit substantially unfinished processors unless you are not planning on completing the known unimplemented features. Your grade will be penalized if I believe you are acting outside of the intention of this system.
PHSingleCycleCPU.jls, it may be easier to write a test file and thoroughly test your control before importing it into
PHSingleCycleCPU.jls. Here is a sample file for testing your control.
1, even temporarily, it will cause the simulator to stop. You may need to add hardware to guard against this. One trick is to put a register before the "stop sign", so that the simulator stops only if the halt line is asserted at the end of a cycle.
addiushould require changes to the control only.
Prof. McGuire has installed a version of
gcc that will compile for MIPS at
/home/mcguire/pub/bin/mips-gcc. To compile
foo.c for mips, run the following command:
/home/mcguire/pub/bin/mips-gcc -mrnames -S foo.c
This will generate
The code generated by
mips-gcc will need some minor modifications to run with your CPU:
mips-gccwill add directives that Mars won't recognize. Most of these will be ignored; but, you may have to remove a few of the directives.
mips-gccwill produce a
j $rapseudo-instruction. You'll have to change this
.textdirective to make sure the program begins executing in
mainto make the program halt.
If you write a script to handle these changes automatically, feel free to contribute it for the use of the class.
This project will be worth 100 points, divided as follows:
|addu, addiu, and subu||5 points|
|xor and xori||5 points|
|number of gates in control||5 points|
|speed of control||5 points|
|neatness / readability||10 points|
Note: It may not be possible to effectively test some instructions if
others are broken. For example, it is not possible to test R-type
instructions without first using an I-type instruction to load some
registers. The list above reflects my testing order. If it is not
possible to easily test category
y because category
is broken, you will receive 0 points for category
if your I-type instructions are broken, you will likely receive a 0 for