From ff9b8bb838ecdfbfc1dc81038fcf3b2a87636982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Zrounba?= <6691770+clement-z@users.noreply.github.com> Date: Sat, 30 Sep 2023 23:06:01 +0200 Subject: Initial release --- src/devices/cw_source.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/devices/cw_source.cpp (limited to 'src/devices/cw_source.cpp') diff --git a/src/devices/cw_source.cpp b/src/devices/cw_source.cpp new file mode 100644 index 0000000..4be5934 --- /dev/null +++ b/src/devices/cw_source.cpp @@ -0,0 +1,45 @@ +#include "specs.h" +#include + +using std::cout; +using std::endl; + +void CWSource::runner() +{ + if (specsGlobalConfig.verbose_component_initialization) + { + cout << name() << ":" << endl; + cout << "signal on: " << m_signal_on << endl; + cout << "--> " << + (dynamic_cast(p_out.get_interface()))->name() << endl; + cout << endl; + } + + bool first_run = true; + + while (true) { + // Wait for enable signal + if (! enable.read().to_bool()) + { + // cout << name() << " waiting for enable" << endl; + wait(enable.posedge_event()); + } + // cout << name() << " was enabled" << endl; + auto s = m_signal_on; + s.getNewId(); + + // Write value to output + m_out_writer.delayedWrite(s, SC_ZERO_TIME); + cout << name() << " emitted: " << s << endl; + + // Wait for reset + if ( !first_run || !reset.read().to_bool()) + { + // cout << name() << " waiting for reset" << endl; + wait(reset.posedge_event()); + reset.write(sc_logic(0)); + wait(reset.negedge_event()); + } + // cout << name() << " was reset" << endl; + } +} -- cgit v1.2.3