Spice3f5

Voltage and current sources

Independent Sources

General form

VXXXXXXX N+ N- <<DC> DC/TRAN VALUE> <AC <ACMAG <ACPHASE>>>
+       <DISTOF1 <F1MAG <F1PHASE>>> <DISTOF2 <F2MAG <F2PHASE>>>
IYYYYYYY N+ N- <<DC> DC/TRAN VALUE> <AC <ACMAG <ACPHASE>>>
+       <DISTOF1 <F1MAG <F1PHASE>>> <DISTOF2 <F2MAG <F2PHASE>>>

Examples

VCC 10 0 DC 6
VIN 13 2 0.001 AC 1 SIN(0 1 1MEG)
ISRC 23 21 AC 0.333 45.0 SFFM(0 1 10K 5 1K)
VMEAS 12 9
VCARRIER 1 0 DISTOF1 0.1 -90.0
VMODULATOR 2 0 DISTOF2 0.01
IIN1 1 5 AC 1 DISTOF1 DISTOF2 0.001

N+ and N- are the positive and negative nodes, respectively. Note that voltage sources need not be grounded. Positive current is assumed to flow from the positive node, through the source, to the negative node. A current source of positive value forces current to flow out of the N+ node, through the source, and into the N- node. Voltage sources, in addition to being used for circuit excitation, are the 'ammeters' for SPICE, that is, zero valued voltage sources may be inserted into the circuit for the purpose of measuring current. They of course have no effect on circuit operation since they represent short-circuits.

DC/TRAN is the dc and transient analysis value of the source. If the source value is zero both for dc and transient analyses, this value may be omitted. If the source value is time-invariant (e.g., a power supply), then the value may optionally be preceded by the letters DC.

ACMAG is the ac magnitude and ACPHASE is the ac phase. The source is set to this value in the ac analysis. If ACMAG is omitted following the keyword AC, a value of unity is assumed. If ACPHASE is omitted, a value of zero is assumed. If the source is not an ac small-signal input, the keyword AC and the ac values are omitted.

DISTOF1 and DISTOF2 are the keywords that specify that the independent source has distortion inputs at the frequencies F1 and F2 respectively (see the description of the .DISTO control line). The keywords may be followed by an optional magnitude and phase. The default values of the magnitude and phase are 1.0 and 0.0 respectively.

Any independent source can be assigned a time-dependent value for transient analysis. If a source is assigned a time-dependent value, the time-zero value is used for dc analysis. There are five independent source functions: pulse, exponential, sinusoidal, piece-wise linear, and single-frequency FM. If parameters other than source values are omitted or set to zero, the default values shown are assumed. (TSTEP is the printing increment and TSTOP is the final time (see the .TRAN control line for explanation)).

Parameters: Independent voltage source, Independent current source

Pulse

General form

PULSE(V1 V2 TD TR TF PW PER)

Examples

VIN 3 0 PULSE(-1 1 2NS 2NS 2NS 50NS 100NS)
parameterdefault valueunits
V1 (initial value)Volts or Amps
V2 (pulsed value)Volts or Amps
TD (delay time)0.0seconds
TR (rise time)TSTEPseconds
TF (fall time)TSTEPseconds
PW (pulse width)TSTOPseconds
PER(period)TSTOPseconds

A single pulse so specified is described by the following table:

timevalue
0V1
TDV1
TD+TRV2
TD+TR+PWV2
TD+TR+PW+TFV1
TSTOPV1

Intermediate points are determined by linear interpolation.

Sinusoidal

General form

SIN(VO VA FREQ TD THETA)

Examples

VIN 3 0 SIN(0 1 100MEG 1NS 1E10)
parametersdefault valueunits
VO (offset)Volts or Amps
VA (amplitude)Volts or Amps
FREQ (frequency)1/TSTOPHz
TD (delay)0.0seconds
THETA (damping factor)0.01/seconds

The shape of the waveform is described by the following table:

timevalue
0 to TDVO -(t - TD)THETA
TD to TSTOPVO + VA e sin(2π FREQ (t + TD))

Exponential

General form

EXP(V1 V2 TD1 TAU1 TD2 TAU2)

Examples

VIN 3 0 EXP(-4 -1 2NS 30NS 60NS 40NS)
parameterdefault valueunits
V1 (initial value)Volts or Amps
V2 (pulsed value)Volts or Amps
TD1 (rise delay time)0.0seconds
TAU1 (rise time constant)TSTEPseconds
TD2 (fall delay time)TD1+TSTEPseconds
TAU2 (fall time constant)TSTEPseconds

The shape of the waveform is described by the following table:

