The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::SysCSpartaSchedulerAdapter Class Reference

Class that "connects" Sparta to SystemC. More...

#include <SysCSpartaSchedulerAdapter.hpp>

Inheritance diagram for sparta::SysCSpartaSchedulerAdapter:
Collaboration diagram for sparta::SysCSpartaSchedulerAdapter:

Public Member Functions

 SC_HAS_PROCESS (SysCSpartaSchedulerAdapter)
 Register the process for SystemC.
 
 SysCSpartaSchedulerAdapter (Scheduler *scheduler)
 Initialized the sc_module this adapter is part of.
 
void run (Scheduler::Tick num_ticks=Scheduler::INDEFINITE)
 Run simulation – all of it including SystemC.
 
void setSystemCSimulationDone ()
 Set simulation complete on the SystemC side via the SC_Sparta_STOP_EVENT_NAME sc_event. Can be called directly if need be.
 
void registerSysCFinishQueryEvent (sparta::Scheduleable *sysc_query_event, const Scheduler::Tick interval)
 Register a sparta::Event that is used to determine if the SystemC components are finished.
 
bool wasScStopCalled () const
 Return whether the schedule called sc_stop()
 

Detailed Description

Class that "connects" Sparta to SystemC.

This class will allow a Sparta developer to interoperate a Sparta-based simulator with the SystemC kernel. The general rule of thumb is that the Sparta scheduler is either always equal to or 1 cycle ahead of the SystemC scheduler. The Sparta Scheduler will "sleep" waiting for SysC to catch up the next scheduled Sparta event.

There are two ways to stop simulation using this adapter:

  1. In SystemC, find the event SC_SPARTA_STOP_EVENT_NAME and notify it when SystemC is complete
  2. Register a sparta::Event via registerSysCFinishQueryEvent that is called by Sparta to query the SystemC side

There are some caveats to know about this adapter. See the todo.

Todo:
The Sparta scheduler is on its own SC_THREAD and is put to sleep between scheduled events. For example, if the Sparta scheduler has an event scheduled @ tick 1000, and time is currently 500, the Sparta scheduler thread will wait() for 500 ticks. However, if a SystemC component puts an event on the Sparta scheduler during this sleep window (say at 750 ticks), we do not have a mechanism to wake this thread early.

Definition at line 130 of file SysCSpartaSchedulerAdapter.hpp.

Constructor & Destructor Documentation

◆ SysCSpartaSchedulerAdapter()

sparta::SysCSpartaSchedulerAdapter::SysCSpartaSchedulerAdapter ( Scheduler scheduler)
inline

Initialized the sc_module this adapter is part of.

Definition at line 148 of file SysCSpartaSchedulerAdapter.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ registerSysCFinishQueryEvent()

void sparta::SysCSpartaSchedulerAdapter::registerSysCFinishQueryEvent ( sparta::Scheduleable sysc_query_event,
const Scheduler::Tick  interval 
)
inline

Register a sparta::Event that is used to determine if the SystemC components are finished.

Parameters
sysc_query_eventThe sparta::Event to schedule at the given interval
intervalThe time to schedule the query event

Since there are two schedulers running with this adapter, there are interesting scenarios that must be acknowledged. One scenario is that the SysC clock is finished (no events), but the Sparta Scheduler is still busy (and injecting events) into the SystemC side. Likewise, Sparta could be idle, but SystemC still running. The best way to handle this (as most SystemC users have continuous events and force simulation stop using sc_stop), is to have a Sparta Event that queries the SystemC side to see if it's truly complete. If so, then we drain Sparta and this adapter terminiates simulation.

Definition at line 225 of file SysCSpartaSchedulerAdapter.hpp.

Here is the call graph for this function:

◆ run()

void sparta::SysCSpartaSchedulerAdapter::run ( Scheduler::Tick  num_ticks = Scheduler::INDEFINITE)
inline

Run simulation – all of it including SystemC.

Parameters
num_ticksThe number of ticks to run simulation (both SysC and Sparta)

Run simulation using the Sparta command line infrastructure and world. This method is typically called from derivatives of sparta::Simulator via the runRaw_() overridden method.

Definition at line 185 of file SysCSpartaSchedulerAdapter.hpp.

◆ setSystemCSimulationDone()

void sparta::SysCSpartaSchedulerAdapter::setSystemCSimulationDone ( )
inline

Set simulation complete on the SystemC side via the SC_Sparta_STOP_EVENT_NAME sc_event. Can be called directly if need be.

Definition at line 199 of file SysCSpartaSchedulerAdapter.hpp.

◆ wasScStopCalled()

bool sparta::SysCSpartaSchedulerAdapter::wasScStopCalled ( ) const
inline

Return whether the schedule called sc_stop()

Definition at line 238 of file SysCSpartaSchedulerAdapter.hpp.


The documentation for this class was generated from the following file: