CS 111
Fall 2018

# Lab 5: Digital circuits

### Task 0: Become familiar with Logicly

In Problem Set 5, you will be using a circuit-design tool called Logicly.

If you haven’t already installed it, you should follow the instructions found here:

Let’s review how to use it together.

### Task 1: Practice minterm expansion

Consider the truth table below, which represents an unknown boolean function:

x y z boolean function’s value
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1

On paper, create the minterm expansion formula for this truth table. Here is a reminder of the steps:

1. Delete all rows from the truth table where the value of the function is 0.

2. For each remaining row, create a minterm as follows:

• For each variable that has a 1 in that row, write the name of the variable. If the input variable is 0 in that row, write the variable with a negation symbol to NOT it.

• AND all of these variables together (using multiplication).

3. Combine all of the minterms for the rows using OR (i.e., addition).

### Task 2: Practice building a circuit

Once you have completed the formula for Task 1, use Logicly to build the corresponding circuit.

and open it in Logicly.

Note that we’ve provided you with:

• switches for the inputs x, y, and z

• a NOT gate for the negation of each input; for example, the leftmost switch is for x itself, and the NOT gate immediately to its right is for NOT x

• a light bulb for the output.

You may need to use the Pan Tool (the hand icon available at the top of the screen) and the magnification slider available in the lower right-hand corner to adjust how much of your circuit is visible. After using the Pan Tool, don’t forget to switch back to the Selection Tool (the arrow icon).

When constructing the circuit, remember that:

• each minterm in the minterm expansion should get its own AND gate
• the outputs of the AND gates should be fed into an OR gate.

Once you have completed the circuit, test it by clicking the input switches to turn them on and off. Check to see if you obtain the correct output for all possible inputs.

After testing, make sure to save the final version of your circuit.

### Task 3: More practice with circuits

1. Build a circuit that represents a NAND gate, which has the following truth table:

x y x NAND y
0 0 1
0 1 1
1 0 1
1 1 0

Use the following file for your work:

Once you are done, make sure to save the final version of your circuit.

2. To practice exporting and importing a circuit in Logicly, let’s export your NAND circuit and use it in another circuit.

2. Click the building block icon (which looks like a Lego piece) at the top of the screen. (Alternatively, you can select the Edit->Create Integrated Circuit menu option.)

3. In the window that pops up, give your circuit a name (e.g., My NAND) by entering it in the Full Name text box. You can also add a Symbol Label, but doing so is not required.

4. Click the Create IC button to create the integrated circuit.

5. Use the File->Export Integrated Circuit Library menu option to export your work. Give the file an appropriate name (e.g., my_nand) and save it in a place where you can easily find it.

Using your NAND circuit in another circuit:

and open it in Logicly.

2. Use the File->Import Integrated Circuit Library menu option to import the file in which you stored your exported NAND circuit in step e.

3. After importing the file, scroll down to the bottom of the left-hand pane of components. You should see a section labeled Custom that contains a lego-like building block for your NAND circuit. (Do not use the built-in NAND gate under Logic Gates. Use your building block under Custom.)

4. You can insert a copy of your NAND building block into your circuit by using the Selection Tool to drag the NAND building block into the circuit. You should see a box that looks like this:

5. Add wires to connect :

• the input switch for x to the pin x in your NAND building block

• the input switch for y to the pin y in your NAND building block

• the output of your NAND building block to the output light bulb of the circuit.

6. Test different combinations of values for the inputs, and you should see that your NAND building block behaves exactly the way that your NAND circuit did!

7. Once you are done, make sure to save the final version of your circuit.

3. Build a partial arithmetic logic unit that accepts three inputs: x, y, and op, where a value of 0 for op means that the circuit should compute and output x + y (with carry) and a value of 1 for op means that the circuit should compute and output x * y.

Begin by filling in the following truth table:

op x y r1 r0
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

where r1 and r0 are the two bits of the result:

x
y
-----
r1 r0

In the case of addition, r1 is the carry bit. In the case of multiplication, r1 will always be 0.

Next, use minterm expansion twice – once for each result bit – and create a separate subcircuit for each of those bits.

Use the following file for your work:

Once you are done, make sure to save the final version of your circuit.

You should use Apollo to submit the following files: