This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Converting a SPICE Netlist to Simscape Blocks

You can convert SPICE components into Simscape™ equivalents using the SPICE conversion assistant. Often this conversion is automatic. However, because SPICE is a rich language, it is not always possible to perform a full conversion without some manual intervention.

To convert SPICE subcircuits into equivalent Simscape components, follow these steps.

  1. Use the subcircuit2ssc function to generate Simscape language component files from a SPICE netlist file. You can use the optional subcircuit1,…,subcircuitN input arguments to specify which subcircuits to convert.

  2. Make any necessary manual conversions to the generated Simscape component files. To identify the required manual conversions, check the comments at the beginning of the generated Simscape component files. You can use the optional unsupportedCommands output argument to generate a struct array that lists unsupported SPICE commands for each subcircuit.

  3. Build the library using ssc_build or add individual components to your model using Simscape Component blocks.

There are many different SPICE simulators with variations in syntax and syntax interpretation. The conversion assistant uses the same syntax as Cadence® PSpice and, where such differences exist, complies with PSpice.

Commands

The SPICE conversion assistant supports these commands:

  • .FUNC — Reusable function

  • .PARAM — Definable parameter

  • .MODEL — Set of reusable component parameters

  • .SUBCKT — Subcircuit

  • .LIB — Directive to include models from an external netlist

  • .INC — Directive to include contents of external netlist

The conversion assistant implements .FUNC SPICE commands using Simscape functions. These functions are placed inside a package sublibrary named +subcircuit_name_simscape_functions, where subcircuit_name is the name of the subcircuit being converted.

Specify the .MODEL syntax for resistors, capacitors, and inductors, as

.MODEL <model name> res(r=<value>)
.MODEL <model name> cap(c=<value>)
.MODEL <model name> ind(l=<value>)
where the r, c, and l values are scaling factors for the value specified on the component declaration. This behavior complies with PSpice, but is not consistent across all simulators.

The conversion assistant does not automatically convert initial conditions specified using the .IC statement. However, you can specify initial conditions for capacitors and inductors using the syntax IC=<value>. Also, you can manually convert any .IC statements from the generated Simscape component files.

Because the purpose of the conversion assistant is to help convert SPICE subcircuits into Simscape blocks, simulation commands, such as .TRAN, are ignored.

Numeric Suffixes

The conversion assistant supports these numeric SPICE suffixes:

SuffixNameScale
TTera1e12
GGiga1e9
MEGMega1e6
KKilo1e3
MMilli1e-3
MIL--25.4e-6
UMicro1e-6
NNano1e-9
PPico1e-12
FFemto1e-15

Mathematical Functions

The conversion assistant supports these basic mathematical functions used in SPICE and MATLAB.

Elementary Math

NameSPICE FunctionMATLAB Function
Absolute valueabsabs
Smallest elementminmin
Largest elementmaxmax
Sign functionsgnsign

Trigonometry

NameSPICE FunctionMATLAB Function
Sinesinsin
Inverse sineasinasin
Hyperbolic sinesinhsinh
Cosinecoscos
Inverse cosineacosacos
Hyperbolic cosinecoshcosh
Tangenttantan
Inverse tangentatanatan
Four-quadrant inverse tangentatan2atan2
Hyperbolic tangenttanhtanh

Exponents and Logarithms

NameSPICE FunctionMATLAB Function
Power** or pwr^ or power
Exponentialexpexp
Natural logarithmln or loglog
Base-10 logarithmlog10log10
Square rootsqrtsqrt

The conversion assistant interprets log() as the natural logarithm rather than the base-10 logarithm. Not all SPICE simulators are consistent in this regard, so ensure that this interpretation is congruent with your SPICE model.

Other

In addition, the conversion assistant supports these SPICE functions:

NameSPICE Function
If conditionif
Saturationlimit
Current through devicei
Voltage across devicev
Step functionstp

Symbols

