# Subcircuits

You can use subcircuits to implement custom "black box" devices.

Create and test your device, and then use labeled nodes (under "Outputs and Labels") to mark and label all the inputs/outputs. Here is an example circuit (a bridge rectifier).

Then, select File->Create Subcircuit, then rearrange the pins the way you want them, enter a model name, and click OK. This will load the subcircuit model. Be sure to save this circuit (the subcircuit implementation), because it can't be edited later otherwise.

Now you can create a circuit using the subcircuit model. Click with the right mouse and select the "Active Building Blocks" menu, and the "Add Subcircuit Instance" item. Then click and drag to create an instance. Edit the instance to select which model you want (by default it will use the one you just created).

Here is an example using the rectifier. When you save/load this circuit, it will also save/load the subcircuit model so you can use it in other circuits.

You can also use subcircuits to rearrange pins on the built-in chips. Here is an example with the 555. And here is that subcircuit model being used in a circuit.

If you select part of a circuit before using File->Create Subcircuit, then only the selected elements will be considered part of the subcircuit.

If you want to use labeled nodes in the subcircuit definition but don't want them to be one of the inputs/outputs, then check the "Internal Node" checkbox in those labeled nodes' edit menus.

## Pins

The arrangement and direction of the labeled nodes in your circuit will determine the initial arrangement of the pins when creating the symbol symbol. During symbol creation, you can change the initial pin layout by dragging the pins with the mouse.

The name of the labeled nodes can affect the look of the pin in the following ways:

- Naming a node "CLK" will add a "clock marker" to the symbol at that pin and hide the text.
- Prefixing the name with "CLK:" (as in "CLK:C1") will draw a "clock marker" on that pin in the symbol.
- Prefixing the name with "INV:" (as in "INV:EN") will draw an "inverter circle" on that pin in the symbol, denoting logical inversion.
- Prefixing the name with "/" (as in "/EN") will draw a horizontal line above the text in the symbol, also denoting logical negation.
- For all prefixes, the prefix itself will not be shown in the symbol, only the text after the prefix.
- All prefixes are purely cosmetic and do not affect the actual signal.