Skip to content

Commit

Permalink
sc_process_handle::non_event - convert from global variable to function
Browse files Browse the repository at this point in the history
Similar to sc_event::none, sc_process_handle::non_event is a global
sc_event which holds a reference to the simulation context. Thereby
complicating reset of this context as discussed in accellera-official#8. This commit
couples the sc_process_handle::non_event with the simulation context,
thereby easing resets of the latter.

At the time of writing, it is unclear to me whether it is strictly
necessary to use different sc_event members in sc_simcontext for
sc_event::none and sc_process_handle::non_event.

Signed-off-by: Sören Tempel <[email protected]>
  • Loading branch information
nmeum committed Sep 24, 2020
1 parent 1292c02 commit 86b0514
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/sysc/kernel/sc_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ namespace sc_core {

std::vector<sc_event*> sc_process_handle::empty_event_vector;
std::vector<sc_object*> sc_process_handle::empty_object_vector;
sc_event sc_process_handle::non_event( sc_event::kernel_event );

// If m_target_p == 0.
sc_event &sc_process_handle::non_event(void) const {
sc_simcontext *sc = sc_get_curr_simcontext();
if (!sc->m_non_event)
sc->m_non_event = new sc_event(sc_event::kernel_event);
return *sc->m_non_event;
}

// Last process that was created:

Expand Down
10 changes: 5 additions & 5 deletions src/sysc/kernel/sc_process_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ class SC_API sc_process_handle {
sc_process_b* m_target_p; // Target for this object instance.

protected:
static std::vector<sc_event*> empty_event_vector; // If m_target_p == 0.
static std::vector<sc_object*> empty_object_vector; // If m_target_p == 0.
static sc_event non_event; // If m_target_p == 0.
static std::vector<sc_event*> empty_event_vector; // If m_target_p == 0.
static std::vector<sc_object*> empty_object_vector; // If m_target_p == 0.
sc_event& non_event(void) const; // If m_target_p == 0.
};

inline bool operator == (
Expand Down Expand Up @@ -401,7 +401,7 @@ inline sc_event& sc_process_handle::reset_event() const
else
{
SC_REPORT_WARNING( SC_ID_EMPTY_PROCESS_HANDLE_, "reset()");
return sc_process_handle::non_event;
return sc_process_handle::non_event();
}
}

Expand Down Expand Up @@ -478,7 +478,7 @@ inline sc_event& sc_process_handle::terminated_event()
else
{
SC_REPORT_WARNING( SC_ID_EMPTY_PROCESS_HANDLE_, "terminated_event()");
return sc_process_handle::non_event;
return sc_process_handle::non_event();
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/sysc/kernel/sc_simcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ sc_simcontext::init()
m_cor = 0;
m_reset_finder_q = 0;
m_none_event = NULL;
m_non_event = NULL;
m_in_simulator_control = false;
m_start_of_simulation_called = false;
m_end_of_simulation_called = false;
Expand Down Expand Up @@ -399,6 +400,9 @@ sc_simcontext::clean()
m_reset_finder_q = rf->m_next_p;
delete rf;
}

if (m_non_event)
delete m_non_event;
}


Expand Down
1 change: 1 addition & 0 deletions src/sysc/kernel/sc_simcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ class SC_API sc_simcontext
sc_reset_finder* m_reset_finder_q; // Q of reset finders to reconcile.

sc_event* m_none_event; // never notified event
sc_event* m_non_event; // used by sc_process_handle if m_target_p == 0

private:

Expand Down

0 comments on commit 86b0514

Please sign in to comment.