The conversion assistant recognizes these SPICE symbols:

  • + at the start of a line indicates line continuation from the previous line

  • * at the start of a line indicates that the entire line is a comment

  • ; within a line indicates the beginning of an inline comment

Components

The notation for SPICE commands in this section follows these rules:

  • <argument> refers to a required item in a command line

  • <argument>* refers to a required item in a command line that occur one or more times

  • [argument] refers to an optional item in a command line

  • [argument]* refers to an optional item in a command line that occur zero or more times

This list shows the full set of supported SPICE components, and their supported SPICE netlist notations. You can specify only the .MODEL parameters that differ from SPICE default values.

Sources

  • Independent voltage source

    V<name> <+ node> <- node> [DC] <value>
    V<name> <+ node> <- node> exp(<v1> <v2> <td1> <tc1> <td2> <tc2>)
    V<name> <+ node> <- node> pulse(<v1> <v2> <td> <tr> <tf> <pw> <per>)
    V<name> <+ node> <- node> pwl(<<tj> <vj>>*)
    V<name> <+ node> <- node> sffm(<voff> <vampl> <fc> <mod> <fm>)
    V<name> <+ node> <- node> sin(<voff> <vampl> <freq> <td> <df>)
    
  • Independent current source

    I<name> <+ node> <- node> [DC] <value>
    I<name> <+ node> <- node> exp(<i1> <i2> <td1> <tc1> <td2> <tc2>)
    I<name> <+ node> <- node> pulse(<i1> <i2> <td> <tr> <tf> <pw> <per>)
    I<name> <+ node> <- node> pwl(<<tj> <ij>>*)
    I<name> <+ node> <- node> sffm(<ioff> <iampl> <fc> <mod> <fm>)
    I<name> <+ node> <- node> sin(<ioff> <iampl> <freq> <td> <df>)
    
  • Current-controlled voltage source

    H<name> <+ node> <- node> <voltage source name> <gain>
    H<name> <+ node> <- node> VALUE={<expression>}
    H<name> <+ node> <- node> POLY(<value>) <voltage source name>* <coefficient>*
    H<name> <+ node> <- node> TABLE {<expression>}=< <input value>, <output value> >*
    H<name> <+ node> <- node> <voltage source name> TABLE=< <input value>, <output value> >*
    
  • Voltage-controlled voltage source

    E<name> <+ node> <- node> <+ control node> <- control node> <gain>
    E<name> <+ node> <- node> VALUE={<expression>}
    E<name> <+ node> <- node> POLY(<value>) <<+ control node> <- control node>>* <coefficient>*
    E<name> <+ node> <- node> TABLE {<expression>}=< <input value>, <output value> >*
    E<name> <+ node> <- node> <+ control node> <- control node> TABLE=< <input value>, <output value> >*
    
  • Current-controlled current source

    F<name> <+ node> <- node> <voltage source name> <gain>
    F<name> <+ node> <- node> VALUE={<expression>}
    F<name> <+ node> <- node> POLY(<value>) <voltage source name>* <coefficient>*
    F<name> <+ node> <- node> TABLE {<expression>}=< <input value>, <output value> >*
    F<name> <+ node> <- node> <voltage source name> TABLE=< <input value>, <output value> >*
    
  • Voltage-controlled current source

    G<name> <+ node> <- node> <+ control node> <- control node> <gain>
    G<name> <+ node> <- node> VALUE={<expression>}
    G<name> <+ node> <- node> POLY(<value>) <<+ control node> <- control node>>* <coefficient>*
    G<name> <+ node> <- node> TABLE {<expression>}=< <input value>, <output value> >*
    G<name> <+ node> <- node> <+ control node> <- control node> TABLE=< <input value>, <output value> >*
    
  • Behavioral source (The <expression> does not need to appear in braces {})

    B<name> <+ node> <- node> V=<expression>
    B<name> <+ node> <- node> I=<expression>
    

