Lab 5: Addition Circuits!
[50 points; individual or pair] (filename: hw5 ...) (These will be screenshots. The files will be online.)Getting started with CircuitVerse and the hw5 starter circuits
This week you will design several circuits using an online digital-circuit design tool called CircuitVerse.You'll use CircuitVerse throughout this week's hw (with the same online file, in fact).
Use Chrome (not Safari)
Mac user? For Circuitverse, Chrome (Google's browser) seems happier with the wire-drawing than Safari (Apple's browser).- It can be done in Safari—and has been...
- In Safari, the wire-drawing tends to be "stickier" (which means you're likely to get more accidental short-circuit connections)
Create a CircuitVerse account ...
First, coffee! Then, do this: Create an account with Circuitverse- It's easier to "fork" your own copy of our starter circuits if you already have an account...
- You'll need to create an account
- We ask you to submit screenshots, both to be safe and to simplify checking...
Fork our hw5 "starting circuits" to create your own
Once you have an account and are logged in, you should be able to open this set of "starting circuits": https://circuitverse.org/users/26206/projects/95720 Starting Circuits for cs5 hw5circuitverse.org/users/26206/projects/95720 From, there click the Fork button—and you will have your own copy on which to work. Here's the screen inviting you to fork your own copy of the starter circuits:
Launch Simulator and you're circuit'ing!
Once you've "forked," there should be a Launch Simulator button. Here's what it will look like: Click launch and you're developing your circuits!Warning: Save often!
Circuitverse is a browser-based application... It's capable, but not perfect! It has gotten stuck in the "saving" state before... So, Save Often!:The most common problem is short-circuits. Drawing wires upstream will avoid many of these!
- In our circuits, information usually flows downward and to the right...
- Drawing to the left and upward will avoid accidental "short circuits" across the gates' inputs:
Lab 5: Circuit addition !
There are three parts to this lab:- getting started with XOR
- building a Full Adder (we designed this in class)
- building a Ripple-Carry Adder
Part 1: Getting started with XOR
The XOR exclusive or function is sometimes considered a building-block gate, along with AND, OR, and NOT.- XOR is the "not-equal" function, for two one-bit inputs.
- That is, it outputs 1 (True) when the two inputs are not equal, and 0 (False) otherwise.
- However, as you're about to show, XOR can be built from ANDs, ORs, and NOTs:
Plus, this gives us a chance to get used to the Circuitverse interface!
- So, to get started, you should see a placeholder tab for an XOR circuit. Here's what it should look like:
- Our goal here is to build an XOR circuit to get familiar with gates and the other parts of the interface. Here it is
Be sure to try out the four possible input patterns:
- inputs: 00 desired output: 0
- inputs: 01 desired output: 1
- inputs: 10 desired output: 1
- inputs: 11 desired output: 0
Part 2: Designing and building a Full Adder
- Double-click on the FullAdder circuit tab in your hw5 project.
- The inputs and outputs (and truth table) are all present.
- Your task is to create a FullAdder
- a FullAdder takes in three bits of input (considered individual 0's and 1's).
- It yields two bits of output (considered a two-bit binary number).
- That output should be the sum of the three one-bit inputs.
- Remember the output is in binary, 00 (0) through 11 (3).
- The carry is the name for the left-hand binary digit of the output (it is the one that will "carry" later on).
- The sum is the name for the right-hand binary digit of the output.
- Look over the truth table for the FullAdder
- This image has most of it:
- Your full adder should use the minterm expansion principle to create four AND gates for the "sum" bit and four AND gates for the "carry out" bit. Students in CS 5 Gold designed (on paper) a full adder in class.
- Now is the chance to implement it in a verifiable fashion!
- You will want to use the "rails" for the three input bits named x, y, and c (this c is "carry in").
- There will be four AND gates whose outputs are connected to one OR gate and from there to the Sum output bit.
- There will be four AND gates whose outputs are connected to one OR gate and from there to the CarryOut output bit.
- Each of the two outputs demonstrates a separate application of the minterm expansion principle.
- Please don't try to simplify your circuit and please don't use gates other than
AND
,OR
, andNOT
. - The purpose of this problem is to practice using the minterm expansion principle, not to optimize—we have another problem for that.
- Watch out! You'll need three-input AND gates! By default, they only have two inputs... .
- You will need three-input AND gates and four-input OR gates (or even five, if you prefer).
- With a gate selected, the properties menu on the left (or right) allows you to change the input size Thank you, Lily!
- With a gate selected, the properties menu on the left (or right) allows you to change the input size Thank you, Lily!
- Be sure to thoroughly test your FA before moving on: try all EIGHT input combinations
- Your FA needs to work, because you'll use it in building your four-bit ripple-carry adder, next...
Part 3: Building a 4-bit ripple-carry Adder
- Move over to the ripple-carry adder subcircuit in your circuit file:
- Now that you have a full adder (FA), you will build a 4-bit ripple-carry adder. Recall that this device takes two 4-bit numbers and adds them up. Let's call the digits of the first number X3, X2, X1, X0 where X0 is the least significant bit (the rightmost bit) and X3 is the most significant bit. Similarly, let's call the digits of the second number Y3, Y2, Y1, Y0. We wish to compute:
X3 X2 X1 X0 + Y3 Y2 Y1 Y0 ---------------
- Notice that although there are only 4 bits in each of the two numbers, the sum can have 5 bits due to the carry output (of the leftmost bit!)
- You can "drop in" your FullAdder: you will need four of them, one for each "column" of the addition...
- First, in the FullAdder, click on a blank area to bring up "Project Properties" on the left.
- Under "Project Properties", click "Edit Layout" (you may have to scroll down a bit to find it).
- You can now move the green connection points around. We suggest that you put "y" and "x" along the top (in that order), "c" on the right, "sum" on the bottom, and "carry out" on the left. (If you have trouble selecting points, try zooming in on the canvas.) Then click the "Save" check-mark in the "Layout options" box (again, you may have to scroll down).
- Now return to the ripple-carry adder, go to the Circuit menu, and choose Insert Subcircuit. Then choose the FullAdder as the one to insert.
- In class we sketched (roughly) how four full adders would be used to create a 4-bit ripple-carry adder:
Submitting your screenshots
Test your circuits and then be sure to save them using the Save Online option. Take a screenshot of all three—and submit those three images (all at once) under hw5pr1- The XOR circuit,
- your full-adder circuit, and
- your four-bit ripple-carry adder circuit.
- Drop all three screenshots on the "drag+drop" rectangle or
- Use the usual interface and control-click (or command-click) all the files you want.