From f396fab26611d6107e223a6a3f41c9dff3e2ee9e Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Sun, 27 Aug 2023 21:18:53 +0200 Subject: move sources into src/ subdir --- sc_export.cc | 76 ------------------------------------------------------------ 1 file changed, 76 deletions(-) delete mode 100644 sc_export.cc (limited to 'sc_export.cc') diff --git a/sc_export.cc b/sc_export.cc deleted file mode 100644 index 7acca58..0000000 --- a/sc_export.cc +++ /dev/null @@ -1,76 +0,0 @@ -#include -#include "utils.h" - -using sc_core::sc_export; -using sc_core::sc_in; -using sc_core::sc_module; -using sc_core::sc_module_name; -using sc_core::SC_NS; -using sc_core::sc_signal; -using sc_core::sc_signal_inout_if; - -// -- CLOCK_GEN ---------------------------------------------------------------- - -struct clock_gen : public sc_module { - SC_HAS_PROCESS(clock_gen); - - explicit clock_gen(sc_module_name nm, unsigned period_ns = 20) - : sc_module(nm), m_half_period(period_ns / 2) { - assert(period_ns == m_half_period * 2); - - // Bind sc_signal (clk) against export. - p_clk(m_clk); - - SC_METHOD(tick); - } - - // Export to expose sc_signal (clk) outside this module. - sc_export> p_clk; - - private: - // Implementation of sc_signal_inout_if. - sc_signal m_clk; - - const unsigned m_half_period; - - void tick() { - m_clk.write(!m_clk.read()); - next_trigger(m_half_period, SC_NS); - } -}; - -// -- TICKTOCK ----------------------------------------------------------------- - -struct ticktock : public sc_module { - SC_HAS_PROCESS(ticktock); - - explicit ticktock(sc_module_name nm) : sc_module(nm) { - SC_METHOD(handle_clk); - sensitive << p_clk; - dont_initialize(); - } - - // In port, where sc_in is just a sc_port>. - sc_in p_clk; - - private: - void handle_clk() { - if (p_clk.read()) { - LOGM("TICK"); - } else { - LOGM("TOCK"); - } - } -}; - -// -- SC_MAIN ------------------------------------------------------------------ - -extern "C" int sc_main(int, char*[]) { - clock_gen clk("clk"); - ticktock tiktok{"listen"}; - - tiktok.p_clk(clk.p_clk); - - sc_start(200, SC_NS); - return 0; -} -- cgit v1.2.3