The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 16th, 2024, 8:38pm
Pages: 1
Send Topic Print
'@cross' funtion opttional arguments (Read 2872 times)
sylak
Junior Member
**
Offline



Posts: 24
Silicon valley
'@cross' funtion opttional arguments
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
Back to top
 
 
View Profile   IP Logged
Marq Kole
Senior Member
****
Offline

Hmmm. That's
weird...

Posts: 122
Eindhoven, The Netherlands
Re: '@cross' funtion opttional arguments
Reply #1 - 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.
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: '@cross' funtion opttional arguments
Reply #2 - 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.)
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.