• SUBCIRCUITS

    A subcircuit that consists of SPICE elements can be defined and referenced in a fashion similar to device models. The subcircuit is defined in the input deck by a grouping of element cards; the program then automatically inserts the group of elements wherever the subcircuit is referenced. There is no limit on the size or complexity of subcircuits, and subcircuits may contain other subcircuits. An example of subcircuit usage is given in Appendix A.

    1. .SUBCKT Card

      General form:
      	 .SUBCKT subnam N1 
      Examples:
      	.SUBCKT OPAMP 1 2 3 4
      
      A circuit definition is begun with a .SUBCKT card. SUBNAM is the subcircuit name, and N1, N2, ... are the external nodes, which cannot be zero. The group of element cards which immediately follow the .SUBCKT card define the subcircuit. The last card in a subcircuit definition is the .ENDS card (see below). Control cards may not appear within a subcircuit definition; however, subcircuit definitions may contain anything else, including other subcircuit definitions, device models, and subcircuit calls (see below). Note that any device models or subcircuit definitions included as part of a subcircuit definition are strictly local (i.e., such models and definitions are not known outside the subcircuit definition). Also, any element nodes not included on the .SUBCKT card are strictly local, with the exception of 0 (ground) which is always global.

    2. .ENDS Card

      General form:
      	.ENDS 
      Examples:
      	 .ENDS OPAMP
      
      This card must be the last one for any subcircuit definition. The subcircuit name, if included, indicates which subcircuit definition is being terminated; if omitted, all subcircuits being defined are terminated. The name is needed only when nested subcircuit definitions are being made.

    3. Subcircuit Calls

      General form:
      	XYYYYYYY N1  SUBNAM
      Examples:
      	X1 2 4 17 3 1 MULTI
      
      Subcircuits are used in SPICE by specifying pseudo-elements beginning with the letter X, followed by the circuit nodes to be used in expanding the subcircuit.

  • CONTROL CARDS

    1. .TEMP Card

      General form:
      	 .TEMP T1 >
      Examples:
      	 .TEMP -55.0 25.0 125.0
      
      This card specifies the temperatures at which the circuit is to be simulated. T1, T2, ... Are the different temperatures, in degrees C. Temperatures less than -223.0 deg C are ignored. Model data are specified at TNOM degrees (see the .OPTIONS card for TNOM); if the .TEMP card is omitted, the simulation will also be performed at a temperature equal to TNOM.

    2. .WIDTH Card

      General form:
      	.WIDTH IN=COLNUM OUT=COLNUM
      Examples:
      	.WIDTH IN=72 OUT=133
      
      COLNUM is the last column read from each line of input; the setting takes effect with the next line read. The default value for COLNUM is 80. The out parameter specifies the output print width. Permissible values for the output print width are 80 and 133.

    3. .OPTIONS Card

      General form:
      	.OPTIONS OPT1 OPT2 ... (or OPT=OPTVAL ...)
      Examples:
      	.OPTIONS ACCT LIST NODE
      
      This card allows the user to reset program control and user options for specific simulation purposes. Any combination of the following options may be included, in any order. 'x' (below) represents some positive number.
      option		effect
      ACCT		causes accounting and run time statistics to be printed
      LIST		causes the summary listing of the input data to be printed
      NOMOD		suppresses the printout of the model parameters.
      NOPAGE		suppresses page ejects
      NODE		causes the printing of the node table.
      OPTS		causes the option values to be printed.
      GMIN=x		resets the value of GMIN, the minimum conductance
      		allowed by the program.  The default value is 1.0E-12.
      RELTOL=x	resets the relative error tolerance of the program.  The
      		default value is 0.001 (0.1 percent).
      ABSTOL=x	resets the absolute current error tolerance of the
      		program.  The default value is 1 picoamp.
      VNTOL=x		resets the absolute voltage error tolerance of the
      		program.  The default value is 1 microvolt.
      TRTOL=x		resets the transient error tolerance.  The default value
      		is 7.0.  This parameter is an estimate of the factor by
      		which SPICE overestimates the actual truncation error.
      CHGTOL=x	resets the charge tolerance of the program.  The default
      		value is 1.0E-14.
      PIVTOL=x	resets the absolute minimum value for a matrix entry
      		to be accepted as a pivot.  The default value is 1.0E-13.
      PIVREL=x	resets the relative ratio between the largest column entry
      		and an acceptable pivot value. The default value is 1.0E-3.
      		In the numerical pivoting algorithm the allowed minimum
      		pivot value is determined by
      		EPSREL=AMAX1(PIVREL*MAXVAL,PIVTOL)
      		where MAXVAL is the maximum element in the column where
      		a pivot is sought (partial pivoting).
      NUMDGT=x	resets the number of significant digits printed for
      		output variable values.  X must satisfy the relation
      		0 < x < 8.  The default value is 4.  Note:  this option is
      		independent of the error tolerance used by SPICE (i.e., if
      		the values of options RELTOL, ABSTOL, etc., are not changed
      		then one may be printing numerical 'noise' for NUMDGT > 4.
      TNOM=x		resets the nominal temperature.  The default value is
      		27 deg C (300 deg K).
      ITL1=x		resets the dc iteration limit.  The default is 100.
      ITL2=x		resets the dc transfer curve iteration limit.  The default is 50.
      ITL3=x		resets the lower transient analysis iteration limit.the default value is 4.
      ITL4=x		resets the transient analysis timepoint iteration limit.the default is 10.
      ITL5=x		resets the transient analysis total iteration limit.
      		the default is 5000.  Set ITL5=0 to omit this test.
      CPTIME=x	the maximum cpu-time in seconds allowed for this job.
      LIMTIM=x	resets the amount of cpu time reserved by SPICE for
      		generating plots should a cpu time-limit cause job
      		termination.  The default value is 2 (seconds).
      LIMPTS=x	resets the total number of points that can be printed
      		or plotted in a dc, ac, or transient analysis.  The default value is 201.
      LVLCOD=x	if x is 2 (two), then machine code for the matrix
      		solution will be generated.  Otherwise, no machine code is
      		generated.  The default value is 2.  Applies only to CDC computers.
      LVLTIM=x	if x is 1 (one), the iteration timestep control is used.
      		if x is 2 (two), the truncation-error timestep is used.
      		The default value is 2.  If method=Gear and MAXORD>2 then
      		LVLTIM is set to 2 by SPICE.
      METHOD=name	sets the numerical integration method used by SPICE.
      		Possible names are Gear or trapezoidal.  The default is
      		trapezoidal.
      MAXORD=x	sets the maximum order for the integration method if
      		Gear's variable-order method is used.  X must be between
      		2 and 6.  The default value is 2.
      DEFL=x		resets the value for MOS channel length; the default
      		is 100.0 micrometer.
      DEFW=x	 	resets the value for MOS channel width; the default
      		is 100.0 micrometer.
      DEFAD=x		resets the value for MOS drain diffusion area; the
      		default is 0.0.
      DEFAS=x	 	resets the value for MOS source diffusion area; the
      		default is 0.0.
      

    4. .OP Card

      General form
      	.OP
      
      The inclusion of this card in an input deck will force SPICE to determine the dc operating point of the circuit with inductors shorted and capacitors opened. Note: a dc analysis is automatically performed prior to a transient analysis to determine the transient initial conditions, and prior to an ac small-signal analysis to determine the linearized, small-signal models for nonlinear devices.

      SPICE performs a dc operating point analysis if no other analyses are requested.

    5. .DC Card

      General form:
      	.DC SRCNAM VSTART VSTOP VINCR [SRC2 START2 STOP2 INCR2]
      Examples:
      	.DC VIN 0.25 5.0 0.25
      	.DC VDS 0 10 .5 VGS 0 5 1
      	.DC VCE 0 10 .25 IB 0 10U 1U
      
      This card defines the dc transfer curve source and sweep limits. SRCNAM is the name of an independent voltage or current source. VSTART, VSTOP, and VINCR are the starting, final, and incrementing values respectively. The first example will cause the value of the voltage source VIN to be swept from 0.25 Volts to 5.0 Volts in increments of 0.25 Volts. A second source (SRC2) may optionally be specified with associated sweep parameters. In this case, the first source will be swept over its range for each value of the second source. This option can be useful for obtaining semiconductor device output characteristics. See the second example data deck in that section of the guide.

    6. .NODESET Card

      General form:
      	.NODESET V(NODNUM)=VAL V(NODNUM)=VAL ...
      Examples:
      	.NODESET V(12)=4.5 V(4)=2.23
      
      This card helps the program find the dc or initial transient solution by making a preliminary pass with the specified nodes held to the given voltages. The restriction is then released and the iteration continues to the true solution. The .NODESET card may be necessary for convergence on bistable or astable circuits. In general, this card should not be necessary.

    7. .IC Card

      General form:
      	.IC V(NODNUM)=VAL V(NODNUM)=VAL ...
      Examples:
      	.IC V(11)=5 V(4)=-5 V(2)=2.2
      
      This card is for setting transient initial conditions. It has two different interpretations, depending on whether the UIC parameter is specified on the .TRAN card. Also, one should not confuse this card with the .NODESET card. The .NODESET card is only to help dc convergence, and does not affect final bias solution (except for multi-stable circuits). The two interpretations of this card are as follows:
      • When the UIC parameter is specified on the .TRAN card, then the node voltages specified on the .IC card are used to compute the capacitor, diode, BJT, JFET, and MOSFET initial conditions. This is equivalent to specifying the IC=... parameter on each device card, but is much more convenient. The IC=... parameter can still be specified and will take precedence over the .IC values. Since no dc bias (initial transient) solution is computed before the transient analysis, one should take care to specify all dc source voltages on the .IC card if they are to be used to compute device initial conditions.
      • When the UIC parameter is not specified on the .TRAN card, the dc bias (initial transient) solution will be computed before the transient analysis. In this case, the node voltages specified on the .IC card will be forced to the desired initial values during the bias solution. During transient analysis, the constraint on these node voltages is removed.

    8. .TF Card

      General form:
      	.TF OUTVAR INSRC
      Examples:
      	.TF V(5,3) VIN
      	.TF I(VLOAD) VIN
      
      This card defines the small-signal output and input for the dc small- signal analysis. OUTVAR is the small-signal output variable and INSRC is the small-signal input source. If this card is included, SPICE will compute the dc small-signal value of the transfer function (output/input), input resistance, and output resistance. For the first example, SPICE would compute the ratio of V(5,3) to VIN, the small-signal input resistance at VIN, and the small-signal output resistance measured across nodes 5 and 3.

    9. .SENS Card

      General form:
      	.SENS OV1 <OV2 ... >
      Examples:
      	.SENS V(9) V(4,3) V(17) I(VCC)
      
      If a .SENS card is included in the input deck, SPICE will determine the dc small-signal sensitivities of each specified output variable with respect to every circuit parameter. Note: for large circuits, large amounts of output can be generated.

    10. .AC Card

      General form:
      	.AC DEC ND FSTART FSTOP
      	.AC OCT NO FSTART FSTOP
      	.AC LIN NP FSTART FSTOP
      Examples:
      	.AC DEC 10 1 10K
      	.AC DEC 10 1K 100MEG
      	.AC LIN 100 1 100HZ
      
      DEC stands for decade variation, and ND is the number of points per decade. OCT stands for octave variation, and NO is the number of points per octave. LIN stands for linear variation, and NP is the number of points. FSTART is the starting frequency, and FSTOP is the final frequency. If this card is included in the deck, SPICE will perform an ac analysis of the circuit over the specified frequency range. Note that in order for this analysis to be meaningful, at least one independent source must have been specified with an ac value.

    11. .DISTO Card

      General form:
      	.DISTO RLOAD <INTER <SKW2 <REFPWR <SPW2>>>>
      Examples:
      	.DISTO RL 2 0.95 1.0E-3 0.75
      
      This card controls whether SPICE will compute the distortion characteristic of the circuit in a small-signal mode as a part of the ac small-signal sinusoidal steady-state analysis. The analysis is performed assuming that one or two signal frequencies are imposed at the input; let the two frequencies be f1 (the nominal analysis frequency) and f2 (=SKW2*f1). The program then computes the following distortion measures:
      • HD2 - the magnitude of the frequency component 2*f1 assuming that f2 is not present.
      • HD3 - the magnitude of the frequency component 3*f1 assuming that f2 is not present.
      • SIM2 - the magnitude of the frequency component f1 + f2.
      • DIM2 - the magnitude of the frequency component f1 - f2.
      • DIM3 - the magnitude of the frequency component 2*f1 - f2.
      RLOAD is the name of the output load resistor into which all distortion power products are to be computed. INTER is the interval at which the summary printout of the contributions of all nonlinear devices to the total distortion is to be printed. If omitted or set to zero, no summary printout will be made. REFPWR is the reference power level used in computing the distortion products; if omitted, a value of 1 mW (that is, dbm) is used. SKW2 is the ratio of f2 to f1. If omitted, a value of 0.9 is used (i.e., f2 = 0.9*f1). SPW2 is the amplitude of f2. If omitted, a value of 1.0 is assumed.

      The distortion measures HD2, HD3, SIM2, DIM2, and DIM3 may also be be printed and/or plotted (see the description of the .PRINT and .PLOT cards).

    12. .NOISE Card

      General form:
      	.NOISE OUTV INSRC NUMS
      Examples:
      	.NOISE V(5) VIN 10
      
      This card controls the noise analysis of the circuit. The noise analysis is performed in conjunction with the ac analysis (see .AC card). OUTV is an output voltage which defines the summing point. INSRC is the name of the independent voltage or current source which is the noise input reference. NUMS is the summary interval. SPICE will compute the equivalent output noise at the specified output as well as the equivalent input noise at the specified input. In addition, the contributions of every noise generator in the circuit will be printed at every NUMS frequency points (the summary interval). If NUMS is zero, no summary printout will be made.

      The output noise and the equivalent input noise may also be printed and/or plotted (see the description of the .PRINT and .PLOT cards).

    13. .TRAN Card

      General form:
      	.TRAN TSTEP TSTOP <TSTART <TMAX>> <UIC>
      Examples:
      	.TRAN 1NS 100NS
      	.TRAN 1NS 1000NS 500NS
      	.TRAN 10NS 1US UIC
      
      TSTEP is the printing or plotting increment for line-printer output. For use with the post-processor, TSTEP is the suggested computing increment. TSTOP is the final time, and TSTART is the initial time. If TSTART is omitted, it is assumed to be zero. The transient analysis always begins at time zero. In the interval , the circuit is analyzed (to reach a steady state), but no outputs are stored. In the interval , the circuit is analyzed and outputs are stored. TMAX is the maximum stepsize that SPICE will use (for default, the program chooses either TSTEP or (TSTOP-TSTART)/50.0, whichever is smaller. TMAX is useful when one wishes to guarantee a computing interval which is smaller than the printer increment, TSTEP.

      UIC (use initial conditions) is an optional keyword which indicates that the user does not want SPICE to solve for the quiescent operating point before beginning the transient analysis. If this keyword is specified, SPICE uses the values specified using IC=... on the various elements as the initial transient condition and proceeds with the analysis. If the .IC card has been specified, then the node voltages on the .IC card are used to compute the intitial conditions for the devices. Look at the description on the .IC card for its interpretation when UIC is not specified.

    14. .FOUR Card

      General form:
      	.FOUR FREQ OV1 <OV2 OV3 ...>
      Examples:
      	.FOUR 100K  V(5)
      
      This card controls whether SPICE performs a Fourier analysis as a part of the transient analysis. FREQ is the fundamental frequency, and OV1, ..., are the output variables for which the analysis is desired. The Fourier analysis is performed over the interval , where TSTOP is the final time specified for the transient analysis, and period is one period of the fundamental frequency. The dc component and the first nine components are determined. For maximum accuracy, TMAX (see the .TRAN card) should be set to period/100.0 (or less for very high-Q circuits).

    15. .PRINT Cards

      General form:
      	.PRINT PRTYPE OV1 <OV2 ... OV8>
      Examples:
      	.PRINT TRAN V(4) I(VIN)
      	.PRINT AC VM(4,2) VR(7) VP(8,3)
      	.PRINT DC V(2) I(VSRC) V(23,17)
      	.PRINT NOISE INOISE
      	.PRINT DISTO HD3 SIM2(DB)
      
      This card defines the contents of a tabular listing of one to eight output variables. PRTYPE is the type of the analysis (DC, AC, TRAN, NOISE, or DISTO) for which the specified outputs are desired. The form for voltage or current output variables is as follows:

      V(N1<,N2>)

      specifies the voltage difference between nodes N1 and N2. If N2 (and the preceding comma) is omitted, ground (0) is assumed. For the ac analysis, five additional outputs can be accessed by replacing the letter V by:

      		VR	real part
      		VI	imaginary part
      		VM	magnitude
      		VP	phase
      		VDB	20*log10(magnitude)
      

      I(VXXXXXXX)

      specifies the current flowing in the independent voltage source named VXXXXXXX. Positive current flows from the positive node, through the source, to the negative node. For the ac analysis, the corresponding replacements for the letter I may be made in the same way as described for voltage outputs. Output variables for the noise and distortion analyses have a different general form from that of the other analyses, i.e.

      		OV<(X)>
      
      where OV is any of ONOISE (output noise), INOISE (equivalent input noise), D2, HD3, SIM2, DIM2, or DIM3 (see description of distortion analysis), and X may be any of:
      	R	real part
      	I	imaginary part
      	M	magnitude (default if nothing specified)
      	P	phase
      	DB	20*log10(magnitude)
      
      thus, SIM2 (or SIM2(M)) describes the magnitude of the SIM2 distortion measure, while HD2(R) describes the real part of the HD2 distortion measure.

      There is no limit on the number of .PRINT cards for each type of analysis.

    16. .PLOT Cards

      General form:
      	.PLOT PLTYPE OV1 <(PLO1,PHI1)> <OV2 <(PLO2,PHI2)> ... OV8>
      Examples:
      	.PLOT DC V(4) V(5) V(1)
      	.PLOT TRAN V(17,5) (2,5) I(VIN) V(17) (1,9)
      	.PLOT AC VM(5) VM(31,24) VDB(5) VP(5)
      	.PLOT DISTO HD2 HD3(R) SIM2
      	.PLOT TRAN V(5,3) V(4) (0,5) V(7) (0,10)
      
      This card defines the contents of one plot of from one to eight output variables. PLTYPE is the type of analysis (DC, AC, TRAN, NOISE, or DISTO) for which the specified outputs are desired. The syntax for the OVI is identical to that for the .PRINT card, described above.

      The optional plot limits (PLO,PHI) may be specified after any of the output variables. All output variables to the left of a pair of plot limits (PLO,PHI) will be plotted using the same lower and upper plot bounds. If plot limits are not specified, SPICE will automatically determine the minimum and maximum values of all output variables being plotted and scale the plot to fit. More than one scale will be used if the output variable values warrant (i.e., mixing output variables with values which are orders-of-magnitude different still gives readable plots).

      The overlap of two or more traces on any plot is indicated by the letter X. When more than one output variable appears on the same plot, the first variable specified will be printed as well as plotted. If a printout of all variables is desired, then a companion .PRINT card should be included.

      There is no limit on the number of .PLOT cards specified for each type of analysis.

    Click here for continuation