Computer Science Lab#4

profilefadoo
cs1150_lab4_fall2018.doc

CS1150 Introduction to Computer Science

Lab #4 – Logic Gates and Circuits, 40 points

Objective:

To experiment with digital logic circuits using a simple logic simulator.

Instructions:

Make sure to do the Activity as outlined in the LabCH06.pdf file. The activity is actually a tutorial that will help you to solve the problems in the exercises. It is expected that you will complete the Activity before you begin the exercises.

When you are finished, save and rename the completed document as “firstname_lastname_lab4.docx”. Then, submit the saved document to Pilot.

Exercise 1: (10 points)

1) Start the "LogicGates" applet, and add

· Two (2) switch(inputs) elements,

· One (1) AND gate elements,

· One(1) NOT gate elements,

· One (1) output element.

Arrange them like so:

· with the two (2) switches feeding into the AND

· with the output of the AND going to the NOT

· with the NOT's output going to the output element.

Take one screenshot of your circuit. Submit it with the rest of your work.

Put the screenshot of your completed circuit below this line.

2) Press the Run button and try out all four combinations of inputs for the switches, recording the results in your word document, formatted as a truth table.

Construct your truth table for the above circuit below:

Exercise 2: (10 points)

1) Start the "LogicGates" applet and add

· Four (4) switch(inputs) elements,

· Three (2) OR gates,

· One (1) AND gate and

· One (1) output elements.

Arrange them so

· two switches feed into one OR

· while the other two switches feed into the other OR gate.

· Then the two outputs of these OR gates feed into the AND gate….

· And the output of that AND gate goes to the output element.

Take one screenshot of your circuit. Submit it with the rest of your work.

2) How many combinations of switch values can you have with four switches? How did you get this number?

Write your answer here:

3) Press the Run button and try out all combinations of inputs for the switches, recording the results in a truth table in your word document.

Put your Truth Table below this line. Remember: Don’t record the combinations randomly, count up from zero!

Exercise 3: (10 points)

1) Start the "LogicGates" applet and add

· Four (4) switch(inputs) elements,

· Three (2) XOR gates,

· One (1) NAND gate and

· One (1) output elements.

Arrange them so

· two switches feed into one XOR

· while the other two switches feed into the other XOR gate.

· Then the two outputs of these XOR gates feed into the NAND gate….

· And the output of that NAND gate goes to the output element.

Take one screenshot of your circuit. Submit it with the rest of your work.

2) How many combinations of switch values can you have with four switches? How did you get this number?

Write your answer here:

3) Press the Run button and try out all combinations of inputs for the switches, recording the results in a truth table in your word document.

Put your Truth Table below this line. Remember: Don’t record the combinations randomly, count up from zero!

Exercise 4: (10 points)

Now we will do an exercise with custom logic gates.

Every logic gate’s behavior can be entirely described using its truth table. To put it another way, if you want a special, custom logic gate, you need to simply write down what its response is for every possible input combination. The applet you are using allows you to put “Truth Tables” (custom logic gates) in your circuit, then edit them to achieve whatever logic gate behavior you wish.

We will use our truth table gates to implement one-bit binary addition. One gate will output the “SUM” part of the addition, the other one will output the “CARRY-OUT” part

1) Start the “LogicGates” applet. Build a circuit with:

· three (3) switch elements,

· two (2) custom logic gates (the applet calls these “Truth Tables”),

· and two (2) output elements.

Example 4 from the pull-down examples sets up some of this. Choose example 4 and add to it.

2) Connect all switches to both truth tables, then connect each custom gate to one output.

3) Label your inputs A, B, and C.

4) Label one custom gate “SUM”, and the other “CARRY-OUT”

5) Adjust the two custom gates so that one implements SUM and the other implements CARRY-OUT (see next page)

TIP: Click “Edit TT” with the custom gate selected, then add rows and columns as necessary. It’s easiest to do this in a text editor like notepad++, then copy and paste to the applet.

See the next page for a pair of truth tables you can copy.

Here is the truth table for the SUM gate. Edit your custom gate to match.

A

B

C

SUM

0

0

0

0

0

0

1

1

0

1

0

1

0

1

1

0

1

0

0

1

1

0

1

0

1

1

0

0

1

1

1

1

Here is the truth table for the CARRY-OUT gate. Edit your custom gate to match.

A

B

C

CARRY-OUT

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

See the next page for a picture of how it is all supposed to look.

image1.png

This is what it should look like.

6) Test your circuit, and make sure it gives you the correct results for binary addition.

7) Take a screenshot of your program after you run it on one of the combinations of the three (3) inputs. Submit the screenshot with the rest of your work.

Place the screenshot of your one-bit binary adder below this line:

Rubric (40 pts possible):

Exercise

Points

1

Question 1

5

Question 2

5

2

Question 1

4

Question 2

2

Question 3

4

3

Question 1

4

Question 2

2

Question 3

4

4

Question 1

2

Question 2

1

Question 3

1

Question 4

1

Question 5

2

Question 6

2

Question 7

1

Total

40