侧边栏壁纸
博主头像
Yaohaolin

你好,有缘人

  • 累计撰写 12 篇文章
  • 累计创建 22 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

Spice简要语法整理

Yaohaolin
2024-12-01 / 0 评论 / 3 点赞 / 37 阅读 / 0 字 / 正在检测是否收录...
tips:default 持续整理中......

1 前言

SPICE的全称是Simulation Program with Integrated Circuit Emphasis,最初由Berkeley于20世纪七十年代发明。它是一种利用电路中结点和器件的互联进行仿真的方法。

2 Hspice的文件格式

一个常见的HSPICE文件内容包括:标题行、控制语句、电源定义、器件定义(连接)、子电路定义、仿真/分析语句、结束语句等。

类别 内容
标题 本行填写,如无标题则需空
控制语句 库引用、输出选择、参数定义等
电源定义 定义电源,如Vcc、Vss等
器件定义 定义如晶体管、电容、电阻、子电路等器件并将其通过各个结点连接
子电路定义 定义电路中会用到的子电路
仿真/分析语句 设置要进行的仿真
结束语句 .end 必须存在

3 Spice基本语法

3.1 常数、比例与单位(不区分大小写)

3.1.1 常数

符号 含义
GND 地,0电压

3.1.2 比例

比例 尺度
db 20log10
t 1E+12
g 1E+9
meg 1E+6
k 1E+3
m 1E-3
u 1E-6
n 1E-9
p 1E-12
f 1E-15

在HSPICE输出文件中,

比例 尺度
a 1E-18

3.1.3 单位

单位 含义
V
A
F
H
OHM 欧姆
HZ 赫兹
DEG

3.2 基本语句

3.2.1 注释

* 这是一个注释

HSPICE中没有多行注释

3.2.2 续行符

+ 继续上一行的语句

3.2.3电压源

Vxxx n+ n- <<DC=> dcval> <tranfun> <AC=acmag, <acphase>>
参数 含义
n+ 正极
n- 负极
DC=dcval 直流电压,默认为0.0
tranfun 瞬态源函数(AM、DC、EXP、PE、PL、PU、PULSE、PWL、SFFM、SIN中的一个或多个)
AC 交流小信号分析中使用的交源关键字
acmag 交流源幅值
acphase 交流源相位,默认为0.0

3.2.4 电流源

Ixxx n+ n- <<DC=> dcval> <tranfun> <AC=acmag, <acphase>>
+ <M=val>
参数 含义
n+ 正极
n- 负极
DC=dcval 直流电压,默认为0.0
tranfun 瞬态源函数(AM、DC、EXP、PE、PL、PU、PULSE、PWL、SFFM、SIN中的一个或多个)
AC 交流小信号分析中使用的交源关键字
acmag 交流源幅值
acphase 交流源相位,默认为0.0
M 并联个数

3.2.5 脉冲源

Vxxx n+ n- PU<LSE> <(>v1 v2 <td <tr <tf <pw <per>>>>> <)>
Ixxx n+ n- PU<LSE> <(>v1 v2 <td <tr <tf <pw <per>>>>> <)>r
参数 含义
PULSE 可缩写为PU
v1 低压/低电流
v2 高压/高电流
td 延迟
tr 上升时间
tf 下降时间
pw 脉冲宽度
per 周期

3.2.6 正弦源

Vxxx n+ n- SIN <(> vo va <freq <td <  <  >>>> <)>
Ixxx n+ n- SIN <(> vo va <freq <td <  <  >>>> <)>
参数 含义
vo 直流幅度
va 交流幅度
freq 频率
td 延迟,正弦源开始前的延迟时间,默认为0
ө 衰减因子,单位1/s,默认为0
φ 相位延迟,默认为0

3.2.7 指数源

Vxxx n+ n- EXP <(> v1 v2 <td1 <τ1 <td2 <τ2  >>>> <)>
Ixxx n+ n- EXP <(> v1 v2 <td1 <τ1 <td2 <τ2 >>>> <)>
参数 含义
EXP
v1 初始值
v2 终值
td1 上升延迟
td2 下降延迟
τ1 上升时间
τ2 下降时间

