CIS 451 Project 2: Single Cycle CPU

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.

Deliverables:

  1. Add a text box to your jls files that includes
  2. Upload all relevant .jls files, bug reports, and assembly code to the assignment on Blackboard by 11:59 PM on 2/27/2013.
  3. Print and submit a copy of your top-level circuit. This should be one page. These are due in lab on 2/28/2013.
  4. Fill out an evaluation of your partner for this project. The evaluation form may be found on blackboard, and is due in lab on 2/28/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.


Instructions

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:

Name Mnemonic Format OpCode
(in hex)
Func Code
(in hex)
Add add R 0 20
Add Immediate addi I 8
And and R 0 24
And Immediate andi I c
Branch if Equal beq I 4
Halt halt   20
Jump j J 2
Load Word lw I 23
Load Upper Immediate lui I F
Nor nor R 0 27
Or or R 0 25
Or Immediate ori I d
Set Less Than slt R 0 2a
Set Less Than Immediate slti I a
Store Word sw I 2b
Subtract sub R 0 22

Aside from implementing these instructions, you must do the following:


Hints


Testing

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:

The JLSCircuitTester suite contains a program, jlsCPUTester, that takes as input (1) your JLS circuit and (2) a file containing MIPS assembly code and

  1. assembles the file into MIPS machine code,
  2. simulates the running of your CPU with the machine code,
  3. runs the machine code using MARS, and
  4. compares the final state of your CPU to that calculated by MARS.

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 the JLSCircuitTester installation instructions.

As always, please tell me as soon as possible if you have any problems.

Two Notes:

  1. Registers 0, 1, and 25-31 have special purposes in MIPS. Be careful when writing MIPS assembly code using these registers explicitly. Although it won't affect the running of your CPU under JLS, it may affect how MARS simulates your code and, thus, affect whether jlsCPUTester detects some bugs.
  2. Be aware of pseudo instructions when writing MIPS code. For example, lw $16, val1 is a pseudo instruction. It won't work unless both lui and lw work.
To debug your CPU, you may want to run test programs by hand. The Instruction Memory provided is configured to load instructions from a file named 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 instructions must 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.)

The 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.

Important note:

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.


Grading

This project will be worth 100 points, divided as follows:

I-type 15 points
R-type 15 points
lw 10 points
sw 10 points
branch 10 points
jump 10 points
overall design 15 points
neatness / documentation (This means add comments!) 5 points
testing 10 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 y because category x is broken, you will receive 0 points for category y. Thus, if your I-type instructions are broken, you will likely receive a 0 for the assignment.