Files
SystemC-Components-Test/tests/quantum_keeper_mt/top_module.h
Eyck Jentzsch cde2d0463c
Some checks failed
SCC Test/pipeline/head There was a failure building this commit
adds initial files for mt test
2025-10-21 16:52:01 +02:00

45 lines
1.2 KiB
C++

#ifndef _TOP_MODULE_H_
#define _TOP_MODULE_H_
#include <atomic>
#include <scc/async_queue.h>
#include <scc/async_thread.h>
#include <scc/report.h>
#include <sysc/kernel/sc_initializer_function.h>
#include <tlm/scc/quantum_keeper.h>
#include <tlm>
struct top_module : ::sc_core ::sc_module {
top_module(sc_core::sc_module_name nm)
: sc_core::sc_module(nm) {
SC_THREAD(run);
}
~top_module() {}
private:
void run() {
wait(sc_core::SC_ZERO_TIME); // separate from elaboration phase
do {
quantum_keeper.reset();
core_executor.start([this]() { thread_exec(); });
wait(core_executor.thread_finish_event());
} while(!finish.load(std::memory_order_relaxed));
sc_core::sc_stop();
}
void thread_exec() {
for(auto i = 0u; i < 16; ++i) {
SCCINFO(SCMOD) << "[" << __PRETTY_FUNCTION__ << "]" << " local time " << quantum_keeper.get_local_absolute_time();
quantum_keeper.check_and_sync(1_us);
}
finish.store(true, std::memory_order_release);
}
tlm::scc::quantumkeeper_mt quantum_keeper;
std::atomic_bool finish{false};
scc::async_thread core_executor;
};
// top_module
#endif // _TOP_MODULE_H_