3.2.8 分段线性源

Vxxx n+ n- PWL <(> t1 v1 <t2 v2 t3 v3…> <R <=repeat>> 
+ <TD=delay> <)>
Ixxx n+ n- PWL <(> t1 v1 <t2 v2 t3 v3…> <R <=repeat>> 
+ <TD=delay> <)>
参数 含义
PWL
(t1 v1),…(ti vi) 每个时间点对应一个电压,时间点之间线性插值填充
R=repeat 循环的起始时间点,repeat必须是t1,t2, …中的某一个,不能是最大的那个时间点。若没有这个命令,电压维持最后一个时间点的电压。
Td=delay 函数开始的延迟

3.2.9 调频源

Vxxx n+ n- SFFM <(> vo va <fc <mdi <fs>>> <)>
Ixxx n+ n- SFFM <(> vo va <fc <mdi <fs>>> <)>
参数 含义
SFFM
vo 直流幅度
va 交流幅度
fc 主频率
mdi 调制系数,一般取1到10,默认为0
fs 调制频率

3.2.10 调幅源

Vxxx n+ n- AM <(> vo va fm fc <td> <)>
Ixxx n+ n- AM <(> vo va fm fc <td> <)>
参数 含义
vo 直流幅度
va 交流幅度
fm 调制频率
fc 载波频率
td 初始延迟

SPCICE中支持混合源

3.3 有源器件

3.3.1 二极管

Dxxx  nplus nminus mname
参数 含义
nplus 正极(模型中的寄生电阻串联在正极端)
nminus 负极
mname 被用到的模型名称

3.3.2 BJT

Qxxx nc nb ne <ns> mname <area> <OFF> <IC = vbeval,vceval>
+ <M = val> <DTEMP = val>
参数 含义
nc 集电极
nb 基极
ne 发射极
ns 衬底, 可选择. 可以在BJT模型中用BULK参数设置.
mname 被用到的模型名称
area, AREA = area 影响电流、电阻和电容的发射极面积倍增因子,默认值=1.0
OFF 设置DC分析的初始条件,默认设置为ON
IC = vbeval, vceval,VBE, VCE 初始的内部基极-发射极电压(vbeval)和集电极-发射极间电压(vceval),当UIC存在于.TRAN语句使用,并被覆盖.IC语句覆盖
M 并联个数,默认为1
DTEMP 器件温度与电路温度之差,单位为摄氏度。默认值为0.0
AREAB 影响电流、电阻和电容的基极面积倍增因子。默认值=AREA
AREAC 影响电流、电阻和电容的集电极面积倍增因子。默认值=AREA

3.3.3 MOSFET

Mxxx  nd ng ns <nb> mname <<L = >length> <<W = >width>
+ <AD = val> <AS = val> <PD = val> <PS = val> <NRD = val>
+ <NRS = val> <RDC = val> <RSC = val> <OFF> <IC = vds,vgs,vbs>
+ <M = val> <DTEMP = val> <DELVTO = val>
参数 含义
nd 漏极
ng 栅极
ns 源极
nb 衬底, 可选择. 可以在MOS模型中用BULK参数设置
mname 被用到的模型名称
L 沟道长度
W 沟道宽度
AD 漏极扩散区面积
AS 源极扩散区面积
PD 漏结周长,包括沟道边缘
PS 源结周长,包括沟道边缘
NRD 用于电阻计算的漏极扩散平方数
NRS 用于电阻计算的源极扩散平方数
RDC 由于接触电阻导致的额外漏极电阻
RSC 由于接触电阻导致的额外源极电阻
OFF 设置DC分析的初始条件,默认设置为ON
IC = vds, vgs, vbs 初始的外部漏源(vds)、栅源(vgs)、衬源(vbs)电压
M 并联个数
DTEMP 器件温度与电路温度之差,单位为摄氏度。默认值为0.0
DELVTO 阈值电压偏移量,默认值0.0

3.3.4 JFET/MESFET

