quic/qbox
Loading...
Searching...
No Matches
qkmulti-adaptive.h
1/*
2 * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
3 * Author: GreenSocs 2022
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#ifndef QKMULTI_ADAPTIVE_QUANTUM_H
9#define QKMULTI_ADAPTIVE_QUANTUM_H
10
11#include <qkmultithread.h>
12
13namespace gs {
15{
16 // Only allow up to one quantum from the current sc_time
17 // In accordance with TLM-2
18 virtual sc_core::sc_time time_to_sync() override
19 {
20 if (status != RUNNING) return sc_core::SC_ZERO_TIME;
21
22 sc_core::sc_time m_quantum = tlm_utils::tlm_quantumkeeper::get_global_quantum();
23 sc_core::sc_time sct = sc_core::sc_time_stamp();
24 sc_core::sc_time rmt = get_current_time();
25 if (rmt <= sct) {
26 return m_quantum * 2;
27 }
28 if (rmt > sct && rmt <= sct + m_quantum) {
29 return m_quantum * 1;
30 }
31 if (rmt > sct + m_quantum && rmt <= sct + (2 * m_quantum)) {
32 return m_quantum * 0.5;
33 }
34 return sc_core::SC_ZERO_TIME;
35 }
36
37 // Don't sync until we are on the quantum boundry (as expected by TLM-2)
38 virtual bool need_sync() override { return time_to_sync() == sc_core::SC_ZERO_TIME; }
39};
40} // namespace gs
41#endif
Definition target.h:160
Definition qkmulti-adaptive.h:15
Definition qkmultithread.h:24
Tool which reads a Lua configuration file and sets parameters.
Definition biflow.cc:10