Passive Devices

  • Resistor

    R<name> <+ node> <- node> [model name] <value>
    .MODEL <model name> res(r=<value>)
  • Capacitor

    C<name> <+ node> <- node> [model name] <value> [IC=<value>]
    .MODEL <model name> cap(c=<value>)
  • Inductor

    L<name> <+ node> <- node> [model name] <value> [IC=<value>]
    .MODEL <model name> ind(l=<value>)
    
  • Inductor coupling

    K<name> <inductor name> <inductor name>* <value>
    

Switches

  • Voltage-controlled switch

    S<name> <+ node> <- node> <+ control node> <- control node> <model name>
    .MODEL <model name> sw(ron=<value>, roff=<value>, vt=<value>, vh=<value>)
    
  • Current-controlled switch

    W<name> <+ node> <- node> <voltage source name> <model name>
    .MODEL <model name> csw(ron=<value>, roff=<value>, it=<value>, ih=<value>)
    

Semiconductor Devices

  • Diode

    D<name> <+ node> <- node> <model name> [area]
    .MODEL <model name> d(is=<value>, rs=<value>, n=<value>, cjo=<value>, vj=<value>,
    	+m=<value>, fc=<value>, tt=<value>, revbrk=<value>, bv=<value>, ibv=<value>,
    	+xti=<value>, eg=<value>)
    
  • Bipolar junction transistor (BJT)

    NPN

    Q<name> <collector node> <base node> <emitter node> [substrate node] <model name> <area>
    .MODEL <model name> npn(bf=<value>, br=<value>, cjc=<value>, cje=<value>, cjs=<value>,
    	+eg=<value>, fc=<value>, ikf=<value>, ikr=<value>, irb=<value>, is=<value>, isc=<value>,
    	+ise=<value>, itf=<value>, mjc=<value>, mje=<value>, mjs=<value>, nc=<value>, ne=<value>,
    	+nf=<value>, nr=<value>, rb=<value>, rbm=<value>, rc=<value>, re=<value>, tf=<value>, 
    	+tr=<value>, vaf=<value>, var=<value>, vjc=<value>, vje=<value>, vjs=<value>, vtf=<value>,
    	+xcjc=<value>, xtb=<value>, xtf=<value>, xti=<value>)
    

    PNP

    Q<name> <collector node> <base node> <emitter node> [substrate node] <model name> <area>
    .MODEL <model name> pnp(bf=<value>, br=<value>, cjc=<value>, cje=<value>, cjs=<value>,
    	+eg=<value>, fc=<value>, ikf=<value>, ikr=<value>, irb=<value>, is=<value>, isc=<value>,
    	+ise=<value>, itf=<value>, mjc=<value>, mje=<value>, mjs=<value>, nc=<value>, ne=<value>,
    	+nf=<value>, nr=<value>, rb=<value>, rbm=<value>, rc=<value>, re=<value>, tf=<value>, 
    	+tr=<value>, vaf=<value>, var=<value>, vjc=<value>, vje=<value>, vjs=<value>, vtf=<value>,
    	+xcjc=<value>, xtb=<value>, xtf=<value>, xti=<value>)
    

  • Junction field-effect transistor (JFET)

    N-Channel

    J<name> <drain node> <gate node> <source node> <model name> [area]
    .MODEL <model name> njf(beta=<value>, cgd=<value>, cgs=<value>, fc=<value>, is=<value>,
    	+lambda=<value>, m=<value>, n=<value>, rd=<value>, rs=<value>, vto=<value>, xti=<value>)
    

    P-Channel

    J<name> <drain node> <gate node> <source node> <model name> [area]
    .MODEL <model name> pjf(beta=<value>, cgd=<value>, cgs=<value>, fc=<value>, is=<value>,
    	+lambda=<value>, m=<value>, n=<value>, rd=<value>, rs=<value>, vto=<value>, xti=<value>)
    

  • Metal-oxide-semiconductor field-effect transistor (MOSFET)

    N-Channel (only level-1 and level-3 are supported)

    M<name> <drain node> <gate node> <source node> <bulk node> <model name>
    	+[L=<value>] [W=<value>] [AD=<value>] [AS=<value>] [PD=<value>] [PS=<value>] [NRD=<value>]
    	+[NRS=<value>] [M=<value>]
    .MODEL <model name> nmos(cbd=<value>, cbs=<value>, cgbo=<value>, cgdo=<value>,
    	+cgso=<value>, cj=<value>, cjsw=<value>, delta=<value>, eta=<value>, fc=<value>, 
    	+gamma=<value>, is=<value>, js=<value>, kappa=<value>, kp=<value>, lambda=<value>, 
    	+ld=<value>, level=<value>, mj=<value>, mjsw=<value>, n=<value>, neff=<value>, nfs=<value>,
    	+nss=<value>, nsub=<value>, nrd=<value>, nrs=<value>, pb=<value>, phi=<value>, rd=<value>,
    	+rs=<value>, rsh=<value>, theta=<value>, tox=<value>, tpg=<value>, ucrit=<value>, 
    	+uexp=<value>, uo=<value>, vmax=<value>, vto=<value>, xj=<value>)
    

    P-Channel (only level-1 and level-3 are supported)

    M<name> <drain node> <gate node> <source node> <bulk node> <model name>
    	+[L=<value>] [W=<value>] [AD=<value>] [AS=<value>] [PD=<value>] [PS=<value>] [NRD=<value>]
    	+[NRS=<value>] [M=<value>]
    .MODEL <model name> pmos(cbd=<value>, cbs=<value>, cgbo=<value>, cgdo=<value>,
    	+cgso=<value>, cj=<value>, cjsw=<value>, delta=<value>, eta=<value>, fc=<value>, 
    	+gamma=<value>, is=<value>, js=<value>, kappa=<value>, kp=<value>, lambda=<value>, 
    	+ld=<value>, level=<value>, mj=<value>, mjsw=<value>, n=<value>, neff=<value>, nfs=<value>,
    	+nss=<value>, nsub=<value>, nrd=<value>, nrs=<value>, pb=<value>, phi=<value>, rd=<value>,
    	+rs=<value>, rsh=<value>, theta=<value>, tox=<value>, tpg=<value>, ucrit=<value>, 
    	+uexp=<value>, uo=<value>, vmax=<value>, vto=<value>, xj=<value>)
    

