Subcircuit Calls/Instantiation

The format for a statement defining a subcircuit call or instantiation has been elaborated in and is repeated here for convenience:

Xname  n1  n2 ...  sname
Such a device statement has a device name that begins with the one-character keyword, "X", followed by a set of node names, and the name of a subcircuit at the end.

In order for SIMPLIS to be able to find the referenced subcircuit, the subcircuit instantiation and the subcircuit named "sname" must be defined in the same general circuit. In addition, the number of nodes listed in the subcircuit instantiation must match the number of external nodes listed in the subcircuit definition.

During the reading of the input file, SIMPLIS first combs through the main circuit to register the node names that have already been employed in the main circuit. In example 5.3, the nodes 0, 1, 2, and 3 have been utilized in the main circuit. These node names form a list of existing nodes so that new node names introduced later during subcircuit instantiation will not duplicate these existing node names. Similarly, a list of device names already employed in the main circuit is created. For this example, this list includes V1, R1, R2, and R3. Sometimes devices such as the one represented by X1 are referred to as "pseudo devices" because there is no actual device element corresponding to the keyword "X."

After reading the main circuit, SIMPLIS reads the circuit instantiation statements in the main circuit and starts instantiating the subcircuits. Each subcircuit instantiation can be summarized in a four-step procedure:

  1. Perform a one-to-one mapping of the names of external nodes to the names of corresponding nodes in the subcircuit instantiation statement.
  2. Map the name of each local node to a new node name, different from any existing node name. This new node name is then added to the list of existing node names.
  3. Map the name of each device defined in the subcircuit to a new device name having the same element keyword, but an individual name different from any existing one. This new device name is then added to the list of existing device names.
  4. Carry out subcircuit instantiation for each subcircuit instantiation statement in the current subcircuit.
In example 5.3, node 1 of subcircuit "SUB1" would be mapped to node 2 when the subcircuit instantiation for the pseudo-device X1 is carried out. Then local nodes 2 and 3 in "SUB1" are each mapped to a new node name. The device names R1 and R2 are each mapped to a new name for a linear resistor and device names C1 and C2 are each mapped to a new name for a linear capacitor. The actual new node names or device names introduced in the mapping are not important to the user as they are only used internally by SIMPLIS. For the purpose of illustration here, let us assume that nodes 2 and 3 in "SUB1" are mapped to nodes 7 and 9, respectively.

When SIMPLIS carries out the subcircuit instantiation for the pseudo-devices XA in the subcircuit definition of "SUB1", the four-step procedure is repeated:

  1. Node 101 of subcircuit "SUB2" is mapped to node 2 in subcircuit "SUB1". Since node 2 in "SUB1" has already been mapped to node 7, node 101 of "SUB2" is mapped to node 7.
  2. Node 102, the only local node of subcircuit "SUB2" is mapped to a new node name that is not in the list of existing nodes. Then this new node name is added to the list of existing nodes.
  3. Devices R101 and C101 are mapped to appropriate new device names that are different from existing device names. Then these device names are added to the list of existing device names.
  4. Since there is no subcircuit defined in the subcircuit "SUB2", the instantiation of XA has been completed.
When SIMPLIS carries out the subcircuit instantiation for the pseudo-devices XB in the subcircuit definition of "SUB1", the four-step procedure is repeated:
  1. Node 101 of subcircuit "SUB2" is mapped to node 3 in subcircuit "SUB1". Since node 3 in "SUB1" has already been mapped to node 9, node 101 of "SUB2" is mapped to node 9.
  2. Node 102 is mapped to a new node name that is not in the list of existing nodes. Then this new node name is added to the list of existing nodes.
  3. Devices R101 and C101 are mapped to appropriate new device names that are different from existing device names. Then these device names are added to the list of existing device names.
  4. Since there is no subcircuit defined in the subcircuit 'SUB2", the instantiation of XB has been completed.
The four-step procedure is repeated until all subcircuits have been instantiated. Notice that the definition of a subcircuit only provides a model subcircuit with a reference name. The subcircuit does not come into being until the appropriate subcircuit instantiation.