University of California at Berkeley
College of Engineering
Department of Electrical Engineering and Computer Science

CS61C, Spring 2010

Sweet heaven, It's HW 7!

[TA] Long Wei

Due Wednesday, 2010.03.31 @ 11:59pm

Edit:

1. If you haven't gotten the testing confusion sorted out yet, or if you're just not confused, let me just say that you won't get penalized as long as you do something that looks even remotely helpful in testing your circuit.

2. This assignment was made possible by Ben Sussman, Paul Pearce, and probably other people that I don't know about.

In this assignment, you will implement a 16 bit ALU in logisim.

Functions

The nine functions that you will implement are: OR, AND, shift left logical, shift right logical, shift right arithmetic, add, subtract, and compare. The ALU will perform a desired function on two 16-bit inputs (A and B, where A0 is the lowest order bit for A, etc...) and output the Result. The function will be determined by the value of a control signal (S), as listed below.

In addition to the 16 bits of output provided in Result, two additional outputs will be provided: Signed overflow and Unsigned overflow. Unsigned overflow will have a high value iff the command was an add and unsigned overflow occured. Signed overflow will have a high value iff the command was an add or a subtract, and signed overflow occured. (You need not worry about unsigned overflow for subtractions.)

For the shift instructions detailed below (sll, srl, sra), the shift amount is ONLY the 4 least significant bits of B. You can ignore the other bits of B.

Here's what occurs for each operation:

S op Result
000 or A | B
001 and A & B
010 sll A << B (but logically, don't sign extend!)
011 srl A >> B (but logically, don't sign extend!)
100 sra A >> B (but arithmetically, do sign extend!)
101 add A + B (signal if either type of overflow occurs)
110 sub A - B (signal if signed overflow occurs)
111 cmp if (A < B) //Treat A and B as SIGNED!
Result = -1
else if (A > B)
Result = 1
else
Result = 0

But wait, there's more!

Think about intuitive ways to test your ALU. If the grader can look at your logisim file and immediately see that everything is in working order, it will be to your advantage. You might consider some method for automatically testing your ALU, such as a counter. Perhaps you should add testing logic that signals an error if an incorrect value is seen. Think about this, we want to see some form of testing suite in your outter-most circuit design.

Not Allowed In This Assignment

You may only use tools from the "Base" and "Gates" libraries in Logisim. Do not use any items from the Memory, Plexers, Arithmetic, or Legacy libraries. Any ALU pieces built using any of these illegal components will be given no credit.

Details & Hints

• LABEL EVERYTHING!
• You can download logisim for yourself as well as view more documentation at the logisim website: http://ozark.hendrix.edu/~burch/logisim/
• You can and should use multi-bit wires! Before or after placing a gate you can select the bit width of that gate. This means the number of bits which run through the input and output pins of that gate. For example, a 2 bit wide AND gate with two wires coming in and 1 wire going out actually is taking a 4 bit input and a 2 bit output. The gate performs the one bit AND function on each respective pair of inputs: it ANDs the two lowest order bits and outputs the result on the lowest order bit of the output, etc... The wires will automatically be the width of the input/output pin they are connected to, and Logisim will be kind enough to immediately report any inconsistencies in pins connecting to the same wire.
• Please use subcircuits! They make it easier for you, they make it easier for us. Give your subcircuits appropriate labels as well. Keep in mind that this won't be autograded, and humans will have to look at your schematics (and grade them!).
• The key to your sanity on this project is modularity. Don't be afraid to build subcircuits that are multiple levels deep.

Submission Details

Create a directory named 'hw7' containing the file alu.circ, and any additional files needed for your submission. While in that directory, run 'submit hw7'. If you included any additional files, make sure to say "yes" when the submit script prompts you about it.