Question: Task 3 : Build a signed adder Implement a 1 6 - bit signed adder using any algorithm you wish, provided the circuit has a
Task : Build a signed adder
Implement a 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 with respect to signed inputs This circuit must have an input named CarryIn. You will use this input for future projects.
Your inputs must be named InputA, InputB, and CarryIn. Your circuit will not work with my tests otherwise.
Your outputs must be named Output, CarryOut, and Overflow. CarryOut is the carry out from the last full adder. It is also, in effect, the overflow indicator for unsigned inputs. Overflow is the overflow indicator for signed inputs. CarryOut and Overflow will not necessarily have the same value.
You may use SampleSignedBitAdderTest as a basis for your own tests. A word of warning: these tests scripts are incomplete. Don't assume that a circuit passing these sample tests will pass all of my tests. Add test cases to ensure correct functionality.
Rules:
The simulator comes with a builtin adder. You may not use the builtin adder.
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.
You must write all of your own chips. Do not share "internal" chips with your classmates or download them off the Internet.
Be sure to test your components thoroughly. Just because it passes the included tests does not mean it will pass mine. test your adder yourself using DLUnit.
SampleSignedBitAdderTest
import org.junit.Assert;
import org.junit.Test;
import static edu.gvsu.dlunit.DLUnit.;
Sample test cases for an signed, bit adder with a carryin and overflow.
IMPORTANT: These test cases do not thoroughly test the adder. You need to
rename this class and add more tests!
public class SampleSignedBitAdderTest
The complete list of integers to be tests.
IMPORTANT You need to add to this list
public static final long testIntegersx;
Helper method that runs a test for a given pair of integers and a carryIn.
protected static void verifylong a long b boolean carryIn
Compute the expected outputs
long carryInAsInt carryIn : ; convert the Boolean to or
long expected a b carryInAsInt; expected output value
The overflow output should be true if the expected output is not in the
range
In java takes the bit string and shifts it left
spaces, effectively
generating the value
boolean expectedOverflow expected expected ;
Output "wraps around" if there is an overflow
if expectedOverflow && expected
expected ;
else if expectedOverflow && expected
expected ;
Configure and simulate the circuit
setPinSignedInputA a;
setPinSignedInputB b;
setPinCarryIn carryIn;
run;
Check the correctness of the output
String message of a b with carryIn a : no carry in;
Assert.assertEqualsOutput message, expected, readPinSignedOutput;
Assert.assertEqualsOverflow message, expectedOverflow, readPinOverflow;
Quick tests designed to quickly catch major errors. Also serve as example
tests
@Test
public void zerozerofalse
verify false;
@Test
public void zeroonefalse
verify false;
@Test
public void zerozerotrue
verify true;
@Test
public void zeroonetrue
verify true;
This is actually rather gross; but, it is an effective way to thoroughly test
your adder without
having to write hundreds of individual methods.
@Test
public void testAll
for long a : testIntegers
for long b : testIntegers
verifya b false;
verifya b true;
end testAll
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
