scc 2026.07
SystemC components library
tlm::scc::qk::global_time_keeper Struct Reference

the global time keeper, a singleton More...

#include <global_time_keeper.h>

Collaboration diagram for tlm::scc::qk::global_time_keeper:

Public Member Functions

uint64_t get_client_min_time_ticks ()
 Get the minimum time ticks of all client threads (not SystemC).
uint64_t get_client_max_time_ticks (size_t idx)
 Get the maximum time ticks a client thread is allowed to advance.
void update_client_time_ticks (size_t idx, uint64_t tick)
 updates the global time keeper with the local time ticks of a clinet thread
void schedule_task (size_t idx, std::packaged_task< sc_core::sc_time(void)> &&task, uint64_t when)
 updates the global time keeper with the local time ticks of a clinet thread and schedules a task at this new time point
uint64_t get_sc_time_ticks ()
 Get the maximum sc time ticks a client thread is allowed to advance.
void update_sc_time_ticks (uint64_t tick)
 updates the global time keeper with the local time ticks of the SystemC thread

Static Public Member Functions

static global_time_keeper & get ()
 the singleton getter

Public Attributes

const sc_core::sc_time sc_time_step = 1_ms
 the maximum timestep the simulator is allowed to do if there are no future events

Protected Member Functions

 global_time_keeper (global_time_keeper const &)=delete
 global_time_keeper (global_time_keeper &&)=delete
void start ()
size_t get_channel_index ()
void sync_local_times ()

Protected Attributes

std::atomic< bool > stop_it {false}
std::atomic< bool > update_it {false}
std::atomic_uint64_t client_min_time
std::atomic_uint64_t client_max_time
std::atomic_uint64_t sc_kernel_time
std::mutex upd_mtx
std::condition_variable update
thread_comms_channel sc_coms_channel {-1ULL}
std::deque< thread_comms_channelclient_coms_channels
rigtorp::SPSCQueue< std::tuple< size_t, uint64_t, callback_task > > pending_tasks {1024}
bool started = false

Friends

class sc_time_syncronizer

Detailed Description

the global time keeper, a singleton

The global time keeper receives actual time stamps of all client threads and calculates the max time they are alloed to advance beyond systemc. All calculations are done based on ticks which is the minimal time step a simulator can do. The SystemC thread is special in that it is time wise always the last/slowest thread.

Definition at line 22 of file global_time_keeper.h.

Constructor & Destructor Documentation

◆ ~global_time_keeper()

tlm::scc::qk::global_time_keeper::~global_time_keeper ( )
protected

Definition at line 13 of file global_time_keeper.cpp.

Member Function Documentation

◆ get()

global_time_keeper & tlm::scc::qk::global_time_keeper::get ( )
inlinestatic

the singleton getter

Returns
global_time_keeper&

Definition at line 34 of file global_time_keeper.h.

◆ get_channel_index()

size_t tlm::scc::qk::global_time_keeper::get_channel_index ( )
protected

Definition at line 25 of file global_time_keeper.cpp.

◆ get_client_max_time_ticks()

uint64_t tlm::scc::qk::global_time_keeper::get_client_max_time_ticks ( size_t idx)
inline

Get the maximum time ticks a client thread is allowed to advance.

Parameters
idxthe id of the client thread, to be obtained using get_channel_index()
Returns
uint64_t the absolute number of maximum ticks, if no new information it returns -1

Definition at line 50 of file global_time_keeper.h.

◆ get_client_min_time_ticks()

uint64_t tlm::scc::qk::global_time_keeper::get_client_min_time_ticks ( )
inline

Get the minimum time ticks of all client threads (not SystemC).

Returns
uint64_t the absolute number of ticks

Definition at line 43 of file global_time_keeper.h.

◆ get_sc_time_ticks()

uint64_t tlm::scc::qk::global_time_keeper::get_sc_time_ticks ( )
inline

Get the maximum sc time ticks a client thread is allowed to advance.

Returns
uint64_t the absolute number of ticks

