Main Content

Converting a SPICE Netlist toSimscapeBlocks

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.

要将香料子电路转换为等效的SIMSCAPE组件,请按照以下步骤进行操作。

  1. Use thesubcircuit2sscfunction to generate Simscape language component files from a SPICE netlist file. You can use the optionalsubcircuit1,…,subcircuitNinput 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 optionalunsupportedCommandsoutput argument to generate a结构array that lists unsupported SPICE commands for each subcircuit.

  3. Build the library usingssc_buildor add individual components to your model usingSimscape Componentblocks.

There are many different SPICE simulators with variations in syntax and syntax interpretation. The conversion assistant uses the same syntax as Cadence®PSPICE且在存在这种差异的地方符合PSPICE。

命令

The SPICE conversion assistant supports these commands:

  • .func- 可重复使用的功能

  • 。PARAM— Definable parameter

  • 。模型— Set of reusable component parameters

  • 。SUBCKT— Subcircuit

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

  • .inc— Directive to include contents of external netlist

转换assistant implements.funcSPICE commands using Simscape functions. These functions are placed inside a package sublibrary named+subcircuit_name_simscape_functions, wheresubcircuit_nameis the name of the subcircuit being converted.

指定。模型syntax for resistors, capacitors, and inductors, as

。模型 res(r=) .MODEL  cap(c=) .MODEL  ind(l=)
where ther,c, andlvalues are scaling factors for the value specified on the component declaration. This behavior complies with PSpice, but is not consistent across all simulators.

转换assistant does not automatically convert initial conditions specified using the。ICstatement. However, you can specify initial conditions for capacitors and inductors using the syntaxIC=。另外,您可以手动转换任何。ICstatements 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

转换assistant supports these numeric SPICE suffixes:

Suffix Name Scale
T tera 1e12
G 千兆 1e9
MEG 巨型 1e6
K Kilo 1e3
M Milli 1e-3
MIL -- 25.4e-6
U Micro 1e-6
N Nano 1e-9
P Pico 1e-12
F Femto 1e-15

Mathematical Functions

转换assistant supports these basic mathematical functions used in SPICE and Simscape. These basic mathematical functions might not be continuous or smooth and can cause numerical problems during the simulation. To solve these issues, these functions might require smoothing.

Thesubcircuit2sscfunction automatically turns on the smoothing parameters when converting a SPICE subcircuit. To disable the smoothing option, inside the block mask of the generated Simscape component block, set the指定功能平滑参数parameter toNo

Elementary Math

Name SPICE Function Simscape Function
Absolute value abs simscape.function.abs(x,ZC)
Smallest element min simscape.function.minm(x,y,n,epsilon)
Largest element 最大限度 simscape.function.maxm(x,y,n,epsilon)
Sign function sgn simscape.function.sign(x,ZC)

Trigonometry

Name SPICE Function Simscape Function
Sine
逆正弦 asin simscape.function.asinm(x,warn)
Hyperbolic sine 罪h simscape.function.sinhm(x,maxAbsX,warn)
Cosine cos cos
Inverse cosine acos simscape.function.acosm(x,warn)
双曲余弦 cosh simscape.function.coshm(x,maxabsx,warn)
切线 tan simscape.function.tanm(x,flag,epsilon,x0,warn)
逆切线 atan atan
Four-quadrant inverse tangent atan2 atan2
Hyperbolic tangent

Exponents and Logarithms

Name SPICE Function Simscape Function
Power x**y,pwr(x,y), orpwrs(x,y) simscape.function.powerrational(x,y,flag,epsilon,warn)
Exponential exp simscape.function.expm(x,xl,xh,warn)
Natural logarithm Lnorlog simscape.function.logm(x,x0,warn)
Base-10 logarithm log10 simscape.function.log10m(x,x0,warn)
Square root SQRT simscape.function.sqrtm(x,flag,epsilon,warn)

转换assistant interprets日志()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 and Simscape functions:

Name SPICE Function Simscape Function
If condition 如果 如果else
Saturation limit simscape.function.limitm(x,a,b,n,epsilon)
Current through device i i
跨设备的电压 v v
步骤功能 stp 如果x>0, 1 else 0 end
Derivative (see限制) ddt der
Table 桌子 simscape.tablelookup([x1,x2,…xn],[y1,y2,…yn],x,interpolation=linear,extrapolation=nearest)

List of Simscape Functions

This function always outputs a positive value. Use this function to protect against issues such as division by zero.epsilondetermines the smoothness of the transition and is the absolute error of the hyp function whenx=0

Whenx>epsilon, the output of this function tends tox

