Author: Zack Kurmas, with modifications by Andrew Kalafut
Objective: Use JLS to assemble the Single Cycle CPU described in Chapter 7 of the Harris and Harris textbook.
jlsfiles that includes
.jlsfiles, bug reports, and assembly code to the assignment on Blackboard by 11:59 PM on 2/27/2013.
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.
For this project, you are "assembling" the single-cycle CPU from the components shown in Figure 7.11 on page 375: a register file, an ALU, instruction memory, and a starter control unit. The register file, ALU, and instruction memory, are not difficult to implement; however, they will take too long to implement relative to the amount you would learn from the exercise. For the next project, you will implement your own control.
Begin by using JLS to assemble the single-cycle CPU shown in Figure 7.?? on page ??? in the textbook. In order for your CPU to work seamlessly with the test suite, it should use the following interface:
Your CPU should have all the data paths to support the following instructions:
|Branch if Equal||beq||I||4|
|Load Upper Immediate||lui||I||F|
|Set Less Than||slt||R||0||2a|
|Set Less Than Immediate||slti||I||a|
Aside from implementing these instructions, you must do the following:
Halt. The control recognizes a
haltinstruction (op code
0x20). In response, it places a
Haltoutput line. The starter control sets the
Errorline to 1 when it receives an input that does not correspond to an instruction. The
Errorline is included to make debugging easier. Your CPU need not utilize it.
PHSingleCycle.jlsshowing the clock cycle time.
CSinputs to RAM and ROM are active low.
memReadwires are 1 when a memory write or memory read is desired.
WEto 0 until the
addrelements are set. (Otherwise, you may end up writing to a random spot in memory.) One trick is to make the clock's "one time" small, and wait to set
WEuntil the clock rises from 0 to 1. If the "one time" is small compared to the "zero time", the rising of the clock from 0 to 1 will come at the very end of each cycle.
PC + 4, not
To test your CPU, you have it execute assembly code, then check that the registers and memory contain the expected values. You are responsible for writing code to thoroughly test your CPU. I am providing only the demonstration test files below. They are nowhere near a complete test of your CPU:
JLSCircuitTester suite contains a program,
jlsCPUTester, that takes as input (1) your
JLS circuit and (2) a file containing MIPS assembly code
As with previous projects, all the executable code needed for this
project is in
. If you add this directory to
your path, you will be able to run all test scripts directly from the
command line. If you choose not to add this directory to your path,
you will have to use the full path name when launching the scripts
below. To run the test scripts on your own machine, you must follow
As always, please tell me as soon as possible if you have any problems.
jlsCPUTesterdetects some bugs.
lw $16, val1is a pseudo instruction. It won't work unless both
instructions. You will want to maintain several different test programs. Make sure these programs are not named
instructions, and simply copy (not move) the program you want to test to
instructions. Once you have copied the file, JLS will automatically load instruction memory with the desired program. (The file
instructionsmust be in the current working directory. This is the directory from which you launched JLS. Be careful when launching JLS from an icon because it may not be obvious which directory is the current working directory.)
JLSCircuitTester suite contains
marsAssembler, a program that will take assembly files as
input and generate MIPS code formatted for use as an
instructions file: The file contains two columns. The
first is the word address of the instruction in hex, and the
second is the MIPS binary instruction in hex. Currently
marsAssembler writes only to the standard output. Use
file redirection to save the output to a file.
To examine the results of your program, place a watch on any registers of interest and the RAM unit for Main Memory.
Remember, you are responsible for writing code to thoroughly test your
CPU. 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, Feb 25. 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.
This project will be worth 100 points, divided as follows:
|overall design||15 points|
|neatness / documentation (This means add comments!)||5 points|
You lose "overall design" points for inefficiencies in your design. For example, you will lose points for setting your clock period ridiculously high instead of calculating the critical path length.
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
x is broken, you will receive 0 points for
y. Thus, if your I-type instructions are
broken, you will likely receive a 0 for the assignment.