logisim - middleburycs101/lectures/logisim.pdf · meet logisim poke tool input tool output tool and...

18
Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate

Upload: others

Post on 14-Oct-2019

28 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Meet Logisim

poke tool

input tool output tool

AND gateNOT gate

OR gate

Page 2: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Add a gateClick on the AND gate

Click on the workspace to place it

Set the number of inputs to 2

Page 3: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Connect the gate to some pinsAdd two input pins behind the gate

Add an output pin in front of the gate

Draw the wires in (click and drag -- if you look closely, you will see little dots where wires can connect)

Page 4: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Use the Poke toolUse the poke tool to change the values on the input pins

Notice that the value changed to a 1 and the wire lit up

Page 5: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Playing with ANDHere are the four possible combinations of our two inputs.

Page 6: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Adding two 1 bit numbers

11

10+

101

+011

+000

+

AB

C S+ inputs

sumcarry out

We would like to build a circuit that can add two 1-bit numbers together

Page 7: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Build a truth table

11

10+

101

+011

+000

+

AB

C S+

A B C S0 0 0 00 1 0 11 0 0 11 1 1 0

We can express this as a truth table

Page 8: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Convert to equations

11

10+

101

+011

+000

+

C = ABS = AB + AB

A B C S0 0 0 00 1 0 11 0 0 11 1 1 0

Now, we can extract the minterms and write two equations, one for each output

Page 9: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Equation to gates

C = ABS = AB + AB

1 AND gate2 AND gates, 1 OR gate and 2 NOT gates

... or 1 XORXOR stands for exclusive OR. It is true when exactly one of the inputs is true.

We will need two circuits to implement our two equations

Page 10: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Build the circuit in Logisim

click here

new circuit will show up here

Make sure that you are now in the circuit -- it should have a magnifying glass on it

Double click to change circuits

Create a circuit called half_adder click the green plus sign

Page 11: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Put together the circuit

To change the orientation and add labels to the pins, use the attribute panel

The XOR gate is hiding in here

Page 12: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Build the circuit in LogisimMake sure to test your circuit

Page 13: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

What if the numbers have more than 1 bit?

0101

010+

0100

001+

0001

001+

0000

000+

1101

100+

1100

011+

1001

011+

1000

010+

0111

100+

0110

011+

0011

011+

0010

010+

1111

110+

1110

101+

1011

101+

1010

100+

If we add another bit to each, we have four times the number of possible equations

Page 14: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Looking at the second column

1111

110+

111

11+

1

just looking at the second column

addition is associative

11

10+

111

+

... and we already know how to add two 1 bit numbers together

The second column is not the same -- it has to add three numbers instead of two

Page 15: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Making a full adder

The Carry_out is just the OR of the two carries from the half adders because it will never be the case that both half adders produce one (check it yourself)

HA

HA

OR

A B

carry in

sumcarry out

c1

c2

s1

s2

Page 16: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Make a full adder in LogisimCreate a new circuit and call it full_adder

Add two half_adders to the circuit just click the half_adder once like it was a gate and then click in your workspace

Add an OR gate

Hook it all together

Page 17: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Putting it all together

HAFAFAFA

A3 B3 A2 B2 A1 B1 A0 B0

S0S1S2S3carry_out

With a half adder an a couple of full adders, we can make something called ripple-carry adder

called that because any carries generated in the first column can ripple up to the last one

Page 18: logisim - Middleburycs101/lectures/logisim.pdf · Meet Logisim poke tool input tool output tool AND gate NOT gate OR gate. Add a gate Click on the AND gate Click on the workspace

Build a 4-bit adder• Double click on the main circuit

• Recreate the 4-bit adder from the previous page using three full adders and one half adder

• Add the 8 input pins and five output pins and label them AO, A1, A2, A3, B0, B1, B2, B3, S0, S1, S2, S3, carry_out • [note - the wires may not connect in exactly the same

place as shown in the diagram]

• Test, test, test