Subsystems

  • Subcircuit

    X<name> [node]* <subcircuit name> [PARAMS: < <name>=<value> >*]
    

Performing Manual Conversions

After you generate the Simscape component files, inspect each file header for messages regarding unsupported SPICE commands. For example, the conversion assistant does not support the implementation of temperature coefficients for resistors:

R1 p n 1k TC=0.01,-0.002

The generated Simscape component file contains all the supported conversions, and this header, which identifies the temperature coefficients of the resistor for manual conversion:

component test
% test
% Component automatically generated from a SPICE netlist (11-Dec-2018 09:34:57).
% Users should manually implement the following SPICE commands in order to
% achieve a complete implementation:
%    R1: tc 0.01 -0.002
To complete the conversion, modify the Simscape component file to implement the missing components. For more information about performing manual conversions and this particular scenario, see subcircuit2ssc.

Limitations

  • The netlist must be written in PSpice format and be syntactically correct. The conversion assistant does not check for proper PSpice syntax.

  • Only a subset of the PSpice netlist language is supported. However, unsupported PSpice commands are identified at the top of the corresponding Simscape component file to facilitate manual conversion.

  • To build generated Simscape components into Simscape blocks, parameter values must conform to Simscape constraints. For example, capacitance of a fundamental capacitor and inductance of a fundamental inductor must be nonzero.

See Also

|

Related Topics