Definition at line 81 of file global_time_keeper.h.

◆ schedule_task()

void tlm::scc::qk::global_time_keeper::schedule_task ( size_t idx,
std::packaged_task< sc_core::sc_time(void)> && task,
uint64_t when )
inline

updates the global time keeper with the local time ticks of a clinet thread and schedules a task at this new time point

Parameters
idxthe id of the client thread, to be obtained using get_channel_index()
tickthe absolute number of actual ticks
taskthe task to be executed in the SystemC kernel. It shall return the time it used for execution

Definition at line 70 of file global_time_keeper.h.

◆ start()

void tlm::scc::qk::global_time_keeper::start ( )
protected

Definition at line 19 of file global_time_keeper.cpp.

◆ sync_local_times()

void tlm::scc::qk::global_time_keeper::sync_local_times ( )
protected

Definition at line 34 of file global_time_keeper.cpp.

◆ update_client_time_ticks()

void tlm::scc::qk::global_time_keeper::update_client_time_ticks ( size_t idx,
uint64_t tick )
inline

updates the global time keeper with the local time ticks of a clinet thread

Parameters
idxthe id of the client thread, to be obtained using get_channel_index()
tickthe absolute number of actual ticks

Definition at line 57 of file global_time_keeper.h.

◆ update_sc_time_ticks()

void tlm::scc::qk::global_time_keeper::update_sc_time_ticks ( uint64_t tick)
inline

updates the global time keeper with the local time ticks of the SystemC thread

Parameters
tickthe absolute number of actual SystemC ticks

Definition at line 87 of file global_time_keeper.h.

◆ sc_time_syncronizer

friend class sc_time_syncronizer
friend

Definition at line 23 of file global_time_keeper.h.

Member Data Documentation

◆ client_coms_channels

std::deque<thread_comms_channel> tlm::scc::qk::global_time_keeper::client_coms_channels
protected

Definition at line 117 of file global_time_keeper.h.

◆ client_max_time

std::atomic_uint64_t tlm::scc::qk::global_time_keeper::client_max_time
protected

Definition at line 112 of file global_time_keeper.h.

◆ client_min_time

std::atomic_uint64_t tlm::scc::qk::global_time_keeper::client_min_time
protected

Definition at line 111 of file global_time_keeper.h.

◆ pending_tasks

rigtorp::SPSCQueue<std::tuple<size_t, uint64_t, callback_task> > tlm::scc::qk::global_time_keeper::pending_tasks {1024}
protected

Definition at line 118 of file global_time_keeper.h.

◆ sc_coms_channel

thread_comms_channel tlm::scc::qk::global_time_keeper::sc_coms_channel {-1ULL}
protected

Definition at line 116 of file global_time_keeper.h.

◆ sc_kernel_time

std::atomic_uint64_t tlm::scc::qk::global_time_keeper::sc_kernel_time
protected

Definition at line 113 of file global_time_keeper.h.

◆ sc_time_step

const sc_core::sc_time tlm::scc::qk::global_time_keeper::sc_time_step = 1_ms

the maximum timestep the simulator is allowed to do if there are no future events

Definition at line 28 of file global_time_keeper.h.

◆ started

bool tlm::scc::qk::global_time_keeper::started = false
protected

Definition at line 119 of file global_time_keeper.h.

◆ stop_it

std::atomic<bool> tlm::scc::qk::global_time_keeper::stop_it {false}
protected

Definition at line 109 of file global_time_keeper.h.

◆ upd_mtx

std::mutex tlm::scc::qk::global_time_keeper::upd_mtx
protected

Definition at line 114 of file global_time_keeper.h.

◆ update

std::condition_variable tlm::scc::qk::global_time_keeper::update
protected

Definition at line 115 of file global_time_keeper.h.

◆ update_it

std::atomic<bool> tlm::scc::qk::global_time_keeper::update_it {false}
protected

Definition at line 110 of file global_time_keeper.h.


The documentation for this struct was generated from the following files: