Manuals >Reference >ADS Simulator
Print version of this Book (PDF file)
prevnext

Subcircuit Definitions

General Form:

define subcircuitName ( node1 ... nodeN )
   [ parameters name1 = [ value1 ] ... name n = [ value n ] ]
                      .
                      .
                      .
             elementStatements
                      .
                      .
                      .
end [ subcircuitName ]

Examples:

 define DoubleTuner (top bottom left right)
parameters vel=0.95 r=1.0 l1=.25 l2=.25
    tline:tuner1 top bottom left left len=l1 vel=vel r=r
    tline:tuner2 top bottom right right len=l2 vel=2*vel r=r
end DoubleTuner
DoubleTuner:InputTuner t1 b2 3 4 l1=0.5

A subcircuit is a named collection of instances connected in a particular way that can be instantiated as a group any number of times by subcircuit calls. The subcircuit call is in effect and form, an instance statement. Subcircuit definitions are simply circuit macros that can be expanded anywhere in the circuit any number of times. When an instance in the input file refers to a subcircuit definition, the instances specified within the subcircuit are inserted into the circuit. Subcircuits may be nested. Thus a subcircuit definition may contain other subcircuits. However, a subcircuit definition cannot contain another subcircuit definition. All the definitions must occur at the top level.

An instance statement that instantiates a subcircuit definition is referred to as a subcircuit call. The node names (or numbers) specified in the subcircuit call are substituted, in order, for the node names given in the subcircuit definition. All instances that refer to a subcircuit definition must have the same number of nodes as are specified in the subcircuit definition and in the same order. Node names inside the subcircuit definition are strictly local unless they are a global ground defined with a ground statement or global nodes defined with a globalnode statement. A subcircuit definition with no nodes must still include the parentheses ( ).

Parameter specification in subcircuit definitions is optional. Any parameters that are specified are referred to by name followed by an equals sign and then an optional default value. If, when making a subcircuit call in your input file, you do not specify a particular parameter, then this default value is used in that instance. Subcircuit parameters can be used in expressions within the subcircuit just as any other variable.

Subcircuits are a flexible and powerful way of developing and maintaining hierarchical circuits. Parameters can be used to modify one instance of a subcircuit from another. Names within a subcircuit can be assigned without worrying about conflicting with the same name in another subcircuit definition. The full name for a node or instance include its path name in addition to its instance name. For example, if the above subcircuit is included in subckt2 which is itself included in subckt1, then the full path name of the length of the first transmission line is subckt1.subckt2.tuner1.len.

Only enough of the path name has to be specified to unambiguously identify the parameter. For example, an analysis inside subckt1 can reference the length by subckt2.tuner1.len since the name search starts from the current level in the hierarchy. If a reference to a name cannot be resolved in the local level of hierarchy, then the parent is searched for the name, and so on until the top level is searched. In this way, a sibling can either inherit its parent's attributes or define its own.


prevnext