The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 6:26pm
Pages: 1
Send Topic Print
Cross statements and simulation speed (Read 2152 times)
Bob Atwell
New Member
*
Offline



Posts: 9
Tucson, AZ
Cross statements and simulation speed
Feb 28th, 2012, 12:39pm
 
OK I am confused.  (Not an unusual condition.)
Based on what I thought I knew, Version 2 below shoud run slightly faster than Version 1 since the assignment statements occur within the cross statement.  However this seems not to be true and in my test case it actually runs very slightly slower.  Can someone explain?

Thanks,  Bob.

Version 1:
  @(cross(V(s) - 0.5))
     ;
  if (V(s) < 0.5)
        y1 = 0;
  else
        y1 = 1;
  V(q1) <+ transition( y1, td, tt );


Version 2:
  @(cross(V(s) - 0.5, +1))
     y1 = 1;
  @(cross(V(s) - 0.5, -1))
     y1 = 0;
  V(q1) <+ transition( y1, td, tt );
Back to top
 
 
View Profile   IP Logged
Frank Wiedmann
Community Fellow
*****
Offline



Posts: 678
Munich, Germany
Re: Cross statements and simulation speed
Reply #1 - Feb 29th, 2012, 12:53am
 
I guess that version 2 does two separate tests for a cross event at every timestep whereas version 1 only does one test. The test for the cross event might take considerably longer than the if statement because values from two different points in time are involved. In version 1, why don't you trigger the if statement with the cross event?
Back to top
 
 
View Profile WWW   IP Logged
Bob Atwell
New Member
*
Offline



Posts: 9
Tucson, AZ
Re: Cross statements and simulation speed
Reply #2 - Feb 29th, 2012, 5:42am
 
Thanks, that makes sense.  The real model I was working on  is a bit more complicated than this example but I think I can streamline it some.

Thanks again.
Back to top
 
 
View Profile   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.