Search the Community
Showing results for tags 'sc_event'.
-
The SystemC standard says: 5.10.8 Multiple event notifications A given event shall have no more than one pending notification. If function notify is called for an event that already has a notification pending, only the notification scheduled to occur at the earliest time shall survive. The notification scheduled to occur at the later time shall be cancelled (or never be scheduled in the first place). An immediate notification is taken to occur earlier than a delta notification, and a delta notification earlier than a timed notification. This is irrespective of the order in which function notify is called. If I run the following example the simulation stops after 100000000 ps as intended, however, the memory usage of the program increases rapidly to 1GB and more. #include <iostream> #include <systemc.h> SC_MODULE(Tester) { sc_event event; uint64_t counter = 0; SC_CTOR(Tester) { SC_METHOD(process); sensitive << event; } void process() { if (counter == 100000000) sc_stop(); counter++; event.notify(1, SC_MS); event.notify(1, SC_PS); } }; int sc_main(int argc, char **argv) { Tester tester("Tester"); sc_start(); return 0; } When both event notifications are swapped the memory leak is gone. When SC_MS is replaced by SC_US, the memory usage increases a lot slower. The program was tested with the latest SystemC version from GitHub as well as SystemC 2.3.3 on the WSL with GCC 8 and GCC 6.
-
I have a class with an sc_event which should be readable and writeable through getter and setter methods. class IntWithEvent { private: sc_event _ev_wr; sc_event _ev_trigger; public: const sc_event& get_write_event() const { return _ev_wr; } const sc_event& get_trigger_event() const { return _ev_trigger; } void set_trigger_event(sc_event &ev) const { _ev_trigger = ev; // E0349 no operator "=" matches these operands } } Writing the getters was no problem. However the setter throws me an error of no matching assignment operator. Do I need to store a pointer to a sc_event and then set the pointer to the address of the parameter? It doesn't give me compile errors like this. class IntWithEvent { private: sc_event _ev_wr; sc_event *_ev_trigger; public: const sc_event& get_write_event() const { return _ev_wr; } const sc_event& get_trigger_event() const { return *_ev_trigger; } void set_trigger_event(sc_event *ev) { _ev_trigger = ev; } } I was taught to avoid pointers where I can. Is there a way to avoid the pointers?
-
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.
-
Hi all, is there any way to implement the intra assignment delay in systemC without using sc_event()? for example : in verilog we write out = #10 in1 + in2; // intra assignment delay. how would i implement the same in systemC? regards, jatin
-
Hallo, I have a SC_THREAD which has a dynamic synchronization. I use a sc_event_or_list as the wait-function argument. void notifyForGeneratedOutPix(void) { using namespace std; while (true) { sc_core::wait( m_outPixEvOrList ); //I'd like to do something like this: for(auto event : m_outPixEvOrList) { if(event.isNotified()) { cout << "@ " << setw(5) << sc_core::sc_time_stamp(); cout << " | delta cycle: " << setw(5) << sc_core::sc_delta_count(); cout << "Written values from "; this->dump(cout); cout << endl; cout << "value: "; dumpOutPixel(event); //map access with event as key } else continue; } } The events synchronize a method where I need to know which event is notified and has resumed the thread process. I haven't found a method or function to check an event if it is notified or not. The event class have this enumaration enum notify_t { NONE, DELTA, TIMED }; but I haven't found something to check that flag. Is their any way to find out if a event is notified or not? Thx *andre*