//VerilogA for modulator,basicmz,veriloga //With no S21 - S21 is ideal `include "constants.vams" `include "disciplines.vams" module basicmz(Ipow,Iphase,Ilam,Opow,Ophase,Olam,Vrfu,Vrfl,Vdcu,Vdcl,Gnd); parameter real VpiDC = 5 from (0:inf); parameter real VpiRF = 5 from (0:inf); parameter real insloss = 6 from [0:inf); parameter real extratio = 35 from [0:inf); parameter integer lowarmphase = -1 from [-1:1] exclude 0; parameter real dVdcdT = 0 from (-inf:inf); parameter real dVrfdT = 0 from (-inf:inf); parameter real reftem = 25 from (-273.15:inf); // parameter real eleclenupper = 40.0e-3 from (0:inf); // parameter real indexmisupper = 0.05; // parameter real mwavelossupper = 0.005 from [0:inf); // parameter real eleclenlower = 40.0e-3 from (0:inf); // parameter real indexmislower = 0.05; // parameter real mwavelosslower = 0.005 from [0:inf); // parameter real digfilterorder = 1024 from [8:4096]; parameter integer directmod = 0 from [0:1]; input Ipow,Iphase,Ilam,Vrfu,Vrfl,Vdcu,Vdcl; output Opow,Ophase,Olam; inout Gnd; electrical Ipow,Iphase,Ilam,Opow,Ophase,Olam,Vrfu,Vrfl,Vdcu,Vdcl,Gnd; branch (Vrfu,Gnd) Rrfu; branch (Vrfl,Gnd) Rrfl; branch (Vdcu,Gnd) Rdcu; branch (Vdcl,Gnd) Rdcl; real top=$temperature; real tref=273.15+reftem; real phiu,phil,yspu,yspl,eps; real Mpu1,Mpu2,Mpl1,Mpl2; real reu,imu,rel,iml,reh,imh,eh,phih,h; real Rint = 50; analog begin if (directmod == 1) begin yspu=(1+1/sqrt(pow(10,extratio/10)))/2*sqrt(2); yspl=(1-yspu)*sqrt(2); end else begin if (extratio<6.1) begin $display("Error: extratio must be greater than 6.1"); $finish; end eps = 1.0/sqrt(pow(10,extratio/10.0)); yspu = sqrt(0.5+eps); yspl = sqrt(0.5-eps); end Mpu1 = `M_PI*V(Vrfu)/(VpiRF+(top-tref)*dVrfdT); Mpu2 = `M_PI*V(Vdcu)/(VpiDC+(top-tref)*dVdcdT); Mpl1 = `M_PI*V(Vrfl)/(VpiRF+(top-tref)*dVrfdT); Mpl2 = `M_PI*V(Vdcl)/(VpiDC+(top-tref)*dVdcdT); phiu = (Mpu1+Mpu2); phil = lowarmphase*(Mpl1+Mpl2); reu = yspu*cos(phiu); imu = yspu*sin(phiu); rel = yspl*cos(phil); iml = yspl*sin(phil); reh = reu+rel; imh = imu+iml; eh = sqrt(reh*reh+imh*imh); phih = acos(reh/eh); h = 1.0/sqrt(2)*eh/pow(10,insloss/10.0); I(Rrfu) <+ V(Vrfu)/Rint; I(Rrfl) <+ V(Vrfl)/Rint; I(Rdcu) <+ V(Vdcu)/Rint; I(Rdcl) <+ V(Vdcl)/Rint; V(Opow) <+ V(Ipow)*h*h; V(Ophase) <+ V(Iphase)+phih*360.0/(2*`M_PI); V(Olam) <+ V(Ilam); end endmodule