Project 4: Processor Design

CS61C Spring 2014

Due Sunday, May 4th, 2014 @ 23:59:59

Updates

Overview

In this project, you will be implementing a 2-stage pipelined processor for the Ida assembly language (a language designed specifically for this project!). It is absolutely necessary to thoroughly read through the Ida Manual to be able to complete this project, as there are substantial differences (both simplifications and complications) from MIPS.

Before you begin, some points to consider:

Getting Started

For this project, you should work in groups of two (however, you may work solo). You are not allowed to show or share your project files with any other students, friends, and such. This includes files you write for testing.

As usual, note that looking at solutions from previous semesters is also strictly prohibited. We have various tools at our disposal to detect plagiarism and they are very good at what they do.

Files

Before you begin, copy the start kit to your project 4 directory:

cp -r ~cs61c/proj/04/* proj04

The following files are given:

Pipelining

You will be implementing a 2-stage pipeline, specifically including the following stages:

  1. Instruction Fetch - fetch an instruction from instruction memory
  2. Decode - everything else (decode and execute the instruction, then write back the results)

Note that data hazards are not present in this design, since every data access from any source occurs only in one pipeline stage. However, control hazards must still be accounted for. Ida does not expose branch delay slots to software. In other words, the instruction immediately after a jump is not necessarily executed if the jump actually occurs. By the time you have figured out that a jump is in the execute stage, you have already accessed the instruction memory and possibly pulled out the wrong instruction. Thus you will need to "kill" the instruction being fetched if the instruction currently being executed is a taken jump (which is to say that jumps that are not taken should not cause a kill).

Instruction kills for this project MUST be accomplished by MUXing a nop into the instruction stream and sending the nop into the execute stage (instead of using the fetched instruction). Notice that every Ida instruction contains numerous possible nops (every instruction can be turned into a nop using the ?NO comparison query). However, you MUST use 0x00000000 as a nop, for grading purposes.

Because all of the control and execution is handled in the Execute stage, your processor should be more or less indistinguishable from a single-cycle implementation, barring the one-cycle startup latency and the jump delays. However, we will be enforcing the two-pipeline design. If you are unsure about pipelining, it is perfectly fine (and even recommended) to first implement a single-cycle processor. This will allow you to first verify that your instruction decoding, control signals, arithmetic operations, and memory accesses are all working properly. From a single-cycle processor, you can then split off the instruction fetch stage with a few additions and a few logical tweaks.

You might also notice a bootstrapping problem here: during the first cycle, the instruction register sitting between the pipeline stages won't contain an instruction loaded from memory. How do we deal with this? It happens that Logisim automatically sets registers to zero on reset. The instruction register will then contain a nop. We will allow you to depend on this behavior of Logisim (which is required as specified in the Ida Manual).

Starting Circuit Files

Layout

The general layout of the skeleton files is demonstrated with the ALU skeleton file shown here.

In this example, the top row contains the actual input and output pins. These must not be moved or changed under any circumstances! Connect to these pins using tunnels. Each file also has a helpful group of display probes, which merely display the inputs and outputs in a more readable format. These probes can be ignored, moved, or changed as desired.

REG.circ

You will design a register file to manage the sixteen 24-bit registers in Ida. After being told to write data to a particular register, you will be able to retrieve that data by asking for the value of that register on subsequent clock cycles.

Note:

Input Description
reg1Readthe first register to read from
reg2Readthe second register to read from
reg3Writethe register to write to, which is also the third register to read from
writeValthe value to write to the specified register
write?enables writing to the register
clkthe clock pulse

Output Description
reg1Valthe first read register value
reg2Valthe second read register value
reg3Valthe third read register value
R00 - R15all the register values; used for debugging and grading only

WARNING: BE CERTAIN NOT TO CHANGE OR MOVE THE INPUT OR OUTPUT PINS OF THIS CIRCUIT!

ALU.circ

You will also design an ALU that your processor will use to do math. You will tell your ALU what operation to perform, and it will drive its output with the result of that operation.

Note:

Input Description
s1the first ALU operand
s2the second ALU operand
operationthe operation number that identifies which instruction is being executed (for operations that do not use the ALU, output 0)
  1. Shift Left Logical
  2. Shift Right Logical
  3. Shift Right Arithmetic
  4. Rotate Left
  5. Rotate Right
  6. And
  7. Inclusive Or
  8. Exclusive Or
  9. Addition
  10. Subtraction
  11. Addition
  12. Addition
  13. Some Sort of Signed Comparison
  14. Some Sort of Unsigned Comparison
  15. 0
  16. 0

Output Description
resultthe result of the selected operation

WARNING: BE CERTAIN NOT TO CHANGE OR MOVE THE INPUT OR OUTPUT PINS OF THIS CIRCUIT!

CPU.circ

The CPU contains most of the processor, excluding instruction memory. The reason for this involves testing concerns. There are several things to note here:

Note:

Input Description
instthe next encoded instruction to execute
clkthe clock pulse

Output Description
nextPCthe next program counter to use
memDatathe data that is being written into memory if memory writing is active, or garbage otherwise; used for debugging and grading only
memAddrthe address that would be written to in memory if memory writing is active, or garbage otherwise; used for debugging and grading only
memWrite?whether writing to memory is enabled; used for debugging and grading only
R00 - R15all the register values; used for debugging and grading only

WARNING: BE CERTAIN NOT TO CHANGE OR MOVE THE INPUT OR OUTPUT PINS OF THIS CIRCUIT!

RUN.circ

This test harness contains the remainder of the CPU logic, and is used to run the processor. Since you will not submit this file, any changes you make will not be graded.

Questions

The provided QUESTIONS file contains a few short questions for you to answer. They are also listed here for reference. Please answer them within the QUESTIONS file.

  1. Briefly explain how you implemented comparison queries and how they affected your control block's signals (in a few sentences).
  2. Please list your control block's control signals, and briefly explain what each one does (in a sentence or less each).
  3. What features (if any) of this assembly language do you like?
  4. What features (if any) of this assembly language do you not like?

Logisim Notes

It is strongly recommended that you download Logisim and to run on your local machine while developing your processor to avoid overwhelming the instructional machines. Though Logisim is relatively stable, it is still recommended that you save often, and also make backup copies of your .circ files early and often. The official version of Logisim we will be using for evaluation is v2.7.1.

Some Helpful Hints:

Testing

Once you've implemented your processor, you can test its correctness by writing programs to run on it! This simple program has been provided for you as a basic sanity check: halt.ida. This program loads the values 1-15 into registers 1-15, and then attempts to "halt" by performing an infinite loop. If it fails to halt (for example, due to an error in your jump computation), it will then set all registers to 0.

See the Ida Manual to review how the assembler and emulator works.

After the hex files have been assembled (and hopefully run through the emulator), they can be loaded into a logisim RAM unit. Loading a hex file should be done before running a simulation normally.

Please note that you are EXPECTED to fully test your circuit as this is the ONLY way for you to know if you completed everything correctly. Also note that in the event the emulator differs from the behavior defined in the Ida Manual, you should assume the manual is correct.

Submission

Make sure to fill out the questions in the QUESTIONS file before submitting.

You must submit only the following files:

Again, this means that none of your circuits may use other external circuits. Submit in the usual way:

submit proj4

This project is due in its entirety on Sunday, May 4th, 2014 at 23:59:59.

Grading

This project will be graded in large part by an autograder. Readers will also glance at your circuits. If some of your tests fail the readers will look to see if there is a simple wiring problem. If they can find one they will give you the new score from the autograder minus a deduction based on the severity of the wiring problem. For this reason and as neatness is a small part of your grade please try to make your circuits neat and readable.