CSCI 210: Lab 5

Adder/Subtracter
Due: 11:59 PM on Sunday, March 28th.

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 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 4.

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.

absc
0000110000001000000010100
0000110000001000100000100
0110100001010000010111000
0110100001010000100011000

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 starting with basic logic gates (i.e. and, or, not, nor, nand and xor). You are not allowed to use the circuitverse adder. We recommend the taking the following steps:

  1. Build a one-bit half-adder as a subcircuit.
  2. Build a one-bit full-adder out of half-adders, also as a subcircuit.
  3. Build an eight-bit adder/subtracter out of eight one-bit full-adders.

Hint: Both lecture 19 and Zybooks section 3.4 should be very useful.

C. Taylor