Hi Geoffrey_Coram,
After changing it to gate charge, I am getting convergence error for inverter logic.
Here is my complete code:
Code:`include "constants.vams"
`include "disciplines.vams"
module fet_cap (vd, vg, vs);
analog function real sub_threshold;
input V0, I0, S, alpha0, lambda, vol_vgs, vol_vds;
real V0, I0, S, alpha0, lambda, vol_vgs, vol_vds;
begin
sub_threshold = I0 * exp(ln(10)/S * (vol_vgs - V0)) * tanh(alpha0 * vol_vds) * (1 + lambda * vol_vds);
end
endfunction
analog function real near_threshold;
input a, b, c, d, alpha0, lambda, vol_vgs, vol_vds;
real a, b, c, d, alpha0, lambda, vol_vgs, vol_vds;
begin
near_threshold = (a * pow(vol_vgs, 3) + b * pow(vol_vgs, 2) + c * vol_vgs + d) * (tanh(alpha0 * vol_vds)) * (1 + lambda * vol_vds);
end
endfunction
analog function real gch;
input gch0, vth_ch, gamma_ch, vol_vgs;
real gch0, vth_ch, gamma_ch, vol_vgs;
begin
gch = gch0 * pow((vol_vgs - vth_ch), (1 + gamma_ch));
end
endfunction
analog function real Isat;
input beta, vth, gamma, vol_vgs;
real beta, vth, gamma, vol_vgs;
begin
Isat = beta * pow((vol_vgs - vth), (1 + gamma));
end
endfunction
analog function real alpha;
input gch0, vth_ch, gamma_ch, beta, vth, gamma, vol_vgs;
real gch0, vth_ch, gamma_ch, beta, vth, gamma, vol_vgs;
begin
alpha = gch(gch0, vth_ch, gamma_ch, vol_vgs) / Isat(beta, vth, gamma, vol_vgs);
end
endfunction
analog function real above_threshold;
input gch0, vth_ch, gamma_ch, beta, vth, gamma, lambda, vol_vgs, vol_vds;
real gch0, vth_ch, gamma_ch, beta, vth, gamma, lambda, vol_vgs, vol_vds;
begin
above_threshold = beta * pow((vol_vgs - vth), (1 + gamma)) * tanh(alpha(gch0, vth_ch, gamma_ch, beta, vth, gamma, vol_vgs) * vol_vds) * (1 + vol_vds * lambda);
end
endfunction
inout vd, vg, vs;
electrical vd, vg, vs, ig;
branch(vd, vs) vds;
branch(ig, vd) vgd;
branch(ig, vs) vgs;
branch(vg, ig) RG;
//Channel geometry
parameter W=75u, L=40u;
//subthreshold
parameter V0 = 0.1740;
parameter I0 = 4.1742e-08;
parameter S = 0.0297;
//near threshold
parameter a = 1.2520e-04;
parameter b = -4.8064e-05;
parameter c = 1.0849e-05;
parameter d = -1.0594e-06;
parameter alpha0 = 17.1562;
//above threshold
parameter beta = 3.0211e-05;
parameter vth = 0.2429;
parameter vth_ch = 0.2430;
parameter gamma = 0.1366;
parameter gamma_ch = -0.8340;
parameter gch0 = 3.8755e-05;
parameter lambda = 0.0328;
//Limits
parameter VGS_epsilon1 = 0.1820;
parameter VGS_epsilon2 = 0.3120;
real IDS_sub, IDS_near, IDS_above;
/////////////////PARAMETERS FOR CAPACITANCE
parameter R = 1;
real C, CS, CD, qd, qs;
/////////////////////////////PARAMETERS FOR CAPACITANCES END
analog begin
//Capacitance
I(RG) <+ V(RG)/R;
C = 4.29095598e-11 + 5.08332314e-11*tanh(V(vgs));
CS = W*L*C;
CD = CS;
qs = CS*V(vgs);
qd = CD*V(vgd);
I(vgs) <+ ddt(qs);
I(vgd) <+ ddt(qd);
//Capacitance end
if (V(vgs) <= VGS_epsilon1) begin
IDS_sub = sub_threshold(V0, I0, S, alpha0, lambda, V(vgs), V(vds));
IDS_near = 0;
IDS_above = 0;
end
if (V(vgs) > VGS_epsilon1 && V(vgs) < VGS_epsilon2) begin
IDS_sub = 0;
IDS_near = near_threshold(a, b, c, d, alpha0, lambda, V(vgs), V(vds));
IDS_above = 0;
end
if (V(vgs) >= VGS_epsilon2) begin
IDS_sub = 0;
IDS_near = 0;
IDS_above = above_threshold(gch0, vth_ch, gamma_ch, beta, vth, gamma, lambda, V(vds), V(vds));
end
I(vds) <+ W/L * (IDS_sub + IDS_near + IDS_above + 0.3e-9);
end
endmodule
Could you please review my code ?. The DC model is from anothe developer I just added capacitance block for transient simulation.