Creating and Using Subcircuits.

example

In addition to the known gate types, you can create new ones by declaring them as circuits. For example, suppose you want to create a two-input nand with one active-low input and one active-high input. You could do this as follows.

xnand: circuit  
  inputs A,B
  outputs C
  not A,ABAR
  nand (ABAR,B),C
  endcircuit  

You may now use xnand as a gate in any other circuit in the same file. When you have several circuits in the same file, the first is treated as the main circuit and all others are treated as subcircuits. To use the xnand subcircuit, include a statement similar to the following in some other circuit.

gtest: xnand (Q,R),S

You may use a subcircuit any number of times.