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.
140 lines
5.4 KiB
140 lines
5.4 KiB
//VerilogA for ring,basicreso,veriloga
|
|
|
|
`include "constants.vams"
|
|
`include "disciplines.vams"
|
|
|
|
module basicreso(Ipow,Iphase,Ilam,Opow,Ophase,Olam);
|
|
parameter integer modespec = 1 from [1:2];
|
|
parameter integer alpha_use_dBm = 1 from [0:1];
|
|
parameter real l_bus = 1e-3 from [0:inf);
|
|
parameter real r_ring = 7.5e-6 from [0:inf);
|
|
parameter real attenu_bus_te = 0 from [0:inf);
|
|
parameter real attenu_bus_tm = 0 from [0:inf);
|
|
parameter real attenu_ring_te = 0 from [0:inf);
|
|
parameter real attenu_ring_tm = 0 from [0:inf);
|
|
parameter real phasedelay_bus_te = 0;
|
|
parameter real phasedelay_bus_tm = 0;
|
|
parameter real phasedelay_ring_te = 0;
|
|
parameter real phasedelay_ring_tm = 0;
|
|
parameter real neff_te = 2.6 from (0:inf);
|
|
parameter real neff_tm = 2.6 from (0:inf);
|
|
parameter real coupling_ring_te = 0.145 from [0:1];
|
|
parameter real coupling_ring_tm = 0.145 from [0:1];
|
|
parameter real reffreq = 193.1T from (0:inf);
|
|
parameter real n_gv_te = 4.2 from (0:inf);
|
|
parameter real n_gv_tm = 4.2 from (0:inf);
|
|
parameter real disper_te = 0 from [0:inf);
|
|
parameter real disper_tm = 0 from [0:inf);
|
|
//parameter real coupling_tem = 0;
|
|
|
|
input Ipow,Iphase,Ilam;
|
|
output Opow,Ophase,Olam;
|
|
electrical Ipow,Iphase,Ilam,Opow,Ophase,Olam;
|
|
|
|
real eeir,eeii,emir,emii;
|
|
real eeor,eeoi,emor,emoi;
|
|
real t11r,t11i,t12r,t12i,t21r,t21i,t22r,t22i;
|
|
real beta_te,beta_tm;
|
|
real alpha_bus_te,alpha_bus_tm,alpha_ring_te,alpha_ring_tm;
|
|
real beta_bus_ter,beta_bus_tei,beta_bus_tmr,beta_bus_tmi,beta_ring_ter,beta_ring_tei,beta_ring_tmr,beta_ring_tmi;
|
|
real t_te,t_tm,theta_ter,theta_tei,theta_tmr,theta_tmi;
|
|
real c1e1r,c1e1i,c1e2r,c1e2i,c1m1r,c1m1i,c1m2r,c1m2i;
|
|
real c11r,c11i,c11m,c12r,c12i,c12m;
|
|
real c21r,c21i,c22r,c22i;
|
|
real l_ring=2*`M_PI*r_ring;
|
|
real freq;
|
|
real iph;
|
|
|
|
analog begin
|
|
freq=`P_C/V(Ilam);
|
|
iph=V(Iphase)/360.0*2*`M_PI;
|
|
if (modespec == 1) begin
|
|
eeir=sqrt(V(Ipow))*cos(iph);
|
|
eeii=sqrt(V(Ipow))*sin(iph);
|
|
emir=0;
|
|
emii=0;
|
|
end
|
|
else if (modespec == 2) begin
|
|
eeir=0;
|
|
eeii=0;
|
|
emir=sqrt(V(Ipow))*cos(iph);
|
|
emii=sqrt(V(Ipow))*sin(iph);
|
|
end
|
|
|
|
beta_te=2*`M_PI*reffreq/`P_C*neff_te+2*`M_PI/`P_C*n_gv_te*(freq-reffreq)-`M_PI*`P_C*disper_te/pow(reffreq,2)*pow(freq-reffreq,2);
|
|
beta_tm=2*`M_PI*reffreq/`P_C*neff_tm+2*`M_PI/`P_C*n_gv_tm*(freq-reffreq)-`M_PI*`P_C*disper_tm/pow(reffreq,2)*pow(freq-reffreq,2);
|
|
if (alpha_use_dBm == 0) begin
|
|
alpha_bus_te=attenu_bus_te;
|
|
alpha_bus_tm=attenu_bus_tm;
|
|
alpha_ring_te=attenu_ring_te;
|
|
alpha_ring_tm=attenu_ring_tm;
|
|
end
|
|
else if (alpha_use_dBm == 1) begin
|
|
alpha_bus_te=attenu_bus_te/10.0*ln(10);
|
|
alpha_bus_tm=attenu_bus_tm/10.0*ln(10);
|
|
alpha_ring_te=attenu_ring_te/10.0*ln(10);
|
|
alpha_ring_tm=attenu_ring_tm/10.0*ln(10);
|
|
end
|
|
|
|
beta_bus_ter=beta_te;
|
|
beta_bus_tei=-0.5*alpha_bus_te;
|
|
beta_bus_tmr=beta_tm;
|
|
beta_bus_tmi=-0.5*alpha_bus_tm;
|
|
beta_ring_ter=beta_te;
|
|
beta_ring_tei=-0.5*alpha_ring_te;
|
|
beta_ring_tmr=beta_tm;
|
|
beta_ring_tmi=-0.5*alpha_ring_tm;
|
|
|
|
t_te=sqrt(1-coupling_ring_te);
|
|
t_tm=sqrt(1-coupling_ring_tm);
|
|
theta_ter=beta_ring_ter*l_ring-phasedelay_ring_te/360.0*`M_PI*2;
|
|
theta_tei=beta_ring_tei*l_ring;
|
|
theta_tmr=beta_ring_tmr*l_ring-phasedelay_ring_tm/360.0*`M_PI*2;
|
|
theta_tmi=beta_ring_tmi*l_ring;
|
|
|
|
c1e1r=1-t_te*exp(-theta_tei)*cos(theta_ter);
|
|
c1e1i=-t_te*exp(-theta_tei)*sin(theta_ter);
|
|
c1e2r=t_te-exp(-theta_tei)*cos(theta_ter);
|
|
c1e2i=exp(-theta_tei)*sin(theta_ter);
|
|
c11m=pow(t_te-exp(-theta_tei)*cos(theta_ter),2)+pow(exp(-theta_tei)*sin(theta_ter),2);
|
|
c11r=(c1e1r*c1e2r-c1e1i*c1e2i)/c11m;
|
|
c11i=(c1e1r*c1e2i+c1e1i*c1e2r)/c11m;
|
|
|
|
c1m1r=1-t_tm*exp(-theta_tmi)*cos(theta_tmr);
|
|
c1m1i=-t_tm*exp(-theta_tmi)*sin(theta_tmr);
|
|
c1m2r=t_tm-exp(-theta_tmi)*cos(theta_tmr);
|
|
c1m2i=exp(-theta_tmi)*sin(theta_tmr);
|
|
c12m=pow(t_tm-exp(-theta_tmi)*cos(theta_tmr),2)+pow(exp(-theta_tmi)*sin(theta_tmr),2);
|
|
c12r=(c1m1r*c1m2r-c1m1i*c1m2i)/c12m;
|
|
c12i=(c1m1r*c1m2i+c1m1i*c1m2r)/c12m;
|
|
|
|
c21r=exp(beta_bus_tei*l_bus)*cos(-beta_bus_ter*l_bus-phasedelay_bus_te/360.0*`M_PI*2);
|
|
c21i=exp(beta_bus_tei*l_bus)*sin(-beta_bus_ter*l_bus-phasedelay_bus_te/360.0*`M_PI*2);
|
|
c22r=exp(beta_bus_tmi*l_bus)*cos(-beta_bus_tmr*l_bus-phasedelay_bus_tm/360.0*`M_PI*2);
|
|
c22i=exp(beta_bus_tmi*l_bus)*sin(-beta_bus_tmr*l_bus-phasedelay_bus_tm/360.0*`M_PI*2);
|
|
|
|
t11r=c11r*c21r-c11i*c21i;
|
|
t11i=c11r*c21i+c11i*c21r;
|
|
t12r=0;
|
|
t12i=0;
|
|
t21r=0;
|
|
t21i=0;
|
|
t22r=c12r*c22r-c12i*c22i;
|
|
t22i=c12r*c22i+c12i*c22r;
|
|
|
|
eeor=t11r*eeir-t11i*eeii+t12r*emir-t12i*emii;
|
|
eeoi=t11r*eeii+t11i*eeir+t12r*emii+t12i*emir;
|
|
emor=t21r*eeir-t21i*eeii+t22r*emir-t22i*emii;
|
|
emoi=t21r*eeii+t21i*eeir+t22r*emii+t22i*emir;
|
|
|
|
if (modespec == 1) begin
|
|
V(Opow) <+ eeor*eeor+eeoi*eeoi;
|
|
V(Ophase) <+ atan2(eeoi,eeor)*360.0/(2*`M_PI);
|
|
end
|
|
else if (modespec == 2) begin
|
|
V(Opow) <+ emor*emor+emoi*emoi;
|
|
V(Ophase) <+ atan2(emoi,emor)*360.0/(2*`M_PI);
|
|
end
|
|
V(Olam) <+ V(Ilam);
|
|
end
|
|
endmodule
|
|
|