adds initial files for mt test
Some checks failed
SCC Test/pipeline/head There was a failure building this commit
Some checks failed
SCC Test/pipeline/head There was a failure building this commit
This commit is contained in:
44
tests/quantum_keeper_mt/top_module.h
Normal file
44
tests/quantum_keeper_mt/top_module.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#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_
|
||||
Reference in New Issue
Block a user