Jump to content


  • Content count

  • Joined

  • Last visited

  1. A small example of async_request_event. It only triggers the first event and not the second one? Can anyone please explain why? #include <systemc> #include <unistd.h> #include <thread> using namespace sc_core; class ThreadSafeEventIf : public sc_interface { virtual void notify(sc_time delay = SC_ZERO_TIME) = 0; virtual const sc_event &default_event(void) const = 0; protected: virtual void update(void) = 0; }; class ThreadSafeEvent : public sc_prim_channel, public ThreadSafeEventIf { public: ThreadSafeEvent(const char *name = ""): event(name) {} void notify(sc_time delay = SC_ZERO_TIME) { this->delay = delay; async_request_update(); } const sc_event &default_event(void) const { return event; } protected: virtual void update(void) { event.notify(delay); } sc_event event; sc_time delay; }; SC_MODULE(Foo) { public: SC_CTOR(Foo) { SC_THREAD(main); SC_METHOD(eventTriggered); sensitive << event; dont_initialize(); } private: void main() { usleep(5 * 1000 * 1000); // Just for the example, event is added to pending events during this sleep wait(SC_ZERO_TIME); // Schedule (event is evaluated here) usleep(1 * 1000 * 1000); // Just for the example std::cout << "Done" << std::endl; } void eventTriggered() { std::cout << "Got event" << std::endl; std::cout << "sc_time " << sc_time_stamp() << std::endl; } public: ThreadSafeEvent event; }; void externalHostThread(void *arg, int d) { usleep(1 * 1000 * 1000); // Just for the example Foo* foo = (Foo*)(arg); foo->event.notify(sc_time(d,SC_NS)); std::cout << "Event notified from an external host thread" << std::endl; } int sc_main(int argc, char *argv[]) { Foo foo("foo"); int delay1 = 10; int delay2 = 15; std::thread t1(externalHostThread, &foo, delay1); std::thread t2(externalHostThread, &foo, delay2); sc_start(); t1.join(); t2.join(); return 0; }
  2. User Guide for systemc 2.3.2

    Hi @maehne, I am reading the book "SystemC: from the ground up". It refers to some example codes at www.EklecticAlly.com but this link is not functional anymore. It would be a great help in my SystemC adventure if someone can give me those example codes. Thanks!
  3. SystemC 2.3.2 Public Review Now Open

    Hi, I am using the flag g++ -std=c++11 but still the same issue
  4. SystemC 2.3.2 Public Review Now Open

    Hi, While running a custom library under SystemC 2.3.2, I am getting the following error. In function `__static_initialization_and_destruction_0': /sc_ver.h:179: undefined reference to `sc_core::sc_api_version_2_3_2_cxx201103L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_2_cxx201103L(sc_core::sc_writer_policy)ยด I looked into this problem and it seems like it is related to the C++ standard. before build SystemC 2.3.2 I configured it: ../configure --prefix=/users/systemc-2.3.2 In make file I am using CXXFLAGS="-DSC_CPLUSPLUS=201103L" for c++11 standard but the error is still the same.
  5. sc_thread vs pthread

    Thanks for you detailed explanation.
  6. sc_thread vs pthread

    Hi, I am new to SystemC. I have two questions. 1) Do sc_thread generates separate Linux thread for each call and what is the difference between the POSIX thread and sc_thread? 2) Why systemC has no parallelization scheme? The SystemC scheduler uses cooperative multitasking and cannot exploit fully the potential of SMP workstation.