• Tidak ada hasil yang ditemukan

ENDS (end subcircuit)

Dalam dokumen PSpice Reference Manual (Halaman 84-87)

Purpose

The .SUBCKT command/statement starts the subcircuit definition by specifying its name, the number and order of its terminals, and the names and default parameters that control its behavior. Subcircuits are instantiated using X (Subcircuit instantiation) devices. The .ENDS command marks the end of a subcircuit definition.

General form

.SUBCKT <name> [node]*

+ [OPTIONAL: < <interface node> = <default value> >*]

+ [PARAMS: < <name> = <value> >* ] + [TEXT: < <name> = <text value> >* ] ...

.ENDS

Examples

.SUBCKT OPAMP 1 2 101 102 17 ...

.ENDS

.SUBCKT FILTER INPUT, OUTPUT PARAMS: CENTER=100kHz, + BANDWIDTH=10kHz

...

.ENDS

.SUBCKT PLD IN1 IN2 IN3 OUT1 + PARAMS: MNTYMXDLY=0 IO_LEVEL=0 + TEXT: JEDEC_FILE="PROG.JED"

...

.ENDS

.SUBCKT 74LS00 A B Y

+ OPTIONAL: DPWR=$G_DPWR DGND=$G_DGND + PARAMS: MNTYMXDLY=0 IO_LEVEL=0 ...

.ENDS

Arguments and options

<name>

The name is used by an X (Subcircuit Instantiation) device to reference the subcircuit.

[node]*

An optional list of nodes (pins). This is optional because it is possible to specify a subcircuit that has no interface nodes.

OPTIONAL:

Allows specification of one or more optional nodes (pins) in the subcircuit definition.

Commands .ENDS (end subcircuit) Comments

The subcircuit definition ends with a .ENDS command. All of the netlist between .SUBCKT

and .ENDS is included in the definition. Whenever the subcircuit is used by an X (Subcircuit Instantiation) device, all of the netlist in the definition replaces the X device.

There must be the same number of nodes in the subcircuit calling statements as in its definition. When the subcircuit is called, the actual nodes (the ones in the calling statement) replace the argument nodes (the ones in the defining statement).

Do not use 0 (zero) in this node list. Zero is reserved for the global ground node.

The optional nodes are stated as pairs consisting of an interface node and its default value. If an optional node is not specified in an X device, its default value is used inside the subcircuit;

otherwise, the value specified in the definition is used.

This feature is particularly useful when specifying power supply nodes, because the same nodes are normally used in every device. This makes the subcircuits easier to use because the same two nodes do not have to be specified in each subcircuit statement. This method is used in the libraries provided with the Digital Simulation feature.

Subcircuits can be nested. That is, an X device can appear between .SUBCKT and .ENDS commands. However, subcircuit definitions cannot be nested. That is, a .SUBCKT statement cannot appear in the statements between a .SUBCKT and a .ENDS.

Subcircuit definitions should contain only device instantiations (statements without a leading period) and possibly these statements:

.IC (initial bias point condition)

.NODESET (set approximate node voltage for bias point)

.MODEL (model definition)

.PARAM (parameter)

.FUNC (function)

Models, parameters, and functions defined within a subcircuit definition are available only within the subcircuit definition in which they appear. Also, if a .MODEL, .PARAM, or a .FUNC statement appears in the main circuit, it is available in the main circuit and all subcircuits.

Node, device, and model names are local to the subcircuit in which they are defined. It is acceptable to use a name in a subcircuit which has already been used in the main circuit. When the subcircuit is expanded, all its names are prefixed using the subcircuit instance name: for example, Q13 becomes X3.Q13 and node 5 becomes X3.5 after expansion. After expansion all names are unique. The only exception is the use of global node names (refer to your PSpice user’s guide) that are not expanded.

Usage examples

One

In the example of the 74LS00 subcircuit, the following subcircuit reference uses the default power supply nodes $G_DPWR and $G_DGND:

X1 IN1 IN2 OUT 74LS00

Two

To specify your own power supply nodes MYPOWER and MYGROUND, use the following subcircuit instantiation:

X2 IN1 IN2 OUT MYPOWER MYGROUND 74LS00

Three

If wanted, one optional node in the subcircuit instantiation can be provided. In the following subcircuit instantiation, the default $G_DGND would be used:

X3 IN1 IN2 OUT MYPOWER 74LS00

Four

However, to specify values beyond the first optional node, all nodes previous to that node must be specified. For example, to specify your own ground node, the default power node before it must be explicitly stated:

X4 IN1 IN2 OUT $G_DPWR MYGROUND 74LS00

The keyword PARAMS: passes values into subcircuits as arguments and uses them in expressions inside the subcircuit. The keyword TEXT: passes text values into subcircuits as arguments and uses them as expressions inside the subcircuit. Once defined, a text parameter can be used in the following places:

• To specify a JEDEC file name on a PLD device.

• To specify an Intel Hex file name to program a ROM device or initialize a RAM device.

• To specify a stimulus file name or signal name on a FSTIM device.

• To specify a text parameter to a (lower level) subcircuit.

• As part of a text expression used in one of the above.

The text parameters and expressions are currently only used in Digital Simulation.

Dalam dokumen PSpice Reference Manual (Halaman 84-87)

Dokumen terkait