aboutsummaryrefslogtreecommitdiff
path: root/src/utils/sysc.h
blob: 02ad4123d8abb59d8d556953c378dc6458d72576 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef SYSC_PLAYGROUND_SYSC
#define SYSC_PLAYGROUND_SYSC

#include <sysc/kernel/sc_module.h>
#include <sysc/kernel/sc_simcontext.h>

struct scoped_push_hierarchy {
  [[nodiscard]] explicit scoped_push_hierarchy(sc_core::sc_module& mod)
      : m_mod(mod), m_simctx(sc_core::sc_get_curr_simcontext()) {
    assert(m_simctx);
    m_simctx->hierarchy_push(&m_mod);
  }

  ~scoped_push_hierarchy() {
    const auto* top = m_simctx->hierarchy_pop();
    assert(top == &m_mod);
  }

 private:
  sc_core::sc_simcontext* m_simctx{nullptr};
  sc_core::sc_module& m_mod;
};

#endif