timevalue
0 to TD1V1 | ------------| TAU1 | -(t - TD1) | -(t - TD2)
TD1 to TD2V1 + (V2 - V1) 1 - e | ----------| | ----------| | TAU1 | | TAU2 |
TD2 to TSTOPV1 + (V2 - V1) - e + (V1 - V2) 1 - e

Piece-Wise Linear

General form

PWL(T1 V1 <T2 V2 T3 V3 T4 V4 ...>)

Examples

VCLOCK 7 5 PWL(0 -7 10NS -7 11NS -3 17NS -3 18NS -7 50NS -7)

Each pair of values (Ti, Vi) specifies that the value of the source is Vi (in Volts or Amps) at time=Ti. The value of the source at intermediate values of time is determined by using linear interpolation on the input values.

Single-Frequency FM

General form

SFFM(VO VA FC MDI FS)

Examples

V1 12 0 SFFM(0 1M 20K 5 1K)
parameterdefault valueunits
VO (offset)Volts or Amps
VA (amplitude)Volts or Amps
FC (carrier frequency)1/TSTOPHz
MDI (modulation index)
FS (signal frequency)1/TSTOPHz

The shape of the waveform is described by the following equation:

V(t) = VO+VA sin ( 2π⁢FC⁢t + MDI⁢sin(2π⁢FS⁢t) )

Linear Dependent Sources

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

i=gvv=evi=fiv=hi

where g, e, f, and h are constants representing transconductance, voltage gain, current gain, and transresistance, respectively.

Polynomial sources: POLY(ND)

The E, F, G and H sources also accept the SPICE2 polynomial form, in which the output is a polynomial in one or more controlling voltages or currents:

EXXXXXXX N+ N- POLY(ND) NC1+ NC1- ... NCND+ NCND- P0 P1 P2 ...
GXXXXXXX N+ N- POLY(ND) NC1+ NC1- ... NCND+ NCND- P0 P1 P2 ...
FXXXXXXX N+ N- POLY(ND) VNAM1 ... VNAMND P0 P1 P2 ...
HXXXXXXX N+ N- POLY(ND) VNAM1 ... VNAMND P0 P1 P2 ...

ND is the dimension of the polynomial: the number of controlling quantities. For E and G sources, each is a voltage between a pair of nodes; for F and H sources, each is the current through a voltage source. They are followed by the polynomial coefficients P0, P1, ...; coefficients not given are zero.

The coefficients are in the SPICE2 order: the constant term, then the terms of degree 1, degree 2 and so on, and within each degree the exponent of x1 from highest to lowest, then of x2, and so on. With controlling quantities x1, x2, x3:

POLY(1): P0+P1x1+P2x12+P3x13+… POLY(2): P0+P1x1+P2x2+P3x12+P4x1x2+P5x22+P6x13+P7x12x2+… POLY(3): P0+P1x1+P2x2+P3x3+P4x12+P5x1x2+P6x1x3+P7x22+…

For example, a multiplier whose output is V(1)·V(2):

EMULT 3 0 POLY(2) 1 0 2 0 0 0 0 0 1

A POLY source is converted, as the circuit is read, into an arbitrary source (B source) with the same polynomial as its expression, named B followed by the whole original name: EMULT becomes BEMULT, with the expression v=v(1,0)*v(2,0). Use that name to refer to the device, for example with show, @bemult[v] or the branch current bemult#branch, and as the controlling source of another F or H source; listing expand shows the converted line.

Notes on this version:

Linear Voltage-Controlled Current Sources

General form

GXXXXXXX N+ N- NC+ NC- VALUE
GXXXXXXX N+ N- POLY(ND) NC1+ NC1- ... NCND+ NCND- P0 P1 P2 ...

Examples

G1 2 0 5 0 0.1MMHO
GNONLIN 100 0 POLY(1) 3 0 0 1e-3 1e-4

N+ and N- are the positive and negative nodes, respectively. Current flow is from the positive node, through the source, to the negative node. NC+ and NC- are the positive and negative controlling nodes, respectively. VALUE is the transconductance (in mhos).

In the POLY form, the output current is a polynomial in ND controlling voltages, each given by a pair of nodes NCk+ and NCk-, followed by the polynomial coefficients P0, P1, ... (see polynomial sources). In the example, the current is 1e-3·V(3) + 1e-4·V(3)2.

Parameters: Voltage-controlled current source

Linear Voltage-Controlled Voltage Sources

General form

EXXXXXXX N+ N- NC+ NC- VALUE
EXXXXXXX N+ N- POLY(ND) NC1+ NC1- ... NCND+ NCND- P0 P1 P2 ...

Examples

E1 2 3 14 1 2.0
ENONLIN 100 101 POLY(2) 3 0 4 0 0.0 13.6 0.2 0.005

N+ is the positive node, and N- is the negative node. NC+ and NC- are the positive and negative controlling nodes, respectively. VALUE is the voltage gain.

