milesma Posted September 11, 2013 Report Share Posted September 11, 2013 After Signal/Port binding, when signal changed, the sensitive list will cause SC_METHOD registered method to run. When I'm implementing the SystemC version, I met this warning W571. To be honest, I think this warning is correct because there is no activity. But Why there is no activity where I thought there should be is the question. The problem happens when call sc_start() the second time; I suspect that the binding between signal/port is not handing well. SC_MODULE ( MyClass ) { SC_CTOR(MyClass) { SC_METHOD(eventListener); dont_initialize(); sensitive << m_event; } void eventListener() { Event* event = m_event.read(); ... delete event; } } int sc_main (int argc, char* argv[]) { sc_signal<Event*> eventSubject; MyClass context("CONTEXT"); context.m_event(eventSubject); //bind signal to port, m_event is the port while(true) { getline(cin, in); ... eventSubject = new Event(); sc_start(); } } Quote Link to comment Share on other sites More sharing options...
milesma Posted September 12, 2013 Author Report Share Posted September 12, 2013 I've fixed the issue. In short, it is my code's problem (the delete is not at the correct place; besides, there are memory leaks)Be very careful when using pointer type as signal/port.when sc_start evaluating whether there are activities pending, it is actually comparing m_cur_val and m_new_val.In my case, the first time assigning eventSubject = new Event(...), say the address is 0x1234then it is released by "delete event;"Now: m_cur_val is pointing to "0x1234" with value 0xfeeefeee (because it is released)Now comes to "eventSubject = new Event(...)", the memory is allocated at "0x1234" as well. so m_new_val is "0x1234".since m_cur_val == m_new_val, SystemC thought there is no activity pending, so the SC_MODULE won't be invoked.How to fix:add following two lines of code: eventSubject = NULL; sc_start(); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.