Jump to content

SC_METHOD and next_trigger() diagnostics


katang

Recommended Posts

I receive the message

Error: (E520) next_trigger() is only allowed in SC_METHODs:
        in SC_THREADs and SC_CTHREADs use wait() instead

when running my code (the relevant fragments are shown below). Any idea, what could be wrong? (what else is needed?)
 

SC_MODULE(scMemory) {
    sc_core::sc_in<bool> Clock;  

public:
    void WaitAccessing(void)
       {    next_trigger(memory_accessed); }
    void ReceivedClock(void);
  sc_event memory_accessed;    // memory access finished
};

SC_HAS_PROCESS(scMemory);
scMemory::scMemory(sc_core::sc_module_name nm, int Size )
: sc_core::sc_module(nm),  mClocks(0), Length(Size), my_state(STANDBY)
{
   SC_METHOD(ReceivedClock);
   sensitive << Clock.pos();
   SC_METHOD(WaitAccessing);
   sensitive << memory_accessed;
   dont_initialize();  // Do not receive clock during initialization
}

the error message changes to

 

Error: (E519) wait() is only allowed in SC_THREADs and SC_CTHREADs:

in SC_METHODs use next_trigger() instead

if I change the code to

   SC_THREAD(WaitAccessing);

    void WaitAccessing(void)
       {    wait(memory_accessed); }

I surely do something wrong, but surely the diagnostic messages are not on the top, too.

 

Link to comment
Share on other sites

Well, the full code of the member function calling WaitAccessing() is

    byte_t
  getByte(scCore* FromCore, SC_ADDRESS_TYPE  Address){ 
       AccessMemory(FromCore, scMemoryRead, Address, 1);  // Request a content
       WaitAccessing();
       return storage->contents[Address];
    }

Of course I set a breakpoint in the member function above (this is the only place where WaitAccessing() is called from)  and it is exactly called from this place. Concerning your namespace question:

I simple followed the example in SCFTGU, page 55

//FILE: module_name.cpp
SC_HAS_PROCESS(module_name);
module_name::module_name(
sc_module_name instname[, other_args…])
: sc_module(instname)

Is it wrong (or can be wrong)?

Link to comment
Share on other sites

Re. the error

SC_METHOD is called repeatedly (every time an element of the static sensitivity list triggers); however, SC_METHOD processes must execute in single delta cycle (zero time). Blocking methods such as wait() is illegal there. Methods such as sc_fifo::write() call wait() and are therefore also illegal. To wait 10 ns, you can do something like this:

#include <systemc>
#include <iostream>
struct Ex1 : sc_core::sc_module
{
  Ex1( void )
  {
    SC_HAS_PROCESS(Ex1);
    SC_METHOD(Method10ns);
  }
  void Method10ns( void )
  {
    next_trigger( 10, SC_NS );
    std::cout << "Now " << sc_core::sc_time_stamp() << sdt::endl;
  }
};

SC_THREAD is called only one, and therefore normally contains an infinite loop to properly model hardware. Thus the above is coded more simply as:

#include <systemc>
#include <iostream>
struct Ex1 : sc_core::sc_module
{
  Ex1( void )
  {
    SC_HAS_PROCESS(Ex1);
    SC_THREAD(Thread10ns);
  }
  void Thread10ns( void )
  {
    for(;;) {
      std::cout << "Now " << sc_core::sc_time_stamp() << sdt::endl;
      wait( 10, SC_NS );

    }
  }
};

 

Link to comment
Share on other sites

  • 1 year later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...