CIS 351

Project 2: Build a Subtractor and Comparator

Winter 2022

Extend your signed adder from the previous project to build

Setup

  1. Follow this GitHub Classroom link to create a repository for the project.
  2. Copy your adder from Project 1 into this new repo.

Task 1: Adder/Subtractor

Build a circuit that can do both addition and subtraction. Specifically, surround your adder with additional gates so that it performs both addition and subtraction. This circuit should contain one adder only. Be sure to ask for clarification if you don't understand this requirement.

Place your Adder/Subtractor in SignedAddSubtract_16bit.jls. Do not change the names of the input or output pins.

The Op input specifies whether to perform addition or subtraction. (1 means subtract, 0 means add).

The CarryOut and Overflow outputs should simply be the carry out and overflow from your adder. Unsigned subtraction cannot overflow. Unsigned subtraction that generates a negative result is not considered "overflow".

You may use SampleSigned16BitAddSubtractTest.java as a basis for your own tests. Warning! This test class is incomplete. Don't assume that a circuit that passes this sample test will pass all of my tests.

Task 2: Set if Less Than

Build a circuit that can compare two integers. It must support both signed and unsigned comparisons.

Use your adder/subtractor as a starting point and leverage the fact that

Be aware, however, that this algorithm works only as long as A - B doesn't overflow. You'll need to think about the conditions under which A - B might overflow and use alternate techniques for comparing A and B in this case. (Hint: Don't try to detect and react to overflow. That doesn't tend to work well. Instead, think about the conditions under which you might have an overflow.)

Place your comparison circuit in Slt_16bit.jls. Do not change the names of the input or output pins.

You may use SampleSlt16BitTest.java as a basis for your own tests. Warning! This test script is incomplete. Don't assume that a circuit that passes this sample test will pass all of my tests.

Rules

  1. You are strongly encouraged to work in groups of two. You may work alone only with permission of the instructor.
  2. The simulator comes with a built-in adder. You may not use the built-in adder.
  3. 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.
  4. 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.
  5. Be sure to test your components thoroughly. Just because it passes the test included here doesn't mean it will pass my test.
  6. You may use the built-in mux component.

Hints and shortcuts

Grading

You are expected to revise your circuits until both (1) the automated tests pass, and (2) your circuit design and layout have earned a score of "E" or "M". Project "Late Days" will accumulate until both requirements have been satisfied. Remember: There are two separate sets of tests to run.

You can accumulate up to -1 Late Days if you project meets all requirements before the deadline. (Negative Late Days can be used to offset any Late Days acquired on other projects or labs.)

Deliverables

To submit your project:

  1. Add a text box to your jls files that includes the names of everybody on the team.
  2. Commit and push your code.
  3. When your code passes all my tests, add [Grade Me] to the commit message.

Updated Tuesday, 8 February 2022, 3:21 PM

W3c Validation