CSCI 210: Lab 6
Adder/Subtracter
Due:
11:59
PM
on
Sunday,
July
19th.
Partners
You may work with a partner for this lab. If you work with a partner, please submit a single assignment through circuitverse.org - you should be able to add a partner to your assignment using the "Add Collaborator" button when you start the assignment. If you work with a partner, you must also fill out this form to let me know.
If you choose to work with a partner, you and your partner must complete the entire lab together. Dividing the lab up into pieces and having each partner complete a part of it on their own will be considered a violation of the honor code. Both you and your partner are expected to fully understand all of the code you submit.
Adder/Subtracter
We will be using circuitverse.org for this assignment, just like we did for Lab 5.
In this lab, you will build an eight-bit adder/subtracter that takes in two 8 bit numbers, a and b, and one select value, s and has an 8 bit output, c. If s is zero, your adder should output a+b. If s is one, your adder should output a-b. For some examples, look at the table below.
a | b | s | c |
00001100 | 00001000 | 0 | 00010100 |
00001100 | 00001000 | 1 | 00000100 |
01101000 | 01010000 | 0 | 10111000 |
01101000 | 01010000 | 1 | 00011000 |
Note that in the third example, we get the wrong answer because of overflow - just like many modern programming languages, we are going to ignore this.
You are required to build this adder/subtracter using only with basic logic gates (i.e. and, or, not, nor, nand and xor). You are not allowed to use the circuitverse adder. You should take the following steps:
- Build a one-bit half-adder as a subcircuit.
- Build a one-bit full-adder out of half-adders, also as a subcircuit.
- Build an eight-bit adder/subtracter out of eight one-bit full-adders.
You are required to have a separate half-adder and full-adder subcircuit to get full credit for the lab.
Hint: Both lecture 18 and Zybooks section 3.4 should be very useful.