• APPENDIX A: EXAMPLE DATA DECKS

    1. Circuit 1

      The following deck determines the dc operating point and small-signal transfer function of a simple differential pair. In addition, the ac small-signal response is computed over the frequency range 1Hz to 100MEGHz.

      SIMPLE DIFFERENTIAL PAIR
      VCC 7 0 12
      VEE 8 0 -12
      VIN 1 0 AC 1
      RS1 1 2 1K
      RS2 6 0 1K
      Q1 3 2 4 MOD1
      Q2 5 6 4 MOD1
      RC1 7 3 10K
      RC2 7 5 10K
      RE 4 8 10K
       .MODEL MOD1 NPN BF=50 VAF=50 IS=1.E-12 RB=100 CJC=.5PF TF=.6NS
       .TF V(5) VIN
       .AC DEC 10 1 100MEG
       .PLOT AC VM(5) VP(5)
       .PRINT AC VM(5) VP(5)
       .END
      

    2. Circuit 2

      The following deck computes the output characteristics of a MOSFET device over the range 0-10V for VDS and 0-5V for VGS.

      MOS OUTPUT CHARACTERISTICS
      .OPTIONS NODE NOPAGE
      VDS 3 0
      VGS 2 0
      M1 1 2 0 0 MOD1 L=4U W=6U AD=10P AS=10P
      .MODEL MOD1 NMOS VTO=-2 NSUB=1.0E15 UO=550
      * VIDS MEASURES ID, WE COULD HAVE USED VDS, BUT ID WOULD BE NEGATIVE
      VIDS 3 1
      .DC VDS 0 10 .5 VGS 0 5 1
      .PRINT DC I(VIDS) V(2)
      .PLOT DC I(VIDS)
      .END
      

    3. Circuit 3

      The following deck determines the dc transfer curve and the transient pulse response of a simple RTL inverter. The input is a pulse from 0 to 5 Volts with delay, rise, and fall times of 2ns and a pulse width of 30ns. The transient interval is 0 to 100ns, with printing to be done every nanosecond.

       SIMPLE RTL INVERTER
       VCC 4 0 5
       VIN 1 0 PULSE 0 5 2NS 2NS 2NS 30NS
       RB 1 2 10K
       Q1 3 2 0 Q1
       RC 3 4 1K
       .PLOT DC V(3)
       .PLOT TRAN V(3) (0,5)
       .PRINT TRAN V(3)
       .MODEL Q1 NPN BF 20 RB 100 TF .1NS CJC 2PF
       .DC VIN 0 5 0.1
       .TRAN 1NS 100NS
       .END
      
    4. Circuit 4

      The following deck simulates a four-bit binary adder, using several subcircuits to describe various pieces of the overall circuit.

       ADDER - 4 BIT ALL-NAND-GATE BINARY ADDER
       *** SUBCIRCUIT DEFINITIONS
       .SUBCKT NAND 1 2 3 4
       *   NODES:  INPUT(2), OUTPUT, VCC
       Q1 9 5 1 QMOD
       D1CLAMP 0 1 DMOD
       Q2 9 5 2 QMOD
       D2CLAMP 0 2 DMOD
       RB 4 5 4K
       R1 4 6 1.6K
       Q3 6 9 8 QMOD
       R2 8 0 1K
       RC 4 7 130
       Q4 7 6 10 QMOD
       DVBEDROP 10 3 DMOD
       Q5 3 8 0 QMOD
       .ENDS NAND
       .SUBCKT ONEBIT 1 2 3 4 5 6
       *   NODES:  INPUT(2), CARRY-IN, OUTPUT, CARRY-OUT, VCC
       X1 1 2 7 6 NAND
       X2 1 7 8 6 NAND
       X3 2 7 9 6 NAND
       X4 8 9 10 6 NAND
       X5 3 10 11 6 NAND
       X6 3 11 12 6 NAND
       X7 10 11 13 6 NAND
       X8 12 13 4 6 NAND
       X9 11 7 5 6 NAND
       .ENDS ONEBIT
       .SUBCKT TWOBIT 1 2 3 4 5 6 7 8 9
       *   NODES:  INPUT - BIT0(2) / BIT1(2), OUTPUT - BIT0 / BIT1,
       *   CARRY-IN, CARRY-OUT, VCC
       X1 1 2 7 5 10 9 ONEBIT
       X2 3 4 10 6 8 9 ONEBIT
       .ENDS TWOBIT
       .SUBCKT FOURBIT 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
       *   NODES:  INPUT - BIT0(2) / BIT1(2) / BIT2(2) / BIT3(2),
       *   OUTPUT - BIT0 / BIT1 / BIT2 / BIT3, CARRY-IN, CARRY-OUT, VCC
       X1 1 2 3 4 9 10 13 16 15 TWOBIT
       X2 5 6 7 8 11 12 16 14 15 TWOBIT
       .ENDS FOURBIT
       *** DEFINE NOMINAL CIRCUIT
       .MODEL DMOD D
       .MODEL QMOD NPN(BF=75 RB=100 CJE=1PF CJC=3PF)
       VCC 99 0 DC 5V
       VIN1A 1 0 PULSE(0 3 0 10NS 10NS   10NS   50NS)
       VIN1B 2 0 PULSE(0 3 0 10NS 10NS   20NS  100NS)
       VIN2A 3 0 PULSE(0 3 0 10NS 10NS   40NS  200NS)
       VIN2B 4 0 PULSE(0 3 0 10NS 10NS   80NS  400NS)
       VIN3A 5 0 PULSE(0 3 0 10NS 10NS  160NS  800NS)
       VIN3B 6 0 PULSE(0 3 0 10NS 10NS  320NS 1600NS)
       VIN4A 7 0 PULSE(0 3 0 10NS 10NS  640NS 3200NS)
       VIN4B 8 0 PULSE(0 3 0 10NS 10NS 1280NS 6400NS)
       X1 1 2 3 4 5 6 7 8 9 10 11 12 0 13 99 FOURBIT
       RBIT0 9 0 1K
       RBIT1 10 0 1K
       RBIT2 11 0 1K
       RBIT3 12 0 1K
       RCOUT 13 0 1K
       .PLOT TRAN V(1) V(2) V(3) V(4) V(5) V(6) V(7) V(8)
       .PLOT TRAN V(9) V(10) V(11) V(12) V(13)
       .PRINT TRAN V(1) V(2) V(3) V(4) V(5) V(6) V(7) V(8)
       .PRINT TRAN V(9) V(10) V(11) V(12) V(13)
       *** (FOR THOSE WITH MONEY (AND MEMORY) TO BURN)
       .TRAN 1NS 6400NS
       .OPTIONS ACCT LIST NODE LIMPTS=6401
       .END
      

    5. Circuit 5

      The following deck simulates a transmission-line inverter. Two transmission-line elements are required since two propagation modes are excited. In the case of a coaxial line, the first line (T1) models the inner conductor with respect to the shield, and the second line (T2) models the shield with respect to the outside world.

       TRANSMISSION-LINE INVERTER
       V1 1 0 PULSE(0 1 0 0.1N)
       R1 1 2 50
       X1 2 0 0 4 TLINE
       R2 4 0 50
       .SUBCKT TLINE 1 2 3 4
       T1 1 2 3 4 Z0=50 TD=1.5NS
       T2 2 0 4 0 Z0=100 TD=1NS
       .ENDS TLINE
       .TRAN 0.1NS 20NS
       .PLOT TRAN V(2) V(4)
       .END
      
  • APPENDIX B: NONLINEAR DEPENDENT SOURCES

    SPICE allows circuits to contain dependent sources characterized by any of the four equations

    i=f(v)  v=f(v)  i=f(i)  v=f(i)
    
    where the functions must be polynomials, and the arguments may be multidimensional. The polynomial functions are specified by a set of coefficients p0, p1, ..., pn. Both the number of dimensions and the number of coefficients are arbitrary. The meaning of the coefficients depends upon the dimension of the polynomial, as shown in the following examples:

    Suppose that the function is one-dimensional (that is, a function of one argument). Then the function value fv is determined by the following expression in fa (the function argument):

    fv = p0 + (p1*fa) + (p2*fa**2) + (p3*fa**3) + (p4*fa**4) + (p5*fa**5) + ...
    
    Suppose now that the function is two-dimensional, with arguments fa and fb. Then the function value fv is determined by the following expression:
    fv = p0 + (p1*fa) +  (p2*fb)  +  (p3*fa**2)  +  (p4*fa*fb)  +  (p5*fb**2)
     +  (p6*fa**3)  +   (p7*fa**2*fb)   +   (p8*fa*fb**2)   +  (p9*fb**3) + ...
    
    Consider now the case of a three-dimensional polynomial function with arguments fa, fb, and fc. Then the function value fv is determined by the following expression:
    fv = p0  +  (p1*fa)  +  (p2*fb)  +  (p3*fc)  +  (p4*fa**2)  + (p5*fa*fb)
     + (p6*fa*fc) + (p7*fb**2) + (p8*fb*fc)  +  (p9*fc**2)  + (p10*fa**3)
     + (p11*fa**2*fb) + (p12*fa**2*fc) + (p13*fa*fb**2) + (p14*fa*fb*fc)
     +  (p15*fa*fc**2)  +  (p16*fb**3)  +  (p17*fb**2*fc)   + (p18*fb*fc**2)
     + (p19*fc**3) + (p20*fa**4) + ...
    
    Note: if the polynomial is one-dimensional and exactly one coefficient is specified, then SPICE assumes it to be p1 (and p0 = 0.0), in order to facilitate the input of linear controlled sources.

    For all four of the dependent sources described below, the initial condition parameter is described as optional. If not specified, SPICE assumes 0 the initial condition for dependent sources is an initial 'guess' for the value of the controlling variable. The program uses this initial condition to obtain the dc operating point of the circuit. After convergence has been obtained, the program continues iterating to obtain the exact value for the controlling variable. Hence, to reduce the computational effort for the dc operating point (or if the polynomial specifies a strong nonlinearity), a value fairly close to the actual controlling variable should be specified for the initial condition.

    1. Voltage-Controlled Current Sources

      General form:
      GXXXXXXX N+ N- <POLY(ND)> NC1+ NC1- ... P0 <P1 ...> <IClt;IC=...>
      Examples:
      G1 1 0 5 3 0 0.1M
      GR 17 3 17 3 0 1M 1.5M IC=2V
      GMLT 23 17 POLY(2) 3 5 1 2 0 1M 17M 3.5U IC=2.5, 1.3
      
      N+ and N- are the positive and negative nodes, respectively. Current flow is from the positive node, through the source, to the negative node. POLY(ND) only has to be specified if the source is multi-dimensional (one-dimensional is the default). If specified, ND is the number of dimensions, which must be positive. NC1+, NC1-, ... Are the positive and negative controlling nodes, respectively. One pair of nodes must be specified for each dimension. P0, P1, P2, ..., Pn are the polynomial coefficients. The (optional) initial condition is the initial guess at the value(s) of the controlling voltage(s). If not specified, 0.0 is assumed. The polynomial specifies the source current as a function of the controlling voltage(s). The second example above describes a current source with value
      I = 1E-3*V(17,3) + 1.5E-3*V(17,3)**2
      
      note that since the source nodes are the same as the controlling nodes, this source actually models a nonlinear resistor.

    2. Voltage-Controlled Voltage Sources

      General form:
      EXXXXXXX N+ N- <POLY(ND)> NC1+ NC1- ... P0 <P1 ...> <IClt;IC=...>
      Examples:
      E1 3 4 21 17 10.5 2.1 1.75
      EX 17 0 POLY(3) 13 0 15 0 17 0 0 1 1 1 IC=1.5,2.0,17.35
      
      N+ and N- are the positive and negative nodes, respectively. POLY(ND) only has to be specified if the source is multidimensional (one-dimensional is the default). If specified, ND is the number of dimensions, which must be positive. NC1+, NC1-, ... are the positive and negative controlling nodes, respectively. One pair of nodes must be specified for each dimension. P0, P1, P2, ..., Pn are the polynomial coefficients. The (optional) initial condition is the initial guess at the value(s) of the controlling voltage(s). If not specified, 0.0 is assumed. The polynomial specifies the source voltage as a function of the controlling voltage(s). The second example above describes a voltage source with value
      V = V(13,0) + V(15,0) + V(17,0)
      (in other words, an ideal voltage summer).
      

    3. Current-Controlled Current Sources

      General form:
      FXXXXXXX N+ N- <POLY(ND)> VN1 <VN2 ...> P0 <P1 ...> <IClt;IC=...>
      Examples:
      F1 12 10 VCC 1MA 1.3M
      FXFER 13 20 VSENS 0 1
      
      N+ and N- are the positive and negative nodes, respectively. Current flow is from the positive node, through the source, to the negative node. POLY(ND) only has to be specified if the source is multi-dimensional (one-dimensional is the default). If specified, ND is the number of dimensions, which must be positive. VN1, VN2, ... are the names of voltage sources through which the controlling current flows; one name must be specified for each dimension. The direction of positive controlling current flow is from the positive node, through the source, to the negative node of each voltage source. P0, P1, P2, ..., Pn are the polynomial coefficients. The (optional) initial condition is the initial guess at the value(s) of the controlling current(s) (in Amps). If not specified, 0.0 is assumed. The polynomial specifies the source current as a function of the controlling current(s). The first example above describes a current source with value I = 1E-3 + 1.3E-3*I(VCC)

    4. Current-Controlled Voltage Sources

      General form:
      HXXXXXXX N+ N- <POLY(ND)> VN1 <VN2 ...> P0 <P1 ...> <IClt;IC=...>
      Examples:
      HXY 13 20 POLY(2) VIN1 VIN2 0 0 0 0 1 IC=0.5 1.3
      HR 4 17 VX 0 0 1
      
      N+ and N- are the positive and negative nodes, respectively. POLY(ND) only has to be specified if the source is multidimensional (one-dimensional is the default). If specified, ND is the number of dimensions, which must be positive. VN1, VN2, ... are the names of voltage sources through which the controlling current flows; one name must be specified for each dimension. The direction of positive controlling current flow is from the positive node, through the source, to the negative node of each voltage source. P0, P1, P2, ..., Pn are the polynomial coefficients. The (optional) initial condition is the initial guess at the value(s) of the controlling current(s) (in Amps). If not specified, 0.0 is assumed. The polynomial specifies the source voltage as a function of the controlling current(s). The first example above describes a voltage source with value V = I(VIN1)*I(VIN2)