Verilog-A release version.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3 KiB

//VerilogA for ring,idealreso,veriloga
`include "constants.vams"
`include "disciplines.vams"
module idealreso(Ipow,);
parameter real t_abs = 0.8 from [0:1];
parameter real t_theta = 0 from (-360:360);
parameter real alpha = 7.1029e3 from (0:inf);
parameter real r = 10u from (0:inf);
parameter real neff = 3.42 from (0:inf);
input Ipow,Iphase,Ilam;
output Opow,Ophase,Olam;
electrical Ipow, Iphase, Ilam, Opow, Ophase, Olam;
real omega,L;
real a,theta;
// real T;
real tr,ti,a1,b1,c1,d1,ttr,tti;
real einr,eini,eoutr,eouti;
analog begin
omega=2*`M_PI*`P_C/V(Ilam);
L=2*`M_PI*r;
a=exp(-alpha*L/2);
theta=omega*neff*L/`P_C;
tr=t_abs*cos(t_theta);
ti=t_abs*sin(t_theta);
a1=tr-a*cos(theta);
b1=ti-a*sin(theta);
c1=1-a*tr*cos(theta)+a*-1*ti*sin(theta);
d1=-a*-1*ti*cos(theta)-a*tr*sin(theta);
ttr=(a1*c1+b1*d1)/(c1*c1+d1*d1);
tti=(b1*c1-a1*d1)/(c1*c1+d1*d1);
einr=V(Ipow)*cos(V(Iphase)/180.0*`M_PI);
eini=V(Ipow)*sin(V(Iphase)/180.0*`M_PI);
eoutr=ttr*einr-tti*eini;
eouti=tti*einr+ttr*eini;
V(Opow) <+ eoutr*eoutr+eouti*eouti;
V(Ophase) <+ atan2(eouti,eoutr)/`M_PI*180.0;
V(Olam) <+ V(Ilam);
end
endmodule