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

ALU-spec.png

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

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.