Jump to content

ArjunMadhudi

Members
  • Content Count

    2
  • Joined

  • Last visited

Everything posted by ArjunMadhudi

  1. Hi, I have two threads, one thread (thread2) waits on event 'e' and other thread (thread1) notifies event 'e' at different time instances. Please find the below code, void thread1() { for(int i=0;i!=3;i++) { wait(5,SC_NS); e.notify(0,SC_NS); e.notify(3,SC_NS); e.notify(); e.notify(3,SC_NS); e.notify(4,SC_NS); std::cout<<"I am called @ "<<sc_time_stamp()<<endl; } } void thread2() { static int i=1; while(1) { wait(e); std::cout<<"e"<<i++<<" @ "<<sc_time_stamp()<<std::endl; } } As per LRM 5.10.8, I would expect the following output, I am called @ 5 ns e1 @ 5 ns I am called @ 10 ns e2 @ 10 ns I am called @ 15 ns e3 @ 15 ns But, the actual output you get when you run is, I am called @ 5 ns e1 @ 5 ns e2 @ 8 ns I am called @ 10 ns e3 @ 10 ns e4 @ 13 ns I am called @ 15 ns e5 @ 15 ns e6 @ 18 ns This appeared bit strange to me and was just curious to know of what caused this behavior. Interestingly, this happens only when you position immediate notification in the middle of series of same event notifications. But, if you place the immediate notification at the very end, then the behavior is as per the expected output above. To add, event "e2" was triggered at 8 ns because we have e.notify(3,SC_NS) and e.notify(4,SC_NS) after immediate notify and the earliest time i.e e.notify(3,SC_NS) survived. Had there been e.notify(1,SC_NS), it prints "e2 @ 6ns" and so on. Appreciate any help. Thanks.
  2. I want my method/thread to be triggered only when both clk goes high and reset goes high. (i.e Func2 is triggered when sensitive to [clk.pos() and reset]). I tried doing below but received an error : target.h:44:33: error: no match for 'operator&' in '((target*)this)->target::clk.sc_core::sc_in<bool>::pos() & ((target*)this)->target::nreset' code: SC_METHOD(func2); sensitive<<(nreset&clk.pos()); dont_initialize();
×
×
  • Create New...