Jxxx nd ng ns <nb> mname <<<AREA> = area | <W = val> <L = val>>
+ <OFF> <IC = vdsval,vgsval> <M = val> <DTEMP = val>
参数 含义
nd 漏极
ng 栅极
ns 源极
nb 衬底(可选)
mname 被用到的模型名称
area, AREA = area 影响BETA、RD、RS、IS、CGS和CGD参数的面积倍增因子。默认值为1.0,单位为平方米
W 栅宽,单位为米
L 栅长,单位为米
OFF DC分析时的初始条件,默认为ON
*C = vdsval, vgsval, VDS, VGS 初始的内部漏源电压(vdsval)和栅源电压(vgsval),当UIC存在于.TRAN语句使用,并被覆盖.IC语句覆盖
M 并联个数,默认为1
DTEMP 器件温度与电路温度之差,单位为摄氏度。默认值为0.0

3.4 无源器件

3.4.1 电阻

Rxxx n1 n2 <mname> <R = >resistance <AC = val>
参数 含义
n1 阳极
n2 阴极
mname 电阻模型名称
R = resistance 室温下电阻大小,单位欧姆
AC 交流分析中电阻大小

3.4.2 电容

Cxxx n1 n2 <mname> <C = >capacitance
参数 含义
n1 阳极
n2 阴极
mname 电容模型名称
C = capacitance 室温下电容大小,单位库伦

3.4.3 电感

Lxxx n1 n2 <L = >inductance
参数 含义
n1 阳极
n2 阴极
mname 电感模型名称
L = inductance 室温下电感大小,单位亨特

3.4.4 互感

Kxxx Lyyy Lzzz <K = >coupling
参数 含义
Lyyy 第一级电感
Lzzz 第二级电感
K = coupling 耦合系数

3.5 其他器件

3.5.1 电压控制电压源

Exxx

3.5.2 电流控制电流源

Fxxx

3.5.3 电压控制电流源

Gxxx

3.5.4 电流控制电压源

Hxxx

3.5.5 传输线

Txxx in refin out refout Z0 = val TD = val <L = val> <IC = v1,i1,v2,i2>

Uxxx in1 <in2 <...in5>> refin out1 <out2 <...out5>> refout mname
+ L = val <LUMPS = val>
Txxx
in 输入结点
refin 参考地(对于输入)
out 输出结点
refout 参考地(对于输出)
Z0 特征阻抗
TD 延迟(秒每米)
L 长度(米),默认为1
IC = v1,i1,v2,i2 初始条件:输入电压(v1)、输入流(i1)、输出电压(v2)和输出电流(i2)
Uxxx
inx 第x条传输线的信号输入结点(需要有n1)。
refin 参考地(对于输入)
outx 第x条传输线的信号输出结点(每个输入端口必须有一个对应的输出端口)。
refout 参考地(对于输出)
mname 使用的模型名称
L 长度(米)
LUMPS 仿真中使用的集总部分的数量

3.6 控制语句

3.6.1 .ALTER

.alter

用于使用不同的参数和数据反复仿真

3.6.2 .DATA

.DATA datanm pnam1 < pnam2 pnam3 … pnamxxx> 
+ pval1 < pval2 pval3 … pvalxxx> 
+ pval1' < pval2' pval3' … pvalxxx'> 
.ENDDATA


*例子

.param width=0 length=0 thresh=0 cap=0 
.tran 1n 100n sweep data=devinf 
.data devinf width length thresh  cap 
             50u      30u   1.2v  1.2pf 
             25u      15u   1.0v  0.8pf 
              5u      2u    0.7v  0.6pf 
.enddata

可以修改不同的参数进行仿真

3.6.3 .GLOBAL

.global node1 node2 ...

定义全局结点

3.6.4 .INCLUDE

.inlcude '<filepath> filename'

引用文件

可简写为.inc

3.6.5 .LIB

.LIB '<filepath>filename' entryname

使用工艺库

entryname: 库文件中的名称,如工艺角‘TT’

3.6.6 .MEASURE

3.6.6.1 上升、下降与延迟

用于测量自变量 (时间、频率或任何参数或温度) 差分测量,例如上升时间、下降时间、转换速率以及任何需要确定自变量值的测量。该方法指定子语句 TRIG 和 TARG。这两个语句指定了测量开始和结束时电压或电流的幅度。

.MEASURE <DC|AC|TRAN> result TRIG ... TARG ...
+ <GOAL = val> <MINVAL = val> <WEIGHT = val>
参数 含义
result 与Hspice输出中的测量值关联的名称。测量的项目从TRIG开始到TARG结束的自变量:对于瞬态分析,它是时间;对于交流分析,它是频率;对于DC分析,它是DC扫描变量。如果在TRIG激活之前达到目标,则结果值为负。注意:不可以用“DC”、“TRAN”和“AC”命名。
TRIG..., TARG ... 标志开始的TRGI和最终目标TARG
\ 指定测量的分析类型。若省略,则为最后一个分析模式。
GOAL 指定优化中所需的测量值。
MINVAL 如果GOAL的绝对值小于MINVAL,则ERRfun表达式分母中的GOAL值将被MINVAL替换。默认值=1.0e-12。
WEIGHT 计算出的误差乘以权重值,用于优化,默认值=1.0。

TRIG

TRIG trig_var VAL = trig_val <TD = time_delay> <CROSS = c>
+ <RISE = r> <FALL = f>

TRIG AT = va
TRIG 触发
trig_val trig_var的值,用于交叉、上升或下降的计数器递增1
trig_var 指定输出变量的名称,该名称决定了测量的逻辑起点。如果在TRIG被激活之前达到TRAG则.MEASURE报告负值。

TARG

TARG targ_var VAL = targ_val <TD = time_delay>
+ <CROSS = c | LAST> <RISE = r | LAST> <FALL = f | LAST>
TARG 目标信号
targ_val trig_var的值,用于交叉、上升或下降的计数器递增1
targ_var 由trig_var确定的传播延迟的输出变量的名称
time_delay 启用测量之前必须经过的模拟时间量,交叉、上升或下降的次数仅在time_delay值之后计算。默认触发延迟为零。
CROSS = cRISE = rFALL = f 这些数字表示交叉、下降或上升事件的发生会导致执行测量。ForRISE=r,满足WHEN条件,当指定信号上升r次时进行测量。对于FALL=f,当指定信号下降f个下降时间时进行测量。交叉要么是上升,要么是下降,因此对于CROSS=c,当指定信号由于上升或下降而达到总共*c*个交叉时间时,就会进行测量。对于TARG,最后一个事件用last关键字指定
LAST 当最后一个CROSS、FALL或RISE事件发生时,进行测量。对于CROSS=LAST,测量是在上升或下降信号的WHEN条件最后一次为真时进行的。对于FALL=LAST,测量是在下降信号的WHEN条件为真的最后一次进行的。对于RISE=LAST,测量是在上升信号的WHEN条件为真的最后一次进行的。LAST是一个保留字,不能被选为上述参数名称
AT = val TRIG规格的特殊情况。“val”是TRAN分析的时间、AC分析的频率或DC分析的参数,在该时间开始测量。
3.6.6.2 FIND和WHEN

使用FIND 和 WHEN 函数,可以在某些特定事件发生时,测量任何自变量(时间、频率、参数)、任何因变量(例如电压或电流)或任何因变量的导数。这些测量语句在单位增益频率或相位测量中很有用,也可用于测量两个信号相互交叉时或信号与恒定值交叉时的时间、频率或任何参数值。测量将在指定的时间延迟 TD 后开始。可以通过将 RISE、FALL 或 CROSS 设置为值(或参数)或将 LAST 设置为最后一个事件来查找特定事件。

.MEASURE <DC|TRAN| AC> result WHEN out_var = val <TD = val>
+ < RISE = r | LAST > < FALL = f | LAST > < CROSS = c | LAST >
+ <GOAL = val> <MINVAL = val> <WEIGHT = val>

.MEASURE <DC|TRAN|AC> result WHEN out_var1 = out_var2 < TD = val >
+ < RISE = r | LAST > < FALL = f | LAST > < CROSS = c| LAST >
+ <GOAL = val> <MINVAL = val> <WEIGHT = val>

.MEASURE <DC|TRAN|AC> result FIND out_var1 WHEN out_var2 = val < TD = val >
+ < RISE = r | LAST > < FALL = f | LAST >
+ < CROSS = c| LAST > <GOAL = val> <MINVAL = val> <WEIGHT = val>

.MEASURE <DC|TRAN|AC> result FIND out_var1 WHEN out_var2 = out_var3
+ <TD = val > < RISE = r | LAST > < FALL = f | LAST >
+ <CROSS = c | LAST> <GOAL = val> <MINVAL = val> <WEIGHT = val>

.MEASURE <DC|TRAN|AC> result FIND out_var1 AT = val <GOAL = val>
参数 含义
CROSS = cRISE = rFALL = f The numbers indicate which occurrence of a CROSS, FALL, or RISE event causes a measurement to be performed. For RISE = r, the WHEN condition is met and measurement is performed when the designated signal has risen r rise times. For FALL = f, measurement is performed when the designated signal has fallen f fall times. A crossing is either a rise or a fall, so for CROSS = c, measurement is performed when the designated signal has achieved a total of c crossing times, as a result of either rising or falling.
\ Specifies the analysis type of the measurement. If omitted, the last analysis type requested is assumed.
FIND Selects the FIND function
GOAL Specifies the desired .MEASURE value. It is used in optimization.
LAST Measurement is performed when the last CROSS, FALL, or RISE event occurs. For CROSS = LAST, measurement is performed the last time the WHEN condition is true for either a rising or falling signal. For FALL = LAST, measurement is performed the last time the WHEN condition is true for a falling signal. For RISE = LAST, measurement is performed the last time the WHEN condition is true for a rising signal. LAST is a reserved word and cannot be chosen as a parameter name in the above .MEASURE statements.
MINVAL If the absolute value of GOAL is less than MINVAL, the GOAL value is replaced by MINVAL in the denominator of the ERRfun expression. Default = 1.0e-12.
out_var(1,2,3) Variables used to establish conditions at which measurement is to take place
result Name associated with the measured value in the Star-Hspice output
TD Identifies the time at which measurement is to start
WEIGHT Calculated error is multiplied by the weight value. Default = 1.0.
WHEN Selects the WHEN function
3.6.6.3 Average, RMS, MIN, MAX, INTEG, 和 Peak-To-Peak
.MEASURE <DC|AC|TRAN> result func out_var <FROM = val> <TO = val>
+ <GOAL = val> <MINVAL = val> <WEIGHT = val>
参数 含义
\ Specifies the analysis type of the measurement. If omitted, the last analysis mode requested is assumed.
FROM Specifies the initial value for the "func" calculation. For transient analysis, value is in units of time.
TO Specifies the end of the "func" calculation.
GOAL Specifies the desired .MEASURE value. It is used in optimization.
MINVAL If the absolute value of GOAL is less than MINVAL, the GOAL value is replaced by MINVAL in the denominator of the ERRfun expression. Default = 1.0e-12.
func Indicates the type of the measure statement, one of the following:* AVG (average):Calculates the area under the out_var divided by the periods of interest* MAX (maximum):Reports the maximum value of the out_var over the specified interval* MIN (minimum):Reports the minimum value of the out_var over the specified interval* PP (peak-to-peak):Reports the maximum value minus the minimum value of the out_var over the specified interval* RMS (root mean squared):Calculates the square root of the area under the out_var 2 curve divided by the period of interest
result Name that is associated with the measured value in the Star-Hspice output. The value is a function of the variable specified (out_var) and func.
out_var Name of any output variable whose function ("func") is to be measured in the simulation.
WEIGHT The calculated error is multiplied by the weight value. Default = 1.0.
3.6.6.4 INTEGRAL 积分
.MEASURE <DC|AC|TRAN> result func out_var <FROM = val> <TO = val>
+ <GOAL = val> <MINVAL = val> <WEIGHT = val>

与3.5.6.3语法相同,但是函数定义为INTEGRAL

