CIS 351 |
Project 2: Build a Subtractor and Comparator |
Winter 2021 |
Extend your signed adder from the previous project to build
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.
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
A < B
, then A - B < 0
, andA ≥ B
, then A - B ≥ 0
.
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.
JLS
and DLUnit
. Commit and push your circuits often.
This assignment will be scored out of 50 points.
Category | Rubric | Maximum Score |
---|---|---|
Adder/Subtractor | ||
Not attempted | 0 | |
Substantially complete, but passes no tests | 3 | |
Passes a few tests | 5 | |
Correctly adds and subtracts (but overflow does not work correctly) |
8 | |
Passes all tests | 10 | |
Sltu | ||
Not attempted | 0 | |
Substantially complete, but passes no tests | 4 | |
Passes a few tests | 6 | |
Passes all tests | 12 | |
Slt | ||
Not attempted | 0 | |
Substantially complete, but passes no tests | 4 | |
Passes a few tests | 6 | |
Passes all tests | 12 | |
Date 100% correct | ||
Two days early | 12 | |
One day early | 11 | |
On time | 10 | |
One day late | 8 | |
(-2 per day) | ... | |
Five or more days late | 0 | |
Presentation | ||
Documentation and Neatness | 6 |
Penalties
To submit your project:
jls
files that includes the names of everybody on the team.
[Grade Me]
to the commit message.Updated Monday, 28 December 2020, 6:46 PM