Skip to content

Commit

Permalink
Add knob to turn off auto precedence for Events (#537)
Browse files Browse the repository at this point in the history
* Add knob to turn off auto precedence for Events

* Comment tweaks
  • Loading branch information
furuame authored Oct 30, 2024
1 parent d63b335 commit d03a7fc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
29 changes: 29 additions & 0 deletions sparta/sparta/events/EventNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,42 @@ 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
void ensureParentIsEventSet_(sparta::TreeNode* parent);

//! Scheduling phase of this node
const sparta::SchedulingPhase sched_phase_;

//! Does this EventNode participate in auto precedence?
bool participate_in_auto_precedence_ = true;
};
}

Expand Down
5 changes: 5 additions & 0 deletions sparta/sparta/simulation/Unit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ namespace sparta {

for(auto & event_node : unit_event_set_.getEvents(sparta::SchedulingPhase::Tick))
{
// This event does not participate in auto precedence.
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.
Expand Down

0 comments on commit d03a7fc

Please sign in to comment.