3.6.6.5 DERIVATIVE 求导
.MEASURE <DC|AC|TRAN> result DERIVATIVE out_var AT = val <GOAL = val>
+ <MINVAL = val> <WEIGHT = val>

.MEASURE <DC|AC|TRAN> result DERIVATIVE out_var WHEN var2 = val
+ <RISE = r | LAST> <FALL = f | LAST> <CROSS = c | LAST>
+ <TD = tdval> <GOAL = goalval> <MINVAL = minval> <WEIGHT = weightval>

.MEASURE <DC|AC|TRAN> result DERIVATIVE out_var WHEN var2 = var3
+ <RISE = r | LAST> <FALL = f | LAST> <CROSS = c | LAST>
+ <TD = tdval> <GOAL = goalval> <MINVAL = minval> <WEIGHT = weightval>
参数 含义
AT = val Value of out_var at which the derivative is to be found
CROSS = cRISE = rFALL = f The numbers indicate which occurrence of a CROSS, FALL, or RISE event causes a measurement to be performed. For RISE = r, the WHEN condition is met and measurement is performed when the designated signal has risen r rise times. For FALL = f, measurement is performed when the designated signal has fallen f fall times. A crossing is either a rise or a fall, so for CROSS = c, measurement is performed when the designated signal has achieved a total of c crossing times, as a result of either rising or falling.
\ Specifies the analysis type measured. If omitted, the last analysis mode requested is assumed.
DERIVATIVE Selects the derivative function. May be abbreviated to DERIV.
GOAL Specifies the desired .MEASURE value. It is used in optimization.
LAST Measurement is performed when the last CROSS, FALL, or RISE event occurs. For CROSS = LAST, measurement is performed the last time the WHEN condition is true for either a rising or falling signal. For FALL = LAST, measurement is performed that last time the WHEN condition is true for a falling signal. For RISE = LAST, measurement is performed the last time the WHEN condition is true for a rising signal. LAST is a reserved word and cannot be chosen as a parameter name in the above .MEASURE statements.
MINVAL If the absolute value of GOAL is less than MINVAL, the GOAL value is replaced by MINVAL in the denominator of the ERRfun expression. Default = 1.0e-12.
out_var Variable for which the derivative is to be found
result Name associated with the measured value in the Star-Hspice output
TD Identifies the time at which measurement is to start
var(2,3) Variables used to establish conditions at which measurement is to take place
WEIGHT The calculated error between result and GOAL is multiplied by the weight value. Default = 1.0.
WHEN Selects the WHEN function
3.6.6.6 ERROR 相对误差
.MEASURE <DC|AC|TRAN> result ERRfun meas_var calc_var <MINVAL = val>
+ < IGNORE | YMIN = val> <YMAX = val> <WEIGHT = val> <FROM = val>
+ <TO = val>

相对误差函数报告两个输出变量的相对差值,这种格式通常用于测量数据的优化和曲线拟合。相对误差格式指定了要从.PARAM变量中测量和计算的变量。

参数 含义
\ Specifies the analysis type of the measurement. If omitted, the last analysis mode requested is assumed.
result Name associated with the measured result in the output
ERRfun ERRfun indicates which error function to use: ERR, ERR1, ERR2, or ERR3.
meas_var Name of any output variable or parameter in the data statement. M denotes the meas_var in the error equation.
calc_var Name of the simulated output variable or parameter in the .MEASURE statement to be compared with meas_var. C denotes the calc_var in the error equation.
IGNOR|YMIN If the absolute value of meas_var is less than IGNOR value, then this point is not considered in the ERRfun calculation. Default = 1.0e-15.
FROM Specifies the beginning of the ERRfun calculation. For transient analysis, the from value is in units of time. Defaults to the first value of the sweep variable.
WEIGHT The calculated error is multiplied by the weight value. Default = 1.0.
YMAX If the absolute value of meas_var is greater than the YMAX value, then this point is not considered in the ERRfun calculation. Default = 1.0e+15.
TO Specifies the end of the ERRfun calculation. Defaults to the last value of the sweep variable.
MINVAL If the absolute value of meas_var is less than MINVAL, the meas_var value is replaced by MINVAL in the denominator of the ERRfun expression. Default = 1.0e-12.

