The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> '@cross' funtion opttional arguments
https://designers-guide.org/forum/YaBB.pl?num=1184970208

Message started by sylak on Jul 20th, 2007, 3:23pm

Title: '@cross' funtion opttional arguments
Post by sylak on Jul 20th, 2007, 3:23pm

I recently came across this verilogA module for analog multiplexer.. but even arfter reading up manuals I have not quite understood how the argument of @cross function works.... I understand up until the 'direction' argument.. .. I know the rest of them are simulator arguments(can recognise abstol) but not how they work ... can someone throw more light on it...???

module analog_mux(vin1, vin2, vsel, vout);
input vin1, vin2, vsel;
output vout;
electrical vin1, vin2, vsel, vout ;
parameter real vth  = 2.5;

  integer selector;
  real vout_val;

  analog begin
     selector = (V(vsel) > vth) ? 1: 0;

     @ (cross(V(vsel) - vth, 1, 1.0, vsel.potential.abstol))
        selector = 1;

     @ (cross(V(vsel) - vth, -1, 1.0, vsel.potential.abstol))
        selector = 0;

     if (selector == 1)begin
        vout_val = V(vin1);
     end
     else if (selector == 0)begin
        vout_val = V(vin2);
     end

     V(vout) <+ vout_val;
  end
endmodule

Title: Re: '@cross' funtion opttional arguments
Post by Marq Kole on Jul 23rd, 2007, 6:01am

As you noted, these additional arguments represent time and value tolerances.

The third argument is the time tolerance, meaning that the crossing is active as soon as the error between the current time and the actual crossing time is less than the third argument value. This is used to reduce the number of iterations used by the simulator to find the actual time of crossing.

The fourth argument is the expression tolerance, meaning the the crossing is active as soon as the error between the expression value at the current time and the expression value at the actual crossing time is less than the fourth argument value. The reason is the same as for the third argument. Use of the expression tolerance implies the use of the time tolerance.

This is used mainly for speeding up the simulation at the cost of accuracy so caveat emptor.

Title: Re: '@cross' funtion opttional arguments
Post by Geoffrey_Coram on Jul 27th, 2007, 6:43am


Marq Kole wrote on Jul 23rd, 2007, 6:01am:
The third argument is the time tolerance, meaning that the crossing is active as soon as the error between the current time and the actual crossing time is less than the third argument value. This is used to reduce the number of iterations used by the simulator to find the actual time of crossing.


That's not quite how I'd describe it.  The simulator goes along picking timepoints, evaluating the models, and solving the circuit.  Now, suppose a crossing occurs, such that timepoint t5 is below the threshold and timepoint t6 is above it.  By interpolation, the simulator can compute the "actual" crossing time tc (which is only accurate to within tolerances and the quality of the interpolation ...); now it compares t6 to tc and checks to see if this difference is less than the time tolerance for the cross event.  If not, then it will choose a new timepoint that is closer to tc.

(Obviously, it is trying to choose large timesteps so that the simulation finishes faster; the cross event keeps it from stepping too far between timepoints.)

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