# Debugging subcircuits

As you test larger circuits, you will likely find bugs. To nail down what's going wrong, exploring what's going on in the subcircuits while running the overall circuit can help. To enter the subcircuit's state, you can use any of three different techniques.

The most straightforward is probably to view the simulation hierarchy by by clicking on the Simulate tab, or by selecting menu | Project |→| View Simulation Tree |. This switches the explorer pane so that it shows the hierarchy of subcircuits being simulated.

Double-clicking an element in this hierarchy will display what is happening inside that subcircuit.

The second way you can enter a subcircuit is to bring up its popup menu by right-clic or Ctrl+Click it, and then choosing the option | View "circuit_name" |.

And the third way is to first ensure the Poke Tool () is selected and then click the subcircuit you want to enter; a magnifying glass will appear over the subcircuit's center, and double-clicking the magnifying glass will enter the subcircuit's state.

In any case, once you enter the subcircuit, you'll see that the pins' values in the subcircuit match the values being sent through them from the containing circuit.

While in the subcircuit, you are allowed to alter the circuit. If the changes affect any of the subcircuit's outputs, they are propagated into the containing circuit. One exception: The subcircuit inputs are determined based on the values coming into the circuit from the supercircuit, so it doesn't make sense to toggle those values. If you attempt to poke a subcircuit's input, a dialog will pop up asking, The pin is tied to the supercircuit state. Create a new circuit state? Clicking No will cancel the toggle request, while clicking Yes will create a copy of the viewed state, divorced from the outer circuit, with the input pin toggled.

Once you have completed viewing and/or editing, you can return to the parent circuit either by double-clicking the parent circuit in the explorer pane, or via the menu | Simulate |→ | Go Out To State "circuit_name" |.

Next: Logisim libraries.