此函数返回输入参数的绝对值,x

您可以通过指定输入参数启用或禁用零交叉ZCto eithertrueor错误的

此功能返回x,exp(x), whenx范围之间xlandxh。Otherwise it uses linear extrapolation with gradient matching at the boundary.

Use this function to avoid numerical issues associated withexp(x)对于很小或大的输入参数。

这个函数返回the hyperbolic cosine ofx,cosh(x), whenx范围之间-maxAbsXand最大限度AbsX。Otherwise it uses linear extrapolation with gradient matching at the boundary.

Use this function to avoid numerical issues associated withcosh(x)用于大型的负面或大的积极输入论点。

此功能返回x,辛(x), whenx范围之间-maxAbsXand最大限度AbsX。Otherwise it uses linear extrapolation with gradient matching at the boundary.

Use this function to avoid numerical issues associated with辛(x)用于大型的负面或大的积极输入论点。

此功能返回x,acos(x), 为了-1≤x≤1,0为了x>1, and π forx<-1。This protects against small numerical incursions into the invalid input range foracos(x)

这个函数返回the inverse sine ofx,asin(x), 为了-1≤x≤1,0为了x>1, and π forx<-1。This protects against small numerical incursions into the invalid input range forasin(x)

这个函数返回xlimited betweenxlandxh。The input argument,n,设置平滑函数的顺序。

Argumentepsilon确定过渡的开始,是该函数的绝对错误x等于eitherxlorxh

这个函数返回the natural logarithm ofx,log(x), whenxis greater thanx0。Otherwise it uses linear extrapolation with gradient matching at the boundary.

当值的值x到达附近0during simulation. Setx0between0and1

这个函数返回the base-10 logarithm ofx,log10(x), whenxis greater thanx0。Otherwise it uses linear extrapolation with gradient matching at the boundary.

当值的值x到达附近0during simulation. Setx0between0and1

此功能返回xandy。The input argument,n,设置平滑函数的顺序。

Argumentepsilon确定过渡的开始,是该函数的绝对错误x等于y

这个函数返回the smallest argument betweenxandy。The input argument,n,设置平滑函数的顺序。

Argumentepsilon确定过渡的开始,是该函数的绝对错误x等于y

Power functionx^y, whereyis rational, with protection for negativex

如果是flagargument is0, the function returnsx^y为了x≥0and-(-x)^y为了x<0。如果是flagargument is1,将电源功能应用于simscape.function.hyp(x,epsilon)

香料转换助手转换pwr(x,y)香料功能到simscape.function.powerrational(x,y,1,0,警告)

香料转换助手转换pwrs(x,y)香料功能到simscape.function.powerRational(x,y,0,0,warn)

这个函数返回the sign of the input argument,x

您可以通过指定输入参数启用或禁用零交叉ZCto eithertrueor错误的

带有输入参数保护的平方根函数。

如果是flagargument is0, this function returnssqrt(x)为了positivexand-sqrt(-x)为了negativex。如果是flagargument is1, apply the square root function tosimscape.function.hyp(x,epsilon)

带有输入保护的切线功能。

如果是flagargument is0, this function returns the tangent ofx,tan(x), whenx等于or-π/2。Theepsilonargument determines the smoothness of the transition at these points.

如果是flagargument is1, this function returns the tangent ofx,tan(x), whenx范围之间-x0andx0。Otherwise it uses linear extrapolation with gradient matching at the boundary.

1/epsilonis the maximum allowed value of the output argumenty

Symbols

转换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

  • ;在一行中指示内联评论的开始

Components

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

  • refers to a required item in a command line

  • *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]*指命令行中的可选项目,该项目发生零次或更多次

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