In the POLY form, the output voltage is a polynomial in ND controlling voltages, each given by a pair of nodes NCk+ and NCk-, followed by the polynomial coefficients P0, P1, ... (see polynomial sources). In the example, with V(3) = x1 and V(4) = x2, the output is 13.6·x1 + 0.2·x2 + 0.005·x12.

Parameters: Voltage-controlled voltage source

Linear Current-Controlled Current Sources

General form

FXXXXXXX N+ N- VNAM VALUE
FXXXXXXX N+ N- POLY(ND) VNAM1 ... VNAMND P0 P1 P2 ...

Examples

F1 13 5 VSENS 5
FNONLIN 100 101 POLY(2) VCC VBB 0.0 13.6 0.2 0.005

N+ and N- are the positive and negative nodes, respectively. Current flow is from the positive node, through the source, to the negative node. VNAM is the name of a voltage source through which the controlling current flows. The direction of positive controlling current flow is from the positive node, through the source, to the negative node of VNAM. VALUE is the current gain.

In the POLY form, the output current is a polynomial in the currents through ND voltage sources VNAM1 ... VNAMND, followed by the polynomial coefficients P0, P1, ... (see polynomial sources). In the example, with the currents through VCC and VBB as x1 and x2, the output is 13.6·x1 + 0.2·x2 + 0.005·x12.

Parameters: Current-controlled current source

Linear Current-Controlled Voltage Sources

General form

HXXXXXXX N+ N- VNAM VALUE
HXXXXXXX N+ N- POLY(ND) VNAM1 ... VNAMND P0 P1 P2 ...

Examples

HX 5 17 VZ 0.5K
HNONLIN 100 101 POLY(2) VCC VBB 0.0 13.6 0.2 0.005

N+ and N- are the positive and negative nodes, respectively. VNAM is the name of a voltage source through which the controlling current flows. The direction of positive controlling current flow is from the positive node, through the source, to the negative node of VNAM. VALUE is the transresistance (in ohms).

In the POLY form, the output voltage is a polynomial in the currents through ND voltage sources VNAM1 ... VNAMND, followed by the polynomial coefficients P0, P1, ... (see polynomial sources).

Parameters: Current-controlled voltage source

Non-linear Dependent Sources

General form

BXXXXXXX N+ N- <I=EXPR> <V=EXPR>

Examples

B1 0 1 I=cos(v(1))+sin(v(2))
B1 0 1 V=ln(cos(log(v(1,2)^2)))-v(3)^4+v(2)^v(1)
B1 3 4 I=17
B1 3 4 V=exp(pi^i(vdd))

N+ is the positive node, and N- is the negative node. The values of the V and I parameters determine the voltages and currents across and through the device, respectively. If I is given then the device is a current source, and if V is given the device is a voltage source. One and only one of these parameters must be given.

The small-signal AC behavior of the nonlinear source is a linear dependent source (or sources) with a proportionality constant equal to the derivative (or derivatives) of the source at the DC operating point.

The expressions given for V and I may be any function of voltages and currents through voltage sources in the system. The following functions of real variables are defined:

abs     asinh   cosh   sin
acos    atan    exp    sinh
acosh   atanh   ln     sqrt
asin    cos     log    tan

The function "u" is the unit step function, with a value of one for arguments greater than one and a value of zero for arguments less than zero. The function "uramp" is the integral of the unit step: for an input x, the value is zero if x is less than zero, or if x is greater than zero the value is x. These two functions are useful in sythesizing piece-wise non-linear functions, though convergence may be adversely affected.

The following standard operators are defined:

+ - * / ^ unary -

If the argument of log, ln, or sqrt becomes less than zero, the absolute value of the argument is used. If a divisor becomes zero or the argument of log or ln becomes zero, an error will result. Other problems may occur when the argument for a function in a partial derivative enters a region where that function is undefined.

To get time into the expression you can integrate the current from a constant current source with a capacitor and use the resulting voltage (don't forget to set the initial voltage across the capacitor). Non-linear resistors, capacitors, and inductors may be synthesized with the nonlinear dependent source. Non-linear resistors are obvious. Nonlinear capacitors and inductors are implemented with their linear counterparts by a change of variables implemented with the nonlinear dependent source. The following subcircuit will implement a nonlinear capacitor:

.Subckt nlcap   pos neg
* Bx: calculate f(input voltage)
Bx   1    0    v = f(v(pos,neg))
* Cx: linear capacitance
Cx   2    0    1
* Vx: Ammeter to measure current into the capacitor
Vx   2    1    DC 0Volts
* Drive the current through Cx back into the circuit
Fx   pos  neg  Vx 1
.ends

Non-linear inductors are similar.

Parameters: Arbitrary (nonlinear) source