VHDL Issue Number: 2124 Language_Version IEEE Draft VHDL-2007 (VHDL + VHPI) Classification Language Definition Problem Summary Ordering of process execution and callbacks Relevant_LRM_Sections 12.6.4.2 Related_Issues Key_Words_and_Phrases process resumption, VHPI callback Authors_Name Peter Ashenden Authors_Phone_Number +61 8 7127 0078 Authors_Fax_Number Authors_Email_Address peter@ashenden.com.au Authors_Affiliation Authors_Address1 Authors_Address2 Authors_Address3 Current Status: Submitted Superseded By: ------------------------ Date Submitted: 27 September 2007 Date Analyzed: 15 March 2008 Author of Analysis: Peter Ashenden Revision Number: 1 Date Last Revised: 15 March 2008 Description of Problem ---------------------- The LRM specifies an ordering of steps in the simulation cycle that may be overly restrictive. In 1076-2002, 12.6.4, process execution in the simulation cycle was specified as: d) For each process, P, if P is currently sensitive to a signal, S, and if an event has occurred on S in this simulation cycle, then P resumes. e) Each nonpostponed process that has resumed in the current simulation cycle is executed until it suspends. This allows interleaved execution of the resumed processes. In 1076c-2007, this was changed to incorporate execution of callbacks. The revised text in 12.6.4.2 is: 2) For each process, P, if P is currently sensitive to a signal, S, and if an event has occurred on S in this simulation cycle, then P resumes. 3) For each nonpostponed process P that has resumed in the current simulation cycle, each registered and enabled vhpiCbResume callback associated with P is executed. 4) Each nonpostponed process that has resumed in the current simulation cycle is executed until it suspends, and each registered and enabled vhpiCbTimeOut and vhpiCbRepTimeOut callback whose triggering condition is met is executed. 5) For each nonpostponed process P that has resumed in the current simulation cycle, each registered and enabled vhpiCbSuspend callback associated with P is executed. This specifies that all of the vhpiCbResume callbacks are executed, then the resumed processes and timeout callbacks are executed, then the vhpiCbSuspend callbacks are executed. The division into three steps constrains the available parallelism in a way that may not have been intended. Moreover, it may prevent certain optimizations of the way in which processes and callbacks are executed. An alternative and less constraining approach would be to allow interleaving of process and callback execution, provided, for each process that has resumed, any associated vhpiCbResume callback is executed before the process is executed and any associated vhpiCbSuspend callback is executed after the process suspends. Apart from the difference in potential parallelism between these two approaches, the difference may be exposed to the callback routines. As the LRM currently stands, the resumption callbacks are guaranteed that no processes or suspension callbacks have started execution. Similarly, the suspension callbacks are guaranteed that all resumption callbacks have completed and all processes have suspended. A VHPI program may be written in a way that depends on these assumptions. Should the ordering be relaxed, the assumptions would no longer hold. Proposed Resolution ------------------- Input is sought from the VHPI task force whether the relaxed ordering is permissible or desirable. If the VHPI task force recommends adoption of the relaxed ordering, the ISAC can revise the LRM to implement that intent. VASG-ISAC Analysis & Rationale ------------------------------ The issue presented in this report originated in the Accellera VHDL-TC LRM-SC as part of issue #150 (see https://bugzilla.mentor.com/show_bug.cgi?id=150). It was not clear whether the strict ordering implied by the current specification was intended, and so the issue was forwarded to the VHPI Task Force for advice. Their recommendation, together with some clarifying correspondence, is attached to the ISAC email at http://www.eda.org/isac/hm/0482.html. The recommendation is that the LRM be revised to allow the relaxed ordering. The relative ordering of processes and resume/suspend callbacks is specified in two places. First, in initialization (12.6.4.1 of D4.0), the relevant steps are: i) Each nonpostponed process in the model is executed until it suspends. Each registered and enabled vhpiCbSuspend callback associated with a nonpostponed process is executed. ... m) Each postponed process in the model is executed until it suspends. n) Each registered and enabled vhpiCbSuspend callback associated with a postponed process is executed. These steps can be revised as follows: i) For each nonpostponed process P in the model, the following actions occur in the indicated order: 1) The process executes until it suspends. 2) Each registered and enabled vhpiCbSuspend callback associated with P is executed. ... m) For each postponed process P in the model, the following actions occur in the indicated order: 1) The process executes until it suspends. 2) Each registered and enabled vhpiCbSuspend callback associated with P is executed. n) [old step o) renumbered] Second, in the simulation cycle (12.6.4.2 of D4.0), the relevant steps are: h) 2) For each process, P, if P is currently sensitive to a signal, S, and if an event has occurred on S in this simulation cycle, then P resumes. 3) For each nonpostponed process P that has resumed in the current simulation cycle, each registered and enabled vhpiCbResume callback associated with P is executed. 4) Each nonpostponed process that has resumed in the current simulation cycle is executed until it suspends, and each registered and enabled vhpiCbTimeOut and vhpiCbRepTimeOut callback whose triggering condition is met is executed. 5) For each nonpostponed process P that has resumed in the current simulation cycle, each registered and enabled vhpiCbSuspend callback associated with P is executed. Substeps 3) to 5) can be revised as follows: h) 3) For each nonpostponed process P that has resumed in the current simulation cycle, the following actions occur in the indicated order: -- Each registered and enabled vhpiCbResume callback associated with P is executed. -- The process executes until it suspends. -- Each registered and enabled vhpiCbSuspend callback associated with P is executed. 4) Each registered and enabled vhpiCbTimeOut and vhpiCbRepTimeOut callback whose triggering condition is met is executed. 5) [old step 6) renumbered] Further steps in the simulation cycle (12.6.4.2 of D4.0) for postponed processes are: j) 4) For each postponed process P, if P has resumed but has not been executed since its last resumption, then each registered and enabled vhpiCbResume callback associated with P is executed. 5) Each postponed process that has resumed but has not been executed since its last resumption is executed until it suspends. 6) For each postponed process P, if P has executed in the previous step, then each registered and enabled vhpiCbSuspend callback associated with P is executed. These steps can be revised as follows: j) 4) For each postponed process P, if P has resumed but has not been executed since its last resumption, the following actions occur in the indicated order: -- Each registered and enabled vhpiCbResume callback associated with P is executed. -- The process executes until it suspends. -- Each registered and enabled vhpiCbSuspend callback associated with P is executed. 5) [old step 7) renumbered] 6) [old step 8) renumbered] VASG-ISAC Recommendation for IEEE Std 1076-2002 ----------------------------------------------- Interpret the standard as though the Recommedation for Future Revisions were incorporated. VASG-ISAC Recommendation for Future Revisions --------------------------------------------- Revise 12.6.4.1 and 12.6.4.2 of P1076-2008/D4.0 as described in the preceding analysis.