quic/qbox
Loading...
Searching...
No Matches
pre_suspending_sc_support.h
1/*
2 * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef PRE_SUSPENDING_SC_SUPPORT_H
8#define PRE_SUSPENDING_SC_SUPPORT_H
9
10#ifndef SC_INCLUDE_DYNAMIC_PROCESSES
11#define SC_INCLUDE_DYNAMIC_PROCESSES
12#endif
13
14#include <systemc>
15
16#if SYSTEMC_VERSION >= 20171012
17#define SC_HAS_ASYNC_ATTACH_SUSPENDING
18#endif
19
20#if SYSTEMC_VERSION >= 20200101 // NB, this may not be the right number when it's released
21#define SC_HAS_SUSPENDING
22#endif
23
24#ifndef SC_HAS_SUSPENDING
25
26#include <map>
27#include <vector>
28#include <condition_variable>
29
30namespace gs {
32{
33 int m_suspend = 0;
34 int m_unsuspendable = 0;
35 bool m_has_suspending_channels = false;
36
37 std::map<sc_core::sc_process_b*, bool> m_unsuspendable_map;
38 std::map<sc_core::sc_process_b*, bool> m_suspend_all_req_map;
39 std::vector<const sc_core::sc_prim_channel*> m_suspending_channels;
40
41 std::condition_variable cond;
42 std::mutex mutex;
43 int wakeups = 0;
44
45 sc_core::sc_event sleeper_event; // would be convenient to be an async_event
46 void sleeper();
47
48public:
50 global_pause(const global_pause&) = delete;
51
52 // (For now) Must be in SystemC thread
53 void suspendable();
54 void unsuspendable();
55 void unsuspend_all();
56 // (For now) Must be in SystemC thread
57 void suspend_all();
58 bool attach_suspending(sc_core::sc_prim_channel* p);
59 bool detach_suspending(sc_core::sc_prim_channel* p);
60
61 void async_wakeup();
62
63 static global_pause& get();
64};
65} // namespace gs
66namespace sc_core {
67void sc_suspend_all();
68void sc_unsuspend_all();
69void sc_suspendable();
70void sc_unsuspendable();
71
72void sc_internal_async_wakeup();
73
74#ifndef SC_HAS_ASYNC_ATTACH_SUSPENDING
75/* Provide a 'global' attach/detach mechanism */
76bool async_attach_suspending(sc_core::sc_prim_channel* p);
77bool async_detach_suspending(sc_core::sc_prim_channel* p);
78#endif
79} // namespace sc_core
80
81#endif
82#endif // PRE_SUSPENDING_SC_SUPPORT_H
Definition target.h:160
Definition pre_suspending_sc_support.h:32
Tool which reads a Lua configuration file and sets parameters.
Definition biflow.cc:10