VHDL Issue Number: IR1.99.03 Classification: Language Definition Problem Language Version: VHDL-1076.1'99 Summary: Definition of std.standard.now returning Real and Tc Related Issues: Relevant LRM Sections: 12.6.4, 12.6.6, 12.7 Key Words and Phrases: now, simulation cycle Current Status: Analyzed 1076.1-99 Disposition: Unknown Closed (All Issues Completely Addressed) Bugs Fixed, Enhancements Outstanding (No ISAC Issues) Superseded (ISAC Issues Outstanding) Disposition Rationale: Superseded By: N/A ----------------------- Date Submitted: October 11, 2001 Author of Submission: Craig Winters Author's Affiliation: Cadence design Systems Author's Post Address: Author's Phone Number: Author's Fax Number: Author's Net Address: cwinters@cadence.com ----------------------- Date Analyzed: 4 Jul 2005 Author of Analysis: Ernst Christen Revision Number: 3 Date Last Revised: 6 Jul 2005 EC: new numbering 10 Jul 2005 EC: changed status Description of Problem ---------------------- Definition of NOW and Tc? Regarding the NOW function, what value is returned when the call occurs in an analog expression such as in the example code in section 5.4 of the LRM: Sine == Amplitude * sin ( Math_2_pi * Freq * NOW ); NOW is defined as returning Tc in section 12.7 of the LRM: The functions denoted STD.Standard.NOW is equivalent to universal_to_physical_time(Tc) (where it returns a value of type DELAY_LENGTH) and universal_to_real_time(Tc) (where it returns a value of type REAL). The value of Tc is updated in the simulation cycle, as specified in 12.6.4: A simulation cycle consists of the following steps: a) The analog solver is executed. b) The current time, Tc is set equal to Tn. ... But the analog solver uses a different variable, Ti, to represent the time at individual solution points as described in 12.6.6: when the analog solver resumes at time Tc it simultaneously resets Tn to a new value Tn' and determines a sequence of times Ti in the interval [Tc , Tn']. Tn' is the lesser of Tn and the least value in the interval [Tc , Tn] at which any signal Q'Above(E) becomes contradictory. The times Ti must include Tn'. At each time Ti the following steps occur: ... [none of these steps updates Tc] Since none of the steps modifies Tc, Tc must stay at the same value as the analog solver progresses from Tc to Tn'. However if that is the case, the expression in 5.4 (above) would not be correct, or at least not accurate. Proposed Resolution ------------------- I believe the NOW function should return Ti when in the analog solver, but I would like clarification of this issue. 1076.1-ISAC Analysis & Rationale -------------------------------- It was the language designers' intent that "now" return the current simulation time during the calculation of an ASP, not the simulation time of the last digital event. For example, q==sin(math2pi*f*now); should create a clean sine wave, with an accurate value during any ASP between two digital events no matter how far apart those events are. The values of Ti depend on the simulator time step between asp's(which is implementation dependent), but it has a well-defined value at each asp -- it is the current value of the independent variable. The issue is not restricted to "now" returning REAL but exixts also for "now" returning DELAY_LENGTH. LRM 14.2 declares two versions of impure function NOW and describes their behavior in comments: -- A function that returns universal_to_physical_time(Tc ), (see 12.6.4 -- and 12.7): impure function NOW return DELAY_LENGTH; -- A function that returns universal_to_real_time(Tc ), -- (see 12.6.4 and 12.7; it is an error if this value is not in the range -- of REAL): impure function NOW return REAL; LRM 12.7 defines the return value of both versions of NOW in terms of the kernel variable Tc of type universal_time, converted to the type indicated by the return type of NOW: The kernel process variables Tc and Tn are objects of the type Universal_Time. The functions denoted STD.Standard.NOW is equivalent to universal_to_physical_time(Tc) (where it returns a value of type DELAY_LENGTH) and universal_to_real_time(Tc) (where it returns a value of type REAL). LRM 12.6.4 gives Tc the name "current time" and defines the mechanism how Tc is updated: A simulation cycle consists of the following steps: a) The analog solver is executed. b) The current time, Tc is set equal to Tn. ... ... f) Each nonpostponed process that has resumed in the current simulation cycle is executed until it suspends. ... i) If the next simulation cycle will be a delta cycle, the remainder of this step is skipped. Otherwise, each postponed process that has resumed but has not been executed since its last resumption is executed until it suspends. ... We observe that in during step a) Tc represents the time of the last event. We define the "expression evaluation time" Te as the universal time at which an expression is evaluated. We observe that for any expression evaluated during steps f) and i) of the simulation cycle, Te = Tc. LRM 12.6.6 defines the behavior of the analog solver during step a) of the simulation cycle: when the analog solver resumes at time Tc it simultaneously resets Tn to a new value Tn' and determines a sequence of times Ti in the interval [Tc , Tn']. Tn' is the lesser of Tn and the least value in the interval [Tc , Tn] at which any signal Q'Above(E) becomes contradictory. The times Ti must include Tn'. At each time Ti the following steps occur: 1) If the value of the predefined DOMAIN signal is TIME_DOMAIN, the time domain augmentation set is determined. 2) The analog solver determines an analog solution point. 3) The analog solver evaluates the expression in each step limit specification in the model. It is an error if any such expression has a nonpositive value. LRM 12.6.6 further states: During the determination of an analog solution point, the analog solver may evaluate any characteristic expression a number of times, where each evaluation may provide different values for the quantities that appear in the characteristic expression (see 7.6 for a definition of what it means for a quantity name to appear in an expression). We observe that for expressions evaluated during step a) of the simulation cycle, Te = Ti, where Ti >= Tc. Finally, LRM 12.5.3, while defining the time domain augmentation set, states: The difference between each scalar subelement of each quantity of the form Q'INTEG and the integral over time from 0.0 to Tc, the current time, of the corresponding scalar subelement of its prefix Q is a characteristic expression of the time domain augmentation set. For quantities of the form Q'DELAYED(T) the following rules apply: - If T = 0.0, the difference between each scalar subelement of Q'DELAYED(T) and the corresponding scalar subelement of its prefix Q is a characteristic expression of the time domain augmentation set. - If T > 0.0 and Tc <= T, the difference between each scalar subelement of Q'DELAYED(T) and the value of the corresponding scalar subelement of its prefix Q at the quiescent point is a characteristic expression of the time domain augmentation set. - If T > 0.0 and Tc > T, the difference between each scalar subelement of Q'DELAYED(T) and the value of the corresponding scalar subelement of its prefix Q at time Tc - T is a characteristic expression of the time domain augmentation set. We observe that these definitions suffer from the same problem as the definition of NOW, i.e. they refer to the current time Tc instead of the expression evaluation time Te. There are two possibilities to fix the problem: 1. We define the expression evaluation time Te as the larger of Tc and Ti and change the definitions of NOW in LRM 14.2/12.7 and of the characteristic expressions in LRM 12.6.5.3 to be based on Te. 2. We update Tc each time Ti changes. The first approach would introduce significant textual differences between the language definitions of IEEE Std. 1076 and IEEE Std 1076.1, although the effect of these differences would be superficial. This seems problematic. The second approach consists of adjusting Tc each time Ti is updated (12.6.6): when the analog solver resumes at time Tc it simultaneously resets Tn to a new value Tn' and determines a sequence of times Ti in the interval [Tc, Tn']. Tn' is the lesser of Tn and the least value in the interval [Tc, Tn] at which any signal Q'Above(E) becomes contradictory. The times Ti must include Tn'. At each time Ti the following steps occur: 1. The current time Tc is set equal to Ti. 2) If the value of the predefined DOMAIN signal is TIME_DOMAIN, the time domain augmentation set is determined. 3) The analog solver determines an analog solution point. 4) The analog solver evaluates the expression in each step limit specification in the model. It is an error if any such expression has a nonpositive value. This change affects step a) of the simulation cycle only, as follows: As a consequence of updating Tc in step 1, the interval [Tc,Tn'] now also has a variable lower bound, in addition to the upper bound Tn' that already was variable. There is no conceptual difficulty with this change, as existing language already ensures that the Ti must include Tn', which in the changed definition means an interval of zero length. It may appear that the first sentence of step b) of the simulation cycle: b) The current time, Tc is set equal to Tn. is now superfluous. This is not so, as changes of Tc depend on this statement if a model has no characteristic expressions. 1076.1-ISAC Recommendation for IEEE Std 1076.1-1999 --------------------------------------------------- TBD 1076.1-ISAC Recommendation for Future Revisions ----------------------------------------------- The last portion of section 12.6.6 of the LRM is modified as follows: At each time Ti the following steps occur: 1) The current time Tc is set equal to Ti. 2) If the value of the predefined DOMAIN signal is TIME_DOMAIN, the time domain augmentation set is determined. 3) The analog solver determines an analog solution point. 4) The analog solver evaluates the expression in each step limit specification in the model. It is an error if any such expression has a nonpositive value.