Using Subcircuits

Reusable cells are the key to saving labor in any CAD system, and this also applies to circuit simulation. To create a reusable circuit, it must be constructed as a subcircuit. Use parameters to expand the utility of a subcircuit. SPICE includes the basic subcircuit but does not provide for the consistent naming of nodes. Star-Hspice provides a simple method for the naming of the subcircuit nodes and elements: simply prefix the node or element with the subcircuit call name.

Figure 3-3: Subcircuit Representation

The following Star-Hspice input creates an instance named X1 of the INV cell macro, which consists of two MOSFETs, MN and MP:

X1 IN OUT VD_LOCAL VS_LOCAL inv W = 20
.MACRO INV IN OUT VDD VSS W = 10 L = 1 DJUNC = 0
	MP OUT IN VDD VDD PCH W = W L = L DTEMP = DJUNC
	MN OUT IN VSS VSS NCH W = 'W/2' L = L DTEMP = DJUNC
.EOM

NOTE: To access the name of the MOSFET inside of the subcircuit INV called by X1, the names are X1.MP and X1.MN. So to print the current through the MOSFETs:
.PRINT I (X1.MP)

Hierarchical Parameters

The most basic subcircuit parameter is the M or multiply parameter. This is actually a keyword common to all elements including subcircuits, except for voltage sources. The multiply parameter multiplies the internal component values to give the effect of making parallel copies of the element or subcircuit. To simulate the effect of 32 output buffers switching simultaneously, you only need to place one subcircuit:

X1 in out buffer M = 32

Multiply works hierarchically. A subcircuit within a subcircuit is multiplied by the product of both levels.

Figure 3-4: Hierarchical Parameters Simplify Flip-flop Initialization
Example
	X1 D Q Qbar CL CLBAR dlatch flip = 0
	macro dlatch
	+ D Q Qbar CL CLBAR flip = vcc
	.nodeset v(din) = flip
	xinv1 din qbar inv
	xinv2 Qbar Q inv
	m1 q CLBAR din nch w = 5 l = 1
	m2 D CL din nch w = 5 l = 1
	.eom
Figure 3-5: D Latch with Nodeset

There is no limit to the size or complexity of subcircuits; they may contain subcircuit references and any model or element statement. To specify subcircuit nodes in .PRINT or .PLOT statements, give the full subcircuit path and node name.

Undefined Subcircuit Search

When a subcircuit call is in a data file that does not contain the subcircuit description, Star-Hspice automatically searches the:

1. Present directory for the file

2. Directories specified in any .OPTION SEARCH = "directory_path_name"
statement

3. Directory where the Discrete Device Library is located.

Star-Hspice searches for the model reference name file with an . inc suffix. For example, if an undefined subcircuit such as "X 1 1 2 INV" is included in the data file, Star-Hspice searches the system directories for the file called inv.inc and when found, places it in the calling data file.

Star-Hspice Manual - Release 2001.2 - June 2001