The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> how to model second order differential equation with variable coefficients in ve
https://designers-guide.org/forum/YaBB.pl?num=1424200679

Message started by mahesh venkatt on Feb 17th, 2015, 11:17am

Title: how to model second order differential equation with variable coefficients in ve
Post by mahesh venkatt on Feb 17th, 2015, 11:17am

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?

Title: Re: how to model second order differential equation with variable coefficients in ve
Post by raja.cedt on Feb 18th, 2015, 5:25am

Hello,
Why cant you use SVCVS, there you can directly write transfer function and simulation takes no time.

Thanks,
Raj.

Title: Re: how to model second order differential equation with variable coefficients in ve
Post by mahesh venkatt on Feb 18th, 2015, 9:41am

Hi Raj,

I think SVCVS also works like verilogA  laplace_zp filter. we can't change zeros/poles during simulation in SVCVS and in Laplace_zp. My problem is my zero and pole will change during simulation. That is the main reason I choose to convert the transfer function from s-domain to time domain.

Thanks
Mahesh

Title: Re: how to model second order differential equation with variable coefficients in ve
Post by mahesh venkatt on Feb 20th, 2015, 1:51am

Hello Everybody,

I could manage to solve the issue that i posted. Earlier i assigned sign as negative to zero, pole1 and pole2s but i shall take them as positive values. And also using this method it is also possible to change the zero, pole and pole2 values during simulation.

Regards
Venkata Mahesh

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.