|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
本帖最后由 TOPEEP108 于 2023-6-15 09:49 编辑
差分信号,单个输入信号幅度大于85mV,输出波形就出错。改过SR也没有作用。不知道是为什么?
85mV不正常波形
75mV正常波形
以下是所用代码:
`include "discipline.h"
`include "constants.h"
module diff_opamp(vout_p,vout_n,vref,vin_p,vin_n,vsupply_p,vsupply_n);
input vref,vsupply_p,vsupply_n;
inout vout_p,vout_n,vin_p,vin_n;
parameter real freq_unitygain=1e6;
parameter real gain=2;
parameter rin=1e6;
parameter real ibias=0;
parameter real rout=80;
parameter real iin_max=100e-6;
parameter real slew_rate=50e6;
parameter vin_offset=0;
parameter real vsoft=0;
real gm_nom;
real vmax_in;
real vin_al,c1,r1;
electrical vout_p,vout_n,vref,vin_p,vin_n,vsupply_n,vsupply_p;
electrical cout_n,cout_p;
Analog begin
@(initial_step or initial_step("dc"))begin
c1=iin_max/(slew_rate);
gm_nom=2*3.14*freq_unitygain*c1;
r1=gain/gm_nom;
vmax_in=iin_max/gm_nom;
end
vin_al=V(vin_p,vin_n)/2+vin_offset;
//
//input stage
//
I(vref,vin_n)<+ibias;
I(vref,vin_p)<+ibias;
I(vin_p,vin_n)<+(V(vin_p,vin_n)+vin_offset)/rin;
//
//GM stage with slew rating
//
I(cout_n,vref)<+ V(cout_n,vref)/100e6;
I(cout_p,vref)<+ V(cout_p,vref)/100e6;
if(vin_al>vmax_in)begin
I(vref,cout_p)<+ iin_max;
I(vref,cout_n)<+ -iin_max;
end
else if(vin_al<-vmax_in)begin
I(vref,cout_p)<+ -iin_max;
I(vref,cout_n)<+ iin_max;
end
else begin
I(vref,cout_p)<+0.5*gm_nom*vin_al;
I(vref,cout_n)<+ -0.5*gm_nom*vin_al;
end
//
//dominate pole
//
I(vref,cout_n)<+ c1*ddt(V(vref,cout_n));
I(vref,cout_p)<+ c1*ddt(V(vref,cout_p));
I(vref,cout_n)<+ V(vref,cout_n)/r1;
I(vref,cout_p)<+ V(vref,cout_p)/r1;
//
//output stage
//
I(vref,vout_n)<+ V(cout_n,vref)/rout;
I(vout_n,vref)<+ V(vout_n,vref)/rout;
I(vref,vout_p)<+ V(cout_p,vref)/rout;
I(vout_p,vref)<+ V(vout_p,vref)/rout;
//
//soft output limiting
//
if(V(vout_p)>(V(vsupply_p)-vsoft))
I(cout_p,vref)<+gm_nom*(V(vout_p,vsupply_p)+vsoft);
else if(V(vout_p)<(V(vsupply_n)+vsoft))
I(cout_p,vref)<+gm_nom*(V(vout_p,vsupply_n)-vsoft);
if(V(vout_n)>(V(vsupply_p)-vsoft))
I(cout_n,vref)<+gm_nom*(V(vout_n,vsupply_p)+vsoft);
else if(V(vout_n)<(V(vsupply_n)+vsoft))
I(cout_n,vref)<+gm_nom*(V(vout_n,vsupply_n)-vsoft);
end
endmodule
|
|