使用Verilog-A实现常见nmos管的建模代码,要求详细的代码
时间: 2024-02-03 20:13:18 浏览: 29
以下是一个简单的 nmos 晶体管 Verilog-A 建模代码的示例:
```
`include "constants.vams"
module nmos_v1 (drain, gate, source, body, vbs, vgs, vds, ids);
// 定义端口
inout drain, source, gate, body;
input vbs, vgs, vds;
output ids;
// 定义参数
parameter REAL W = 1e-6; // 晶体管宽度
parameter REAL L = 1e-6; // 晶体管长度
parameter REAL tox = 2.5e-9; // 氧化层厚度
parameter REAL nsub = 1e16; // 衬底掺杂浓度
parameter REAL eps_ox = 3.9*8.854e-12; // 氧化层介电常数
parameter REAL eps_si = 11.7*8.854e-12; // 硅介电常数
parameter REAL mu = 0.05; // 迁移率
// 定义局部变量
real Vth;
real vdsat;
real idsat;
real vfb;
real phi_f;
real eps_eff;
real Cox;
real Cgs;
real Cgd;
real Cgb;
real Cdb;
real gamma;
real lambda;
real W_eff;
real L_eff;
real Vgs;
real Vds;
real Vbs;
real VT;
real VG;
real VD;
real VSB;
real ID;
real Rd;
real Rs;
real gm;
real gmb;
real go;
real Cgso;
real Cgdo;
real Cgbo;
real Cdbo;
real Cgsd;
real Cgbd;
real Cox_inv;
real VDD;
// 计算局部变量
Vth = 0.5 * (sqrt(4*nsub*eps_si*phi_f) + gamma*sqrt(eps_si)*Vsb - Vdsat);
vdsat = Vgs - Vth;
idsat = 0.5*mu*Cox*W_eff/L_eff*(Vgs-Vth)^2*(1+lambda*Vds);
vfb = -phi_f + eps_si/eps_ox*phi_f;
phi_f = kT/q*log(nsub/ni);
eps_eff = eps_si*eps_ox/(eps_si+eps_ox);
Cox = eps_ox/tox;
Cgs = Cox*W*L_eff/(L_eff+W_eff);
Cgd = Cgs;
Cgb = Cox*W*Leff/(Leff+W_eff);
Cdb = Cox*Leff*L/(L+W_eff);
gamma = sqrt(2*q*eps_si*nsub)/(Cox*Vt);
lambda = 0;
W_eff = W-gamma*(sqrt(phi_f-Vbs)-sqrt(phi_f));
L_eff = L-lambda*W_eff;
VT = Vt*log((nsub)/ni);
VG = gate;
VD = drain;
VSB = body;
ID = 0;
Rd = 0;
Rs = 0;
gm = 0;
gmb = 0;
go = 0;
Cgso = 0;
Cgdo = 0;
Cgbo = 0;
Cdbo = 0;
Cgsd = 0;
Cgbd = 0;
Cox_inv = 1/Cox;
VDD = 1.8;
// 计算电流
if(VD > VG) begin
ID = mu*Cox*W_eff/L_eff*(Vgs-Vth-Vds/2)*Vds*(1+lambda*Vds);
Rd = 1/lambda/mu/W_eff*Cox*L_eff;
end else begin
ID = mu*Cox*W_eff/L_eff*(Vgs-Vth)^2*(1+lambda*Vds);
Rd = 0;
end
if (VG <= Vth) begin
ID = 0;
Rd = 0;
end
if (ID > idsat) begin
ID = idsat;
Rd = Vdsat/idsat;
end
if (ID < 0) begin
ID = 0;
Rd = Vdsat/idsat;
end
// 计算导通电阻
if (VDS <= Vgs-Vth) begin
Rs = 1/(mu*Cox*W_eff/L_eff*(Vgs-Vth-VDS/2));
end else begin
Rs = 1/(2*mu*Cox*W_eff/L_eff*(Vgs-Vth)*(Vdsat-VDS/2));
end
// 计算导通电阻的变化量
if (VDS < Vgs-Vth) begin
gm = mu*Cox*W_eff/L_eff*(2*(Vgs-Vth-VDS/2));
gmb = 0;
go = mu*Cox*W_eff/L_eff*Vdsat;
Cgso = Cox*W_eff*gamma/2;
Cgdo = Cox*W_eff*gamma/2;
Cgbo = Cox*Leff/gamma;
Cdbo = Cox*Leff/gamma;
Cgsd = Cox*L_eff/gamma;
Cgbd = 0;
end else if (VDS < vdsat) begin
gm = mu*Cox*W_eff/L_eff*(2*(Vgs-Vth-Vdsat/2));
gmb = 0;
go = mu*Cox*W_eff/L_eff*Vdsat;
Cgso = Cox*W_eff*gamma/2;
Cgdo = Cox*W_eff*gamma/2;
Cgbo = Cox*Leff/gamma;
Cdbo = Cox*Leff/gamma;
Cgsd = Cox*L_eff/gamma;
Cgbd = 0;
end else begin
gm = mu*Cox*W_eff/L_eff*(2*(Vgs-Vth-Vdsat/2));
gmb = 0;
go = 0;
Cgso = Cox*W_eff*gamma/2;
Cgdo = Cox*W_eff*gamma/2;
Cgbo = Cox*Leff/gamma;
Cdbo = Cox*Leff/gamma;
Cgsd = Cox*L_eff/gamma;
Cgbd = 0;
end
// 输出电流和阻值
ids = ID;
endmodule
```
该代码定义了一个名为 `nmos_v1` 的模块,其中包含了各种局部变量和计算公式,以及从输入端口 `drain`, `gate`, `source`, `body`, `vbs`, `vgs`, `vds` 中读取输入信号的代码。最后,该模块通过输出端口 `ids` 输出计算出的电流值。在模拟器中调用该模块时,需要传递相关参数,如晶体管的宽度、长度、氧化层厚度、衬底掺杂浓度等。