scc 2025.09
SystemC components library
async_event.h
1#pragma once
2#include <atomic>
3#include <sysc/communication/sc_prim_channel.h>
4#include <sysc/kernel/sc_time.h>
5#include <systemc>
6#include <thread>
7
8namespace scc {
9struct async_event : sc_core::sc_prim_channel {
10
11 async_event() = default;
12
13 async_event(char const* nm)
14 : sc_core::sc_prim_channel{nm} {}
15
16 void notify() {
17 if(std::this_thread::get_id() == id)
18 ev_.notify(sc_core::SC_ZERO_TIME);
19 else {
20 pending_update.store(true, std::memory_order_release);
21 async_request_update();
22 }
23 }
24
25 void update() override {
26 if(pending_update.exchange(false, std::memory_order_acq_rel)) {
27 ev_.notify(sc_core::SC_ZERO_TIME);
28 }
29 }
30 const sc_core::sc_event& operator()() const { return ev_; }
31 const sc_core::sc_event& event() const { return ev_; }
32
33private:
34 const std::thread::id id{std::this_thread::get_id()};
35 sc_core::sc_event ev_;
36 std::atomic<bool> pending_update{false};
37};
38} // namespace scc
SCC TLM utilities.