aboutsummaryrefslogtreecommitdiff
path: root/src/utils/sysc.h
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2023-10-27 00:37:29 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2023-10-27 00:37:29 +0200
commit19a5b01f0b2a4a3609a8a8ed32fba8dd376e1905 (patch)
tree83368b6ccc154d3da89dd191f1f24050c729a202 /src/utils/sysc.h
parenteef63c3da8e85f9f155dbc313ec8a87bafd883fd (diff)
downloadsysc-playground-19a5b01f0b2a4a3609a8a8ed32fba8dd376e1905.tar.gz
sysc-playground-19a5b01f0b2a4a3609a8a8ed32fba8dd376e1905.zip
move utils into subfolder and different files
Diffstat (limited to 'src/utils/sysc.h')
-rw-r--r--src/utils/sysc.h24
1 files changed, 24 insertions, 0 deletions
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 <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