1 objectives - university of british columbia

7
CPSC 121: Models of Computation Lab #3: Implementing circuits using the Magic Box Collaboration: For this lab, you may work in teams of two. Each team member must be able to answer questions based on or use skills developed in the lab (including working The Magic Box). Only one pre-lab submission and in-lab report is needed per team. We suggest that team members adopt and regularly change “driver” and “navigator” roles, where the “driver” works with the lab tools while the “navigator” checks the driver’s work, keeps the team on track, and manages references and resources. Because of limited supplies, you may not be allowed to work alone unless you have purchased your own Magic Box. 1 Objectives You have designed circuits with logic formulae and pen-and-paper sketches, laid them out in a simulator, and dynamically tested their functionality. In this lab, you will transfer your circuit designs into physical systems that compute. More specifically, you will assemble circuits using The Magic Box, including your breadboard, switches, wires, LEDs, and several chips. This is the next step as we learn how real computers are designed and built. 2 Prelab Preparation Re-read section 1 through 4 of The Magic Box User’s Manual, available from the website or at http: //www.ugrad.cs.ubc.ca/ cs121/current/Handouts/MagicBoxManual-v2.pdf. In your reading, be sure you know how to: 1. Apply power to The Magic Box. Along with connecting the 5-volt power cable from your power supply to your breadboard, use an additional red wire to connect the two power columns on opposite sides of the breadboard and an additional black wire to connect the two ground columns. Although The Magic Box is designed with safety in mind, it is still important practice for you to turn the power off when you assemble and disassemble your circuits. See figure 3 for an example of the proper power setup. 2. Connect a switch to an LED (i.e., connect the contact point for a switch to the contact point for an LED). IMPORTANT NOTE: Only the flat 4-pin bus wires should be used to connect to the switches and LED contacts on The Magic Box. See figure 2 for an example of this setup. 3. Insert an integrated circuit (IC) into the breadboard, apply power to it, and use one or more if its gates in a circuit. This lab proceeds in two stages. First, you experiment with an unknown IC. Next, you implement and test your priority chain circuit. 1

Upload: others

Post on 16-Oct-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Objectives - University of British Columbia

CPSC 121: Models of ComputationLab #3: Implementing circuits using the Magic Box

Collaboration: For this lab, you may work in teams of two. Each team member must be able to answerquestions based on or use skills developed in the lab (including working The Magic Box). Only one pre-labsubmission and in-lab report is needed per team. We suggest that team members adopt and regularly change“driver” and “navigator” roles, where the “driver” works with the lab tools while the “navigator” checks thedriver’s work, keeps the team on track, and manages references and resources. Because of limited supplies,you may not be allowed to work alone unless you have purchased your own Magic Box.

1 Objectives

You have designed circuits with logic formulae and pen-and-paper sketches, laid them out in a simulator,and dynamically tested their functionality. In this lab, you will transfer your circuit designs into physicalsystems that compute. More specifically, you will assemble circuits using The Magic Box, including yourbreadboard, switches, wires, LEDs, and several chips. This is the next step as we learn how real computersare designed and built.

2 Prelab Preparation

Re-read section 1 through 4 of The Magic Box User’s Manual, available from the website or at http://www.ugrad.cs.ubc.ca/∼cs121/current/Handouts/MagicBoxManual-v2.pdf. In your reading, be sure youknow how to:

1. Apply power to The Magic Box. Along with connecting the 5-volt power cable from your powersupply to your breadboard, use an additional red wire to connect the two power columns on oppositesides of the breadboard and an additional black wire to connect the two ground columns. AlthoughThe Magic Box is designed with safety in mind, it is still important practice for you to turn the poweroff when you assemble and disassemble your circuits. See figure 3 for an example of the proper powersetup.

2. Connect a switch to an LED (i.e., connect the contact point for a switch to the contact point for anLED). IMPORTANT NOTE: Only the flat 4-pin bus wires should be used to connect to the switchesand LED contacts on The Magic Box. See figure 2 for an example of this setup.

