#include "bistabil_d.h" BistabilD:: BistabilD (sc_module_name name): sc_module(name) { d = 0; q = 0; clk = 0; SC_THREAD(clk_thread); SC_THREAD(toggle_d_thread); SC_METHOD(update_data_method); dont_initialize(); sensitive << update_data_event; } void BistabilD::update_data_method() { d=!d; cout << sc_time_stamp() << ": D = " << d << endl; } void BistabilD::clk_thread() { for (;;) { clk=!clk; if(clk) { //wait(SC_ZERO_TIME); q = d; } cout << sc_time_stamp() << ": Q = " << q << endl; wait(0.5, SC_MS); } } void BistabilD::toggle_d_thread() { for (;;) { update_data_event.notify(); wait(1, SC_MS); } }