Documentation‎ > ‎

Subcircuit Tag

Sub-circuits are groupings of components that form a logical block- such as a combiner, a balun, or a detailed transistor model. Sub-circuits follow the general Mason file rules, although only the model, component, port, and variable elements are read. They may be complete Mason files but the other elements will be ignored.

The local nodes will be mapped to the ports in the order that the ports are listed in the sub-circuit.

    <model alias = “wilkinson”>
<mason file = “networks/wilkinson.xml”>
<wilkinson node_list=”1 2 3” />

The impedances of the sub-circuit port definitions are ignored: these impedances are “outside” of the circuit. While models are not shared between sub-circuits and the main circuit, variable definitions do flow from the Mason file to the sub-circuits.

Sub-circuits are actually not the preferred method of nesting designs. Mason allows for automatically generating new primitives based on a circuit composed of other primitives (see Flag Tag: make_primitive), which provides a similar functionality with less confusion. Tracking variables and calculations can be tricky over sub-circuits (for the user, not Mason), where local copies of variables take precedence over the calling circuit's. For example, the sub-circuit may have a local copy of the microstrip line's permittivity, which will overwrite the calling circuit's value, which may or may not be desired.

Subcircuits in TinyCAD 

Important note: As over version 4.5, you can output a PCB Layout with a subcircuit

Notes for Layout:
The top level TinyCAD (or Mason XML file) needs to have a primitive component attached to each port, for example a small (10-mils long) microstrip line.  Currently the routine is not smart enough to drill into the subciruit to figure out which part the terminal should attach to. 

Subcircuits can be used through TinyCAD using the mason_subcircuit library, but care must be taken.  Currently, files are only loosely linked- the following steps describe how the link can be made and how it works.  An example can be found in the TinyCAD examples folder, specifically "subcircuits.dsn" which is loosely linked to "single_wilkinson.dsn".
  1. Start with a Circuit Mason design that runs in TinyCAD
    1. For this example, "single_wilkinson.dsn"
    2. When "single_wilkinson.dsn" is run, it creates a file called "single_wilkinson.dsn.msn.xml"
    3. "single_wilkinson.dsn.msn.xml" is the file which "subcircuit.dsn" will link
    4. "single_wilkinson.dsn.msn.xml" is only updated when "single_wilkinson.dsn" is run; this file is not updated when "subcircuit.dsn" is run

  2. Variables and calculations are hierarchical
    1. Variables and calculations flow down into subcircuits
    2. Local variables and calculations take precedent over variables passed down into the design
    3. Care must be taken not to confuse variable scope when running the subcircuit file and the calling file independently
      1. variables must be defined in the subcircuit to make it run
      2. variables defined in the calling circuit will be overwritten by the subcircuit variables
  3. You can optimize using subcircuits, the subcircuit files will be updates individually (but not the TinyCAD DSN files)