来源

  • Independent voltage source

    V <名称> < +节点> < - >节点(DC) V <名称> < + > <价值node> <- node> exp(     ) V <+ node> <- node> pulse(      ) V <+ node> <- node> pwl(< >*) V <+ node> <- node> sffm(    ) V <+ node> <- node> sin(    )
  • Independent current source

    I <+ node> <- node> [DC]  I <+ node> <- node> exp(     ) I <+ node> <- node> pulse(      ) I <+ node> <- node> pwl(< >*) I <+ node> <- node> sffm(    ) I <+ node> <- node> sin(    )
  • Current-controlled voltage source

    H <名称> < +节点> < -节点> <电压源名称> < gain> H <+ node> <- node> VALUE={} H <+ node> <- node> POLY() * * H <+ node> <- node> TABLE {}=< ,  >* H <+ node> <- node>  TABLE=< ,  >*
  • 电压控制电压源

    E <名称> < +节点> < -节点> < +控制节点> <还要rol node>  E <+ node> <- node> VALUE={} E <+ node> <- node> POLY() <<+ control node> <- control node>>* * E <+ node> <- node> TABLE {}=< ,  >* E <+ node> <- node> <+ control node> <- control node> TABLE=< ,  >*
  • Current-controlled current source

    F <+ node> <- node>   F <+ node> <- node> VALUE={} F <+ node> <- node> POLY() * * F <+ node> <- node> TABLE {}=< ,  >* F <+ node> <- node>  TABLE=< ,  >*
  • Voltage-controlled current source

    g  <+ node> <-node> <+控制节点> <-控制节点>  g   <+ node> <-node> value> value = {} g node> <-node> poly()<<+控制节点> <-控制节点>>* * g   <+ node> <-node> <-node> table> table {} = <<<<<<<<<<<<<<<<<<<<<<<<<输入值>,<输出值>>* g <名称> <+ node> <-node> <-node> <+ control node> <-控制节点> table> table = <<,<输出值>>***
  • Behavioral source (The does not need to appear in braces {})

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

Passive Devices

  • Resistor

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

    c  <+ node> <-node> [模型名称]  [ic = ] .model  cap(c = 
  • 电感器

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

    k <名称> <电感器名称> <电感器名称>* 

Switches

  • 电压控制开关

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

    W <+ node> <- node>   .MODEL  csw(ron=, roff=, it=, ih=)

Semiconductor Devices

  • 二极管

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

    NPN

    q <名称>    [subtrate节点] <模型名称> <区域> .model <模型名称> npn(bf = ,br = ,cjc = <<值>,cje = ,cjs = , +eg = ,fc = ,ikf = ,ikr = ,irb =  is = ,isc = , +ise = ,itf = ,mjc = ,mje = ,mjs = ,nc = ,ne = , +nf = ,nr = ,rb = ,rbm = ,rc = ,re = ,tf = , +tr = ,vaf = ,var = ,vjc = ,vje = ,vjs = ,vtf = , +xcjc = ,xtb = ,XTF = ,XTI = 

    PNP

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

  • Junction field-effect transistor (JFET)

    N通道

    J     [area] .MODEL  njf(beta=, cgd=, cgs=, fc=, is=, +lambda=, m=, n=, rd=, rs=, vto=, xti=)

    P-Channel

    J     [area] .MODEL  pjf(beta=, cgd=, cgs=, fc=, is=, +lambda=, m=, n=, rd=, rs=, vto=, xti=)

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

    N通道(only level-1 and level-3 are supported)

    m <名称>   <源节点>   <模型名称> +[l = ] [w = ] [ad = ] [as = <值>] [pd ​​= ] [ps = ] [nrd = ] +[nrs = ] [m = ] .model  nmos(cbd = <<值>,cbs = ,cgbo = ,cgdo = , +cgso = ,cj = ,cjsw = ,delta = ,eta = ,fc = , +gamma = ,IS = ,js = ,kappa = ,kp = ,lambda = , +ld = ,Level = ,MJ = ,MJSW = ,N = ,Neff = ,NFS = , +NSS = ,NSUB = ,nrd = ,nrs = ,pb = ,phi = ,rd = , +rs = ,rsh = ,theta = ,tox = ,tpg = ,ucrit = , +uexp = ,uo = ,vmax = ,vto = ,xj = 

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

    m <名称>   <源节点>   <模型名称> +[l = ] [w = ] [ad = ] [as = ] [PD=] [PS=] [NRD=] +[NRS=] [M=] .MODEL  pmos(cbd=, cbs=, cgbo=, cgdo=, +cgso=, cj=, cjsw=, delta=, eta=, fc=, +gamma=, is=, js=, kappa=, kp=, lambda=, +ld=, level=, mj=, mjsw=, n=, neff=, nfs=, +nss=, nsub=, nrd=, nrs=, pb=, phi=, rd=, +rs=, rsh=, theta=, tox=, tpg=, ucrit=, +uexp=, uo=, vmax=, vto=, xj=)

Subsystems

  • Subcircuit

    X [node]*  [PARAMS: < = >*]

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, seesubcircuit2ssc

Parasitics Values

对于被动设备,例如电容器和电感器,以在生成的SIMSCAPE组件文件中引入寄生值,请设置Specify parasitics valuesparameter toYes。Then specify the value of theCapacitor parasitic series resistanceor电感器parasitic parallel conductanceparameters.

限制

  • 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.

  • 转换assistant does not support the use of the derivative SPICE function,ddt,在功能调用中。

也可以看看

|

Related Topics