Using subcircuits

Now suppose we want to build a 2x4 multiplexer out of 1x2 multiplexers. We first create a new circuit called 2x4 MUX, and change our view to it.

To add 1x2 multiplexers, we click the 1x2 MUX circuit in the explorer pane, and we can now add them into the circuit. (Don't double-click the 1x2 MUX circuit - that would change the circuit we're editing.) We can now click in a few 1x2 multiplexers.

Notice that it draws the 1x2 multiplexers as boxes with pins.

The pins on the subcircuit box correspond to the input and output pins in the 1x2 MUX circuit. The 1x2 MUX circuit includes two east-facing pins; its box has two pins on its west side corresponding to these, following the same top-down ordering. The 1x2 MUX circuit includes one north-facing pin; this appears on the south side of the box. (If there were several north-facing pins, they would correspond to the same left-right order.) And the 1x2 MUX includes one west-facing pin, which appears on the box's east side.

Note: There's nothing wrong with editing a circuit while it's being used as a subcircuit of another circuit. In fact, this is quite common. Be aware, though, that any changes to the pins (adding, deleting, or moving) will rearrange them also in the containing circuit. Thus, if you change any pins in a circuit, you will also need to edit any circuits using that circuit.

Incidentally, every pin to a circuit must be either an input or an output. Many manufactured chips have pins that behave as an input in some situations and as an output in others; you cannot construct such chips within Logisim.

To complete our 2x4 multiplexer, we can add some inputs and outputs and wire everything up.

Now that we have the 2x4 multiplexer defined, we can now use it in other circuits. Logisim has no limits on how deep you can nest circuits - though it will prevent you from having circuits nested within themselves!

Logisim will maintain different state information for all subcircuits appearing in a circuit. Thus, if you have a flip-flop appearing in a subcircuit that occurs several times, the flip-flops will all have different values.

Next: Libraries.