3. Insert an integrated circuit (IC) into the breadboard, apply power to it, and use one or more if its gatesin a circuit.

This lab proceeds in two stages. First, you experiment with an unknown IC. Next, you implement andtest your priority chain circuit.

1

Page 2: 1 Objectives - University of British Columbia

Before lab, you should also answer the questions below marked as Prelab. You may also want to readthe debugging guide to The Magic Box. If you run into trouble with your circuits, the debugging guide canhelp!

You may be concerned about harming yourself or the equipment. Of course, you should exercise safetyprecautions—keep the power off while wiring circuits, don’t touch bare wires, don’t touch the heatsink, don’t connect power directly to ground, use common sense—but The Magic Box has been designedto minimize these safety hazards. Also, if you don’t drop/throw/stomp on parts of The Magic Box and you’recareful about how you insert the ICs and about correctly wiring up ground and power to the ICs, theMagic Box components should be fine. In other words, experiment! Approach these problems (or your ownideas) with a sense of play.

3 Experimenting with an Unknown Chip

Before proceeding: Ensure that you have a complete lab kit: a Magic Box, a breadboard, a 9 volt poweradapter, a wiring kit (including some 4-wire jumper cables), a 5 volt power wire, and a box of chips.

Your TA will provide you with two ICs. The label on both ICs is covered, but the notch is visible (soyou know the orientation to place them on your breadboard!). One of these chips is a hex inverter, a chipwith six inverters. The other is one of: a quad 2-input NAND gate, a quad 2-input AND gate, a quad 2-inputOR gate, or a quad 2-input XOR gate. Your job is:

1. First, figure out which one is the hex inverter.

2. Second, figure out which of the four possible “quad” chips you have.

Here are some hints to get you started. See figure 3 in the Appendix of this lab for a picture of a what asafe initial setup of the The Magic Box should look like. Reread Section 4, Appendix A, and Section 2.1’sentry on the “probe” in The Magic Box User’s Manual.

The readings tell you how to wire up IC chips and how to probe circuits. You’ll find that the hex inverterand the various quad chips all have the same number of pins, the same shaped “package”, and the same pinsthat connect to power and ground. Thus, without the labels you can’t tell the difference between the chips bysight, but you can safely wire them to power and ground. The probe allows you to check whether a contactpoint is high, low, or unconnected.

Once the chip is powered, is there some way to drive one or more pins with a signal and probe one ormore other pins to determine which chip is the inverter? Once you know which is the quad, is there anothercombination of switches and probes you could use to determine which quad you have?

Once you have a plan, wire up and use one circuit to test which chip is your inverter. Then, wire up anduse a second on your quad chip to determine which of the quads it is. You should have room to keep bothcircuits essentially intact on your breadboard at the same time; so, keep them both to demonstrate to yourTA as you finish. Remember to use appropriate power and ground connections, or you may damagethe ICs!

TODO: Report on your experiment by answering the following questions. The first few are prelabexercises:

2

Page 3: 1 Objectives - University of British Columbia

1. Prelab: How will you determine which of the two chips is the hex inverter? Sketch your wiring planand the steps you’ll take.

2. Prelab: Once you’ve done that, how will you determine which one of the “quad” chips you have?Again, sketch your wiring plan and your steps.

3. Prelab: If you could reveal the chips’ labels, how would you verify your answers? (We’re lookingfor a straightforward answer here; no tricks.)

3

Page 4: 1 Objectives - University of British Columbia

4. According to your circuit, which chip is the inverter? (Which colour indicated the inverter?)

5. According to your circuit, which “quad” chip did you have?

6. Why didn’t we include the quad 2-input NOR gate as one of the possible “quad” chips? (It is possibleto answer this prelab.)

7. Show your working circuit to your TA.

4 Implementing Your Circuit in The Magic Box

Next, implement your priority chain circuit from Lab 2. Start with your pen-and-paper circuit from Lab 2or a printout of the TKGate version. Then, wire up your priority chain and test its functionality.

TODO: Report on your experiment by answering the following questions. The first few are prelabexercises:

1. Prelab: Which ICs will you need to get the gates in your diagram?

2. Prelab: Mark up your Lab 2 diagram to indicate which pins of which ICs correspond to the gateinputs and outputs in the diagram. By organising this beforehand, you will have an easier time wiringyour circuit, as well as redoing it later should you try to replicate it.

Some standard conventions are to wire the power with a red wire (pin 14 in the upper-right), toground with a black wire (pin 7 in the lower-left), as well as to use green and yellow wires for inputsand outputs.

Appendix A below illustrates one way to do this for an unrelated circuit.

4

Page 5: 1 Objectives - University of British Columbia

3. Test every possible combination of inputs to your circuit. Fill in the truth table below to indicate howyour circuit worked:

a b x y0 00 11 01 1

4. Did your circuit work as you anticipated? If not, debug it. If you’re never able to make it work,hypothesize as to why not.

5. Show your working circuit to your TA.

5 Challenge Problems

Problem 1: Wire together your priority chain circuit with at least two other groups’ chains, and demon-strate to your TA that they function as anticipated. To wire your circuits together safely:

1. Turn off the power to the Magic Boxes.

2. Connect the ground signals of your two breadboards together, and connect both breadboards’ groundsto the Magic Box grounds. This gives the two circuits a common reference for voltages.

Do not connect the power signals together. Each Magic Box has its own voltage regulator that converts9 volts from the AC power adapter to 5 volts for the breadboards. While the output voltages are veryclose to 5 volts, there will be slight differences between the boards. If you connect the outputs oftwo voltage regulators together, they can fight over what the right output voltage is. This violates thespecification for how the regulators are supposed to be used and could lead to a malfunction.

3. Connect the y output of one board to the a input of the next board.

4. Turn on the Magic Boxes.

5. Test the chain.

Problem 2: Design, implement, and demonstrate to your TA a “three-input majority gate”: a circuit withthree inputs for which the output is true exactly when the majority of its inputs are true.

5

Page 6: 1 Objectives - University of British Columbia

AppendicesA Wiring Diagram for a Sample Circuit

Imagine we were designing a circuit to compute (A ∨ B) ∧ (C ∨D), we might use a 74LS32 IC (two ORgates, using pins 1–3 and 11–13) and a 74LS08 IC (one AND gate, using pins 1–3). To prepare for wiringthe physical circuit, we could mark up a diagram as in Figure 1.

A3

onoff

onoff

onoff

13D

C

3B

2

2

12

1

74LS08

1

74LS32

74LS32onoff

11

(A OR B) AND (C OR D)

Figure 1: A circuit computing (A ∨ B) ∧ (C ∨D), labeled with IC part and pin numbers. This is not thecircuit for this lab. It is just an example of how to label/wire a circuit.

As we wire the circuit, our first wired gate might look like Figure 2. In the figure, we have wired up theOR gate for C ∨ D according to Figure 1: a 74LS32 IC wired (1) to power with a red wire (pin 14 in theupper-right, using the colour reserved for power); (2) to ground with a black wire (pin 7 in the lower-left,using the colour reserved for ground); and (3) to the inputs and output with green and yellow wires (pins11–13 in the upper right, using arbitrary colours that distinguish inputs from outputs).

This demonstrates the kind of careful circuit building methods that can make your work with hardwaresmoother.

6

Page 7: 1 Objectives - University of British Columbia

Figure 2: A breadboard with the C ∨D gate of (A ∨B) ∧ (C ∨D) wired according to Figure 1.

Figure 3: Standard setup of magic box and breadboard supplying power to an IC.

7