#ifndef _TOP_MODULE_H_ #define _TOP_MODULE_H_ #include #include #include #include #include #include #include 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_