Jump to content

HERITAGE on a SC_MODULE with THREAD


JIBI3731

Recommended Posts

Dear all,

i want to define a generic simple class for ahb master (very simple modeling) liek this

 

SC_MODULE (ahb_master) {
  sc_in<bool>   bus_grant ;       
  sc_out<bool>  bus_req;       
  sc_out<bool>  bus_release;       
  sc_out<bool>  busy;
  //------------Local Variables Here---------------------
  sc_uint<4>    count;

  void tick () {;}
   
  SC_CTOR(ahb_master) {
    SC_THREAD(tick);
  }  

}; 

then i wanted to derive daughter class with additional fields and specialised SC_THREAD, but i encountered some difficulties for the thread routine (i called it tick) 

 

struct dummy_master : ahb_master { 
dummy_master(sc_module_name name) : ahb_master(name)
  {
      cout<<"Executing new"<<endl;
      SC_THREAD(tick);
      sensitive << bus_grant.pos();
   }
   SC_HAS_PROCESS(dummy_master);
  void tick () {
    
    do
    {
        busy.write(0);                 // not busy now        
        wait(1+rand() % 10000 ,SC_PS); // wait inactive  for a random delay
        bus_req.write(1);              // request bus 
        wait();                        // wait for bus grant
        bus_release.write(0);          // not release 
        bus_req.write(0);              // clear bus request 
        busy.write(1);                 // busy now  
        wait(1+rand() % 1000 ,SC_PS); // keep the bus for a random delay
        bus_release.write(1);          // release bus
  
  } while (1);
  }  
};

 

that i instantiated this way : dummy_master master1("MASTER1");

but then i get this at run time

Warning: (W505) object already exists: MASTER1.tick. Latter declaration will be renamed to MASTER1.tick_0
 

This is not blocking for me but i guess a more elegant way to do this exists ....

Any advice ? 

Thanks 

JB

 

Link to comment
Share on other sites

You are defining a thread in ahb_master and a thread in dummy_master where both have the same name (tick) but a different C++ signature (ahb_master::tick and dummy_master::tick).

Actually defining the tick thread in ahb_master doesnt make any sense, moreover since it doesn't do anything it will be declared immediately after simulation start.

BR

Link to comment
Share on other sites

Thanks Eyck

my intention was (is) to define a standard/default  behaviour for ahb master (=> the dummy class) ie performs random bus bandwidth consumption 

then , when i need to instantiate and test a "real" ahb master , i can immediatly test the scene with an arbiter (fixed priority) , the  ahb master under test and several dummies

Regards

JB

 

Link to comment
Share on other sites

But even in this case you register the thread only in the (inheritance) leave module. You could do:
 

dummy_master(sc_module_name name) : ahb_master(name)
{
      cout<<"Executing new"<<endl;
      SC_THREAD(ahb_master::tick);
      sensitive << bus_grant.pos();
}

for the default behavior.

Link to comment
Share on other sites

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...