From 19a5b01f0b2a4a3609a8a8ed32fba8dd376e1905 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Fri, 27 Oct 2023 00:37:29 +0200 Subject: move utils into subfolder and different files --- src/utils/sysc.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/utils/sysc.h (limited to 'src/utils/sysc.h') diff --git a/src/utils/sysc.h b/src/utils/sysc.h new file mode 100644 index 0000000..02ad412 --- /dev/null +++ b/src/utils/sysc.h @@ -0,0 +1,24 @@ +#ifndef SYSC_PLAYGROUND_SYSC +#define SYSC_PLAYGROUND_SYSC + +#include +#include + +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 -- cgit v1.2.3