Here is my model (some inputs are not yet used):
Code:// VerilogA for Test_vco, LC2k2, veriloga
`include "constants.h"
`include "discipline.h"
module LC2k2(LCN, LCP, OUT, CTLN, CTLP, Cap_0, Cap_1, Cap_2, EN, MC, START, VDD, VSS);
output LCN;
electrical LCN;
output LCP;
electrical LCP;
output OUT;
electrical OUT;
input CTLN;
electrical CTLN;
input CTLP;
electrical CTLP;
input Cap_0;
electrical Cap_0;
input Cap_1;
electrical Cap_1;
input Cap_2;
electrical Cap_2;
input EN;
electrical EN;
input MC;
electrical MC;
input START;
electrical START;
input VDD;
electrical VDD;
input VSS;
electrical VSS;
parameter real vthn = 0.33; //Vth0 n
parameter real vthp = 0.33; //Vth0 p
parameter real trise = 130.00e-12; //Rising time(10%-90%)
parameter real tfall = 130.00e-12; //Falling time
parameter real induc = 6.90e-9; //Inductor LC
parameter real capaC = 1.41e-12; //Capacitor LC
parameter real res_ql = 11.00; //resistor L Q
real vdd ; //Power supply
real capa_p1 ; //Varicap P1
real capa_p2 ; //Varicap P2
real capa_n1 ; //Varicap N1
real capa_n2 ; //Varicap N2
real capa_pb1 ; //Varicap P1
real capa_nb2 ; //Varicap P2
real capa_nb1 ; //Varicap N1
real resneg ; //negative resistor
electrical hold ; //hidden states
electrical hold2 ; //hidden states
electrical RL ; //RL
analog begin
vdd=V(VDD);
resneg=induc/(3*capaC*res_ql);
if(analysis("static")) begin
I(hold)<+V(hold);
I(hold2)<+V(hold2);
I(RL)<+V(RL);
end
I(hold)<+ 1e-12*ddt(V(hold));
I(hold2)<+ 1e-12*ddt(V(hold2));
I(Cap_0)<+ 1e-12*ddt(V(Cap_0)); //input not yet used
I(Cap_1)<+ 1e-12*ddt(V(Cap_1)); //input not yet used
I(Cap_2)<+ 1e-12*ddt(V(Cap_2)); //input not yet used
I(EN)<+ 1e-12*ddt(V(EN)); //input not yet used
I(MC)<+ 1e-12*ddt(V(MC)); //input not yet used
I(START)<+ 1e-12*ddt(V(START)); //input not yet used
I(LCP,LCN)<+ capaC*ddt(V(LCP,LCN));
I(LCP,RL)<+ idt(V(LCP,RL),0)/induc;
I(RL,LCN)<+ V(RL,LCN)/res_ql; //Quality factor
I(LCP,LCN)<+ -(V(LCP,LCN))/resneg;
I(LCP,VSS)<+ -1e-6*(1-exp((V(LCP)-vdd+2*vthp)*100)); //diode
I(LCN,VSS)<+ -1e-6*(1-exp((V(LCN)-vdd+2*vthp)*100));
I(LCP,VSS)<+ 1e-6*(1-exp((-V(LCP)+2*vthn)*100));
I(LCN,VSS)<+ 1e-6*(1-exp((-V(LCN)+2*vthn)*100));
capa_p1 = 1E-3*(-73.2/(7.8*5.7)*ln((7.8*exp(-5.7*(V(LCP)-V(CTLP))))+11.9)+1.35*(V(LCP)-V(CTLP)))*230e-12; //varactor
capa_p2 = 1E-3*(-73.2/(7.8*5.7)*ln((7.8*exp(-5.7*(V(LCN)-V(CTLP))))+11.9)+1.35*(V(LCN)-V(CTLP)))*230e-12;
capa_n1 = 1E-3*(-73.2/(7.8*5.7)*ln((7.8*exp(-5.7*(V(CTLN)-V(LCP))))+11.9)+1.35*(V(CTLN)-V(LCP)))*230e-12;
capa_n2 = 1E-3*(-73.2/(7.8*5.7)*ln((7.8*exp(-5.7*(V(CTLN)-V(LCN))))+11.9)+1.35*(V(CTLN)-V(LCN)))*230e-12;
capa_pb1 = 0.14e-15*V(CTLP)*V(CTLP)*230e-12;
capa_nb2 = 0.5*0.14e-15*V(LCN)*V(LCN)*230e-12;
capa_nb1 = 0.5*0.14e-15*V(LCP)*V(LCP)*230e-12;
I(LCP,CTLP)<+ ddt(capa_p1);
I(LCN,CTLP)<+ ddt(capa_p2);
I(CTLN,LCP)<+ ddt(capa_n1);
I(CTLN,LCN)<+ ddt(capa_n2);
I(CTLP) <+ ddt(capa_pb1);
I(LCN) <+ ddt(capa_nb2);
I(LCP) <+ ddt(capa_nb1);
I(CTLP)<+ 10e-12*ddt(V(CTLP));
I(CTLN)<+ 10e-12*ddt(V(CTLN));
I(VDD)<+ 20e-12*ddt(V(VDD));
if((V(LCP) > 2*vthn)&&(V(hold)<0.5)) begin
I(hold2)<+ 1e3*(V(hold2)-0.001);
end else if((V(LCP) < vdd-2*vthp)&&(V(hold)>0.5)) begin
I(hold2)<+ -1e3*(1.8-V(hold2));
end
if((V(LCP) > vdd-2*vthp)&&(V(hold)<0.6)) begin
I(hold)<+ -1e3*(1-V(hold));
end else if((V(LCP) < 2*vthn)&&(V(hold)>0.4)) begin
I(hold)<+ 1e3*V(hold);
end
$bound_step(0.02/1.22e9);
V(OUT) <+ transition(V(hold2),0,trise,tfall);
end
endmodule