Hello everybody,
I have a transfer function OP(s)/IP(s) = (DC_gain * (1+s/z1)) / ((1+s/p1) (1+s/p2))
Values of z1, p1and p2 will change during the simulation.
I know that I cannot use Laplace_zp filter present in verilogams because values of z1, p1 and p2 will change during simulation which is not allowed in case of Laplace_zp filter.
Another solution I tried was to launch multiple Laplace_zp filters with different z1, p1 and p2 values and pass the filter value to the output based on the z1, p1 and p2 selection. This is actually working but impact my simulation speed a lot. I need to literally launch around 40 filters which is killing my simulation speeds.
Another solution i thought of trying is to convert the transfer function to 2nd order differential equations with variable coefficients
Now my equation looks some thing like this
(1/p1*p2) d^2/dt(OP) + (p1+p2)/(p1*p2) d/dt(OP) + OP(t) = dc_gain * (1/z1) d/dt(IP) + dc_gain *IP(t) ----- (1)
OP(t) = ( dc_gain * (1/z1) d/dt(IP) + (dc_gain * IP(t))) - ( (1/p1*p2) d^2/dt(OP) + (p1+p2)/(p1*p2) d/dt(OP) ) ---- (2)
Where p1, p2 and z1 will change during the course of simulation.
Code:input [5:0] select_pole_zero_sig_i;
logic [5:0] select_pole_zero_sig_i;
electrical node1;
integer sel;
analog begin
@(initial_step) begin
sel = select_pole_zero_sig_i;
zero_real = -(2 * `M_PI * freq_z1[sel]);
pole1_real = - (2 * `M_PI * freq_p1);
pole2_real = - (2 * `M_PI * freq_p2_[sel]);
end
@(select_pole_zero_sig_i) begin
sel = select_pole_zero_sig_i;
zero_real = -(2 * `M_PI * freq_z1[sel]);
pole2_real = - (2 * `M_PI * freq_p2_[sel]);
end
// here i am converting equation (2) to verilogA
V(node1) <+ ddt(V(op, on));
V(op, on) <+ ((dc_gain * (ddt(V(ip, in))/zero_real)) + dc_gain * V(ip, in)) -
( ((1/(pole1_real*pole2_real)) * ddt(V(node1))) +
(((pole1_real + pole2_real) / (pole1_real*pole2_real)) * ddt(V(op, on))) );
end
DC has successfully converged. But convergence failed while doing Trans analysis. Can somebody help me on this?