From 3007c1983e5bbf9ef95cec8f9dbce322aec0652c Mon Sep 17 00:00:00 2001 From: Zen Date: Fri, 25 Oct 2024 09:34:51 +0800 Subject: [PATCH 1/2] Add knob to turn off auto precedence for Events --- sparta/sparta/events/EventNode.hpp | 29 +++++++++++++++++++++++++++++ sparta/sparta/simulation/Unit.hpp | 6 ++++++ 2 files changed, 35 insertions(+) diff --git a/sparta/sparta/events/EventNode.hpp b/sparta/sparta/events/EventNode.hpp index 2d165072df..5991918d9e 100644 --- a/sparta/sparta/events/EventNode.hpp +++ b/sparta/sparta/events/EventNode.hpp @@ -97,6 +97,32 @@ namespace sparta //! Get the scheduleable associated with this event node virtual Scheduleable & getScheduleable() = 0; + /** + * \brief Turn on/off auto precedence for this EvendNode + * \param participate Set to true [default] if the EventNode is to + * participate in auto precedence establishment + * in sparta::Unit + * + * In sparta::Unit, registered sparta::Event types and Ports will + * have auto precedence established between them if the user + * of sparta::Unit allows it to do so. However, this might not + * be desired for some Events that are created by the modeler + * and internally bound before the sparta::Unit performs this + * setup. Calling this method with participate set to false, + * will prevent the assertion that the EventNode is be being + * registered after port binding. + */ + virtual void participateInAutoPrecedence(bool participate) { + participate_in_auto_precedence_ = participate; + } + + //! \brief Does this EventNode participate in auto-precedence + //! establishment by sparta::Unit? + //! \return true if so, false otherwise + virtual bool doesParticipateInAutoPrecedence() const { + return participate_in_auto_precedence_; + } + private: //! Make sure the parent is an EventNodeSet @@ -104,6 +130,9 @@ namespace sparta //! Scheduling phase of this node const sparta::SchedulingPhase sched_phase_; + + //! Does this EventNode participate in auto precedence? + bool participate_in_auto_precedence_ = true; }; } diff --git a/sparta/sparta/simulation/Unit.hpp b/sparta/sparta/simulation/Unit.hpp index e90a1e98e1..64f7b64c11 100644 --- a/sparta/sparta/simulation/Unit.hpp +++ b/sparta/sparta/simulation/Unit.hpp @@ -125,6 +125,12 @@ namespace sparta { for(auto & event_node : unit_event_set_.getEvents(sparta::SchedulingPhase::Tick)) { + // This EventNode does not participate auto precedence + // between InPorts and OutPorts. + if(!event_node->doesParticipateInAutoPrecedence()) { + continue; + } + // Go through all of the registered InPorts and set these // ports to precede any events that are on the Tick phase. // This is for 0-cycle precedence only. From 5152ce953fbf7fd197f82ef488ba48cf1bd5e703 Mon Sep 17 00:00:00 2001 From: Zen Date: Wed, 30 Oct 2024 09:30:01 +0800 Subject: [PATCH 2/2] Comment tweaks --- sparta/sparta/simulation/Unit.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sparta/sparta/simulation/Unit.hpp b/sparta/sparta/simulation/Unit.hpp index 64f7b64c11..12196f765b 100644 --- a/sparta/sparta/simulation/Unit.hpp +++ b/sparta/sparta/simulation/Unit.hpp @@ -125,8 +125,7 @@ namespace sparta { for(auto & event_node : unit_event_set_.getEvents(sparta::SchedulingPhase::Tick)) { - // This EventNode does not participate auto precedence - // between InPorts and OutPorts. + // This event does not participate in auto precedence. if(!event_node->doesParticipateInAutoPrecedence()) { continue; }