The main circuit refers to the circuit definition which begins with the title statement, which is the first line in the input file, and ends with the .END statement, which is the last significant line in the input file. Any number of subcircuits can be defined within the main circuit. The subcircuits can also be nested within other subcircuits. As many as 20 levels of nesting are allowed. A typical group of statements defining a subcircuit definition duplicates the following pattern of statements:
Obviously, the "Start Subcircuit Statement" and the "End Subcircuit Statement" must be the first and the last statements, respectively, in the definition of a subcircuit. Between these start and end statements, the comment statements, device statements, model statements, subcircuit definitions, and control statements can appear in any order or sequence without any effect on the reading of the input file.
In this topic:
When a subcircuit named "AAA" is defined in a general circuit named "BBB", then the subcircuit "AAA" is considered the child of the general circuit "BBB" and the general circuit "BBB" is considered the parent of the subcircuit "AAA". Each subcircuit can have only one parent and each general circuit can have zero, one, or more children. The main circuit is the ancestor of all subcircuits defined in the entire input file and it does not have a parent.
In this section, a brief description of the .SUBCKT statement is given. The format of the .SUBCKT statement is defined as:
.SUBCKT sname n1 n2 n3 ...where
|.SUBCKT||is the seven-character keyword ".SUBCKT" signifying the start of the subcircuit definition|
|sname||is a legal subcircuit name as explained in Model Names and Subcircuit Names. A subcircuit name must be unique within a general circuit. If a name is used as a subcircuit name in a general circuit, it cannot be used as a model name in the same general circuit and vice-versa|
|n1||is the node name of the first external node of the subcircuit|
|n2||is the node name of the second external node of the subcircuit|
|n3||is the node name of the third external node of the subcircuit, and so on|
In this section, a brief description of the .ENDS statement is given. The format of the .ENDS statement is defined as:
|.ENDS||is the five-character keyword ".ENDS" signifying the end of one or more subcircuits|
|sname||is the name of a subcircuit whose definition has not been terminated. The subcircuit name may be omitted to form the special case of the non-specific .ENDS statement.|
Subcircuits are normally terminated with a .ENDS statement in the .ENDS [sname] , or specific form. If a subcircuit has not been terminated with this form of .ENDS statement, the non-specific form of the .ENDS statement:
.ENDSwill terminate the subcircuit. All subcircuits whose definition have not been terminated individually will be terminated in a group by the .ENDS statement without a subcircuit name. For example, in the statements shown in the example below, the three subcircuits SUB1, SUB2, and SUB3 are all terminated by the .ENDS statement. In this example, because of the use of the non-specific form of the .ENDS statement, subcircuit SUB1 is the parent of subcircuit SUB2, which is itself the parent of subcircuit SUB3. The placement of .ENDS statements determines the parent-child relationships of the subcircuits. The line immediately following the .ENDS statement is considered to be part of the definition of the parent of subcircuit SUB1.
.SUBCKT SUB113 R1 1 2 1K C1 2 3 1U IC=1 X1 2 3 SUB2 .SUBCKT SUB2 101 103 R2 101 102 1K C2 102 103 1U IC=1 X2 102 103 SUB3 .SUBCKT SUB3 201 203 R3 201 202 1K C3 202 203 1U IC=1 .ENDSIf sname is given in an .ENDS statement, then sname must be the name of the subcircuit currently defined or the name of a subcircuit which is an ancestor of the subcircuit currently defined. In this case, the definition of the current subcircuit, its parent, its grandparent, ..., and the subcircuit whose name matches sname are all terminated at this .ENDS statement. For the statements in the example below, the statement .ENDS SUB2 terminates the definition of subcircuits SUB2 and SUB3 but not the definition of subcircuit SUB1. The line immediately following the ".ENDS SUB2" statement is considered part of the definition of subcircuit SUB1, which is the parent of subcircuit SUB2.
.SUBCKT SUB113 R1 1 2 1K C1 2 3 1U IC=1 X1 2 3 SUB2 .SUBCKT SUB2 101 103 R2 101 102 1K C2 102 103 1U IC=1 X2 102 103 SUB3 .SUBCKT SUB3 201 203 R3 201 202 1K C3 202 203 1U IC=1 .ENDS SUB2Notice that there is a unique correspondence between each .SUBCKT statement and the start of a subcircuit while each .ENDS statement may be "shared" by several subcircuits. The recommended practice, however, is to terminate each subcircuit with a unique .ENDS statement having a matching subcircuit name instead of using the implied termination. This will make reading the input file easier and will make the subcircuit definitions less susceptible to error.
|◄ Overview||Scope of Definition ▶|