The Sparta Modeling Framework
|
The Sparta Scheduler can work in a SystemC environment using the sparta::SysCSpartaSchedulerAdapter.
To enable SystemC in Sparta, the cmake option COMPILE_WITH_SYSTEMC must be ON. To run SystemC tests and the TLM examples, make sure Sparta's CMake build environment can find the SystemC package during configuration. A message in the configuration output will be written if the package was found and COMPILE_WITH_SYSTEMC with set to ON:
If not, then cmake
could not find the SystemC package. This can happen if there exists an install of SystemC elsewhere on the system (like a user's home directory). Sparta can still use that install, but it must be built with the same C++ standard as Sparta (C++17 for example). First, build SystemC:
Then, configure/build Sparta again:
SYSTEMC_HOME
environment variable to the SystemC build: export SYSTEMC_HOME=/path/to/systemc-2.3.3
cmake .. -DCMAKE_BUILD_TYPE=Release -DCOMPILE_WITH_SYSTEMC=ON
The enablement message should print at this point.
To build/run the SystemC example (example/SystemC), the TLM example
directory must be found. Since the TLM examples are not part of an install, the Sparta SystemC example CMakeLists.txt file will use the environment variable SYSTEMC_HOME to locate it.
The sparta::SysCSpartaSchedulerAdapter is just that, an adapter that syncs the SystemC clock with the Sparta Scheduler. With this class, the modeler is not responsible for advancing time on the Sparta scheduler. SystemC will be doing that via SC_THREADs.
However, Sparta assumes "control" of the scheduling in that the adapter by starting the SystemC scheduler (sc_core::sc_start
) via the sparta::SysCSpartaSchedulerAdapter::run method.
The expected development using this adapter is:
sc_main
as normalrun()
on the adapterSee an example of this in sparta/test/SystemC_test.cpp
.
There are 3 other examples of how Sparta can be used in a SystemC environment in the examples/SystemC directory:
Each directory is an example of using the TLM initiator/target at_*_phase example swapping out the TLM target with a Sparta memory object and a Sparta/TLM socket adapter. These examples can only be built if the TLM examples are present in the SystemC directory. Make sure SYSTEMC_HOME
is set before running cmake
on Sparta. See above...
Caveats on using the SystemC adapters: