scc 2026.07
SystemC components library
quantum_keeper_st.h
1#ifndef __SCC_TLM_QUANTUMKEEPER_ST_H__
2#define __SCC_TLM_QUANTUMKEEPER_ST_H__
3
4#include <systemc>
5#include <tlm_utils/tlm_quantumkeeper.h>
6
7namespace tlm {
8namespace scc {
10//
12struct quantumkeeper_st : public tlm_utils::tlm_quantumkeeper {
13 using base = tlm_utils::tlm_quantumkeeper;
14
15 quantumkeeper_st() {}
16
17 virtual ~quantumkeeper_st() {}
18
19 void reset() override { tlm_utils::tlm_quantumkeeper::reset(); }
20
21 inline void reset(sc_core::sc_time const& t) {
22 m_local_time = t - sc_core::sc_time_stamp();
23 m_next_sync_point = t + compute_local_quantum();
24 }
25
26 inline void check_and_sync(sc_core::sc_time core_inc) {
27 // devirtualized inc()
28 m_local_time += core_inc;
29 if((sc_core::sc_time_stamp() + m_local_time) >= m_next_sync_point) {
30 // devirtualized sync()
31 ::sc_core::wait(m_local_time);
32 m_local_time = sc_core::SC_ZERO_TIME;
33 m_next_sync_point = sc_core::sc_time_stamp() + compute_local_quantum();
34 }
35 }
36 sc_core::sc_time get_local_absolute_time() const { return base::get_current_time(); }
42 inline void execute_on_sysc(std::function<void(void)> fct) { execute_on_sysc(fct, sc_core::sc_time_stamp()); }
49 inline void execute_on_sysc(std::function<void(void)>& fct, sc_core::sc_time when) {
50 if(when > sc_core::SC_ZERO_TIME)
51 wait(when);
52 fct();
53 }
54};
55} // namespace scc
56} // namespace tlm
57#endif // __SCC_TLM_QUANTUMKEEPER_ST_H__
SCC TLM utilities.
Definition axis_tlm.h:56
SystemC TLM.
Definition dmi_mgr.h:19
void execute_on_sysc(std::function< void(void)> &fct, sc_core::sc_time when)
execute the given function in the SystemC thread at a given point in time
void execute_on_sysc(std::function< void(void)> fct)
execute the given function in the SystemC thread