Home CPSC 305

Switch Exercise

 

Objective

To gain experience building circuits which use switches to compute logical expressions.


 

Introduction to Logisim

Logisim is a logic simulator which can be used to build logic circuits. We'll use it to build and experiment with digital logic.

To use Logisim, we connect various components together and observe how they operate.

You can find transistors, power, and ground tools under the "Wiring" menu on the left hand side of Logisim:

To place a component on a circuit, click on it, and then click on the area on the right. The placed transistor looks like this:

The transistor has three pins which are places wires can be connected. On the left is the "collector" which is usually connected to a power source. On the right is the "emitter" which is the output signal of the transistor. On top is the "base" which controls if the transistor is on or off.

Components such as transistors have various attributes that can be changed on the left. Transistors can be switched from p-type to n-type, and rotated.

Logisim also has components which will allow us to interact with our design. In the "Input/Output" section, you will find Buttons and LEDs:

LEDS have one input pin which indicates if the LED will be lit or not. Buttons have one output pin which indicate if the button is currently pressed or not.

Logisim is somewhat more abstract than building a real circuit. For a switch to produce a current, it would have to be connected to a voltage source. Logisim buttons have a hidden voltage all ready to go. Likewise, the LEDS would have to be grounded to light.

With all of the power/ground wires a large circuit would need it would get quite messy!

In order to connect two components, they must be wired together. Use the Wiring Tool under the "Base" menu:

Click on the starting pin, and then click on the ending pin. This will draw a wire between them. You will often want to make several smaller wire segments to rout wires around other components.


 

Cat Selector Circuit

In Code, Petzold designs a circuit to decide if a cat is acceptable according to a logical expression. This is used to illustrate the link between logic and circuits. His circuit is given below:

Below is a Logisim version of the same circuit:

This circuit uses transistors controlled by pins instead of switches which would need to be opened and closed manually. A pin is an input or output of a circuit. Whether the cat is male or female is external to the circuit, so is controlled by a pin.

When the value of (M & N & (W | T)) | (F & N & ~W) | B is true, then the LED will light up. Notice that the ~W is handled with a P-type transistor which closes when a 0 is coming in. The other transistors are all N-type which close on a 1.

You can download this circuit here.


 

Exercise: Rock, Paper, Scissors

For this lab, you'll build a circuit along similar lines which will compute who wins a game of rock, paper, scissors. In this game, two players throw hand signals representing rock, paper, and scissors. The moves are compared and a winner is decided according to the following rules:

Your circuit should determine a winner based on the moves of each player.

You should build the circuit out of the following components:


 

Testing

Be sure to test that your circuit lights the appropriate LEDs for each possibility. You should test the case where the players throw the same moves (resulting in a tie), and when no move is thrown.

You don't need to test the case where multiple throws are selected (e.g. if the pins for player 1 throwing rock and paper are both on).


 

Submitting

When your circuit works, please submit the .circ file under the lab assignment on Canvas

Copyright © 2024 Ian Finlayson | Licensed under a Creative Commons BY-NC-SA 4.0 License.