3.6.7 .OPTIONS

.OPTIONS opt1 <opt2 opt3 ...>

对SPICE的行为进行控制

关键字摘要:

常规控制 模型分析 静态工作点、直流扫描、零极点 瞬态与交流小信号分析
Input, Output Interfaces General Accuracy Convergence Accuracy Timestep
ACCT ARTIST DCAP ABSH CONVERGE ABSH ABSVAR
ACOUT CDS SCALE ABSI CSHDC ABSV, VNTOL DELMAX
ALT999ALT9999 CSDF TNOM ABSMOS DCFOR ACCURATE DVDT
MEASOUT ABSTOL DCHOLD ACOUT FS
BRIEF MENTOR MOSFETs ABSVDC DCON CHGTOL FT
CO POST CVTOL DI DCSTEP CSHUNT,GSHUNT IMIN, ITL3
INGOLD PROBE DEFAD KCLTEST DCTRAN IMAX, ITL4
LENNAM PSF DEFAS MAXAMP DV DI ITL5
LIST SDA DEFL RELH GMAX GMIN RELVAR
MEASDGT ZUKEN DEFNRD RELI GMINDC GSHUNT,CSHUNT RMAX
NODE DEFNRS RELMOS GRAMP RMIN
NOELCK Analysis DEFPD RELV GSHUNT MAXAMP SLOPETOL
NOMOD ASPEC DEFPS RELVDC ICSWEEP RELH TIMERES
NOPAGE LIMPTS DEFW NEWTOL RELI
NOTOP PARHIER SCALM Matrix OFF RELQ Algorithm
NUMDGT SPICE WL ITL1 RESMIN RELTOL DVTR
NXX SEED ITL2 RISETIME IMAX
OPTLST Inductors NOPIV Pole/Zero TRTOL IMIN
OPTS Error GENK PIVOT,SPARSE CSCAL VNTOL, ABSV LVLTIM
PATHNUM BADCHR KLIM FMAX Speed MAXORD
PLIM DIAGNOSTIC PIVREF FSCAL AUTOSTOP METHOD
POST_VERSION NOWARN BJTs PIVREL GSCAL BKPSIZ MU, XMU
SEARCH WARNLIMIT EXPLI PIVTOL LSCAL BYPASS
VERIFY SPARSE,PIVOT PZABS BYTOL Input, Output
CPU Version Diodes PZTOL FAST INTERP
CPTIME H9007 EXPLI RITOL ITLPZ ITRPRT
EPSMIN Input, Output XnR, XnI MBYPASS UNWRAP
EXPMAX CAPTAB NEWTOL
LIMTIM DCCAP
VFLOOR

3.6.8 .PRINT

.PRINT antype ov1 <ov2 ...OV32>

指定要在输出文件中打印的变量值

参数 含义
ANTYPE 指定输出的分析类型,Antype 是以下类型之一:DC、AC、TRAN、NOISE 或 DISTO
OV1 ... 指定要打印的输出变量,来自 DC、AC、TRAN、NOISE 或 DISTO 分析的电压、电流或器件模板变量

3.6.9 .TEMP

.temp t1 <t2 < t3 …> >

设定电流仿真时的温度

3.7 仿真语句

3.7.1 .IC 初始化

.IC V(node1)=val1 V(node2)=val2 ……

用于初始化瞬态仿真

3.7.2 .OP 工作点

.OP

DC仿真时计算静态工作点

3.7.3 .DC 直流仿真

.DC var1 START=start1 STOP=stop1 STEP=incr1 

.DC var1 start1 stop1 incr1 < SWEEP var2 type np start2 stop2>

.DC var1 start1 stop1 incr1 < SWEEP DATA=datanam> 

.DC var1 start1 stop1 incr1 <var2 start2 stop2 incr2>

*蒙特卡洛仿真
.DC var1 type np start1 stop1 <SWEEP MONTE=val> 

.DC MONTE=val
3.7.3.1 直流仿真声明
.pz *零极点分析 
.sens *直流小信号敏感性分析
.tf *直流小信号传输函数分析

3.7.4 .AC 交流仿真

.AC type np fstart fstop 

.AC type np fstart fstop <SWEEP var start stop incr> 

.AC type np fstart fstop <SWEEP var type np start stop> 

.AC type np fstart fstop <SWEEP DATA=datanam>

fstart:开始频率
fstop:结束频率

3.7.4.1交流仿真声明
.disto *失真分析
.net *网络分析
.noise *噪声分析
.sample *采样噪声分析

3.7.5 瞬态仿真

.TRAN  tincr1 tstop1 <tincr2 tstop2 …tincrN tstopN> <START=val> <UIC> 
+  <SWEEP var pstart pstop pincr> 

.TRAN  tincr1 tstop1 <tincr2 tstop2 …tincrN tstopN> <START=val> <UIC> 
+  <SWEEP DATA=datanm>
3.7.5.1 傅里叶仿真
.fft  <output_var> <START=value> <STOP=value> <NP=value> 
+ <FORMAT=keyword> <WINDOW=keyword> <ALFA=value> <FREQ=value> 
+ <FMIN=value> <FMAX=value>

3.8 输入语句

3.8.1 .PARAM 参数定义

*定义
.PARAM <ParamName> = <RealNumber>
.PARAM <ParamName> = '<Expression>' 
.PARAM <ParamName1> = <ParamName2> 

*定义一个数
.PARAM TermValue = 1g
*定义一个表达式
.PARAM Pi = '355/113'
.PARAM Pi2 = '2*Pi'
**
***定义
.PARAM npRatio = 2.1
.PARAM nWidth = 3u
.PARAM pWidth = 'nWidth * npRatio'
***使用
Mp1 ... <pModelName> W = pWidth
Mn1 ... <nModelName> W = nWidth
**

一些支持的函数:

HSPICE Form Function Class Description
sin(x) sine trig 返回x(弧度)的正弦值
cos(x) cosine trig 返回x(弧度)的余弦值
tan(x) tangent trig 返回x(弧度)的正切值
asin(x) arc sine trig 返回x(弧度)的反正弦值
acos(x) arc cosine trig 返回x(弧度)的反余弦值
atan(x) arc tangent trig 返回x(弧度)的反正切值
sinh(x) hyperbolic sine trig 返回x(弧度)的双曲正弦值
cosh(x) hyperbolic cosine trig 返回x(弧度)的双曲余弦值
tanh(x) hyperbolic tangent trig 返回x(弧度)的双曲正切值
abs(x) absolute value math 返回x的绝对值|x|
sqrt(x) square root math 返回x的平方根
pow(x,y) absolute power math 返回值是x^{integer part of y}
pwr(x,y) signed power math 返回值是(sign of x)|x|^y
log(x) natural logarithm math 返回值是(sign of x)lg(|x|)
log10(x) base 10 logarithm math 返回值是(sign of x)lg(|x|)
exp(x) exponential math 返回值x的e指数值
db(x) decibels math 返回值是(sign of x)20lg(|x|)
int(x) integer math 返回小于等于x的最大整数
sgn(x) return sign math x>0返回1,x<0返回-1,x=0返回0
sign(x,y) transfer sign math 返回值是(sign of y)|x|
min(x,y) smaller of two args control 返回x,y中较小值
max(x,y) larger of two args control 返回x,y中较大值
lv()orlx() element templates various 返回仿真中的不同器件值
v(), i()... circuit output variables various 返回仿真中的不同电路值

3.8.2 .SUBCKT 子电路

.subckt subnam n1 <n2 n3 …> <parnam=val …> 

.ends 

.macro subnam n1 <n2 n3 …> <parnam=val …> 

.eom

3.9 其他语句

持续更新中

4 参考

  1. Index of /franklinduan/articles/hspice
  2. HSPICE® User Guide: Advanced Analog Simulation and Analysis
  3. HSPICE User Guide
  4. Hspice电路仿真.ppt
  5. Hspice语法手册 天津大学电力学院 陈力颖
  6. HSPICE简明教程(复旦大学).pdf
3

评论区