CIS 451 Project 1: Building an ALU with JLS

Author: Zack Kurmas, with very minor modifications by Andrew Kalafut


Objective: Gain a better understanding of an ALU throught building one. Additionally, gain experience with the JLS simulator.

Deliverables:

  1. Add a text box to your jls files that includes Your adder should also include a label indicating time and gate count. The time should be the maximum simulation needed for any addition. (I'm looking for an actual number, not a big-O expression.)
  2. Upload all relevant .jls files, bug reports, and test scripts to the assignment on Blackboard by 11:59 PM on 2/6/2013. (Attaching your test scripts allows me to determine how well you tested your code, and assess partial credit if necessary.)
  3. Print and submit copies of all relevant circuit diagrams. (When printing diagrams use the "File -> Print -> Just Visible Window" option. There should be one page per .jls file.). These are due in lab 2/7/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/7/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.


Goal:

For this project, you will use JLS to implement a simple ALU. In particular, your ALU must be able to add, subtract, and multiply two 16-bit signed integers. Notice that you will not be implementing the ALU described in the textbook. Your ALU will be able to multiply and detect overflows, but you need not implement logical operations (and, or, etc.), shifts, or compares.

Background:

You should make an effort to complete the background section in Lab on Thursday Jan 17 if there is sufficient time.

Before doing the rest of this project, please work through the steps on the JLS Intro page. This page explains how to set up and use JLS, as well as use the JLSCircuitTester testing suite.

Components

You will build the following four components:

Component Instructions Interface
Adder Implement a 16-bit signed adder using any algorithm you wish, provided the circuit has a reasonable running time and size. Faster adders will receive more points. (See Grading section below.) Your adder must report overflow conditions when they occur. Notice that this circuit must have an input named CarryIn. You will use this input when building your Adder/Subtracter. For addition, CarryIn will always be 0.
File name: SignedFullAdder_16bit.jls
Inputs: InputA, InputB, CarryIn
Outputs: Output, Overflow
Test Script: testSignedFullAdder_16bit
     
Adder / Subtracter This component must perform both signed addition and signed subtraction. Surround your adder with additional gates so that it performs both addition and subtraction, thereby avoiding duplicating the adder in order to perform subtraction. (Be sure to ask for clarification if you don't understand this requirement.) Use the Op input to specify subtraction (1 means subtract, 0 means add). Again, this component must report overflow when it occurs.
File name: SignedAddSubtract_16bit.jls
Inputs: InputA, InputB, Op
Outputs: Output, Overflow
Test Script: testAddSubtract_16bit
     
Multiplier This component must perform signed 16-bit multiplication. The product of two 16-bit numbers can be as large as 32 bits. Your circuit must have two 16-bit outputs named high and Output that contain the high and low 16 bits from the 32-bit product. Your component must also have an Overflow output indicating whether the answer fits entirely in the low 16-bits. You may implement any algorithm you like, provided it runs in polynomial time (with respect to the number of bits). You may also use as much hardware as you like. Most students implement a version of the multiplier shown in Figure 5.18 on page 252 of the Harris and Harris text. See hint below.
File name: SignedMultiplier_16bit.jls
Inputs: InputA, InputB
Outputs: Output, Overflow
Test Script: testSignedMultiplier_16bit
     
ALU This component must perform 16-bit signed addition, subtraction, and multiplication. It takes as input two 16-bit signed integers, and a 2-bit opcode (00 for addition, 01 for subtraction, and 10 for multiplication). It will produce as output two 16-bit integers and a one-bit overflow indicator. When doing addition and subtraction, high should be 0. Remember to use the same physical hardware for addition and subtraction.
File name: ALU_16bit.jls
Inputs: InputA, InputB, Op
Outputs: Output, high, Overflow
Test Script: testALU_16bit

Rules

  1. The simulator comes with a built-in adder. You may not use the built-in adder in your adder or adder/subtracter. You must use the built-in adder when building your multiplier. If you try to use too many copies of your adder, JLS will run out of virtual memory and crash.
  2. To build the required circuits, you will probably find it useful to design and build several subcircuits. These subcircuits may have any interface you choose; however, you are responsible for testing them.
  3. You must write all of your own chips. In other words, you may not share "internal" chips with your classmates, or download them off the Internet.
  4. Be sure to test your components thoroughly. Just because it passes the test included here doesn't mean it will pass my test.

Hints and shortcuts


Grading

This assignment will be scored out of 100 points.

Component State of Code Maximum Score
Adder
Not attempted 0
Substantially complete, but passes no tests 6
Passes a few tests 14
Correctly adds positive integers only 20
Correctly adds positive and negative integers
(but overflow does not work correctly)
24
Passes all tests 30
Adder / Subtracter
Not attempted 0
Substantially complete, but passes no tests 2
Can do some addition and subtraction 4
Correctly subtracts positive integers 6
Correctly subtracts all numbers, but overflow doesn't work 8
Passes all tests 10
 
Multiplier
Not attempted 0
Substantially complete, but passes no tests 6
Passes a few tests 14
Correctly multiplies positive integers 20
Correctly multiplies all numbers, but overflow doesn't work 24
Passes all tests 30
 
ALU
Not attempted 0
Substantially complete, but passes no tests 2
Passes a few tests (at least one per operation) 3
Passes all tests 5

Other factors in grade: