M.X
M.X

Reputation: 195

SystemC- sensitivity list

I have recently started learning SystemC and I have got an error with sensitivity list in "SC_METHOD". I am trying to implement a fifo and the error corresponds to following part of the code:

 SC_MODULE(fifo){
      ...   
      int rd_addr, wr_addr;
      ...
      void buffer_full();
      ...
      SC_CTOR(fifo){
           SC_METHOD(buffer_full);
           sensitive << rd_addr << wr_addr;
 }
};

I get error when compiling the code and it complains about sensitivity list. The error is

fifo_simple.h:32:22: error: invalid user-defined conversion from 'int' to 'const sc_core::sc_event&' [-fpermissive]

I would appreciate if someone could let me know what is wrong with the sensitivity list. how should I make "buffer_full" process sensitive to the changes in rd_addr and wr_addr.

I also tried following syntax to see if it works with single bit sensitivity but still no success

    sensitive << rd_addr[0]

Many thanks

Upvotes: 1

Views: 3590

Answers (1)

pah
pah

Reputation: 323

You cannot be sensitive to plain integers, only to (events of) ports or plain events.

As suggested by @jakub_d in the comments above, try changing the int variables to signal ports (although I'd suggest using inputs rather than output ports):

SC_MODULE(fifo)
{
      ...
      // use ports instead of plain integers
      sc_in<int> rd_addr, wr_addr;
      ...
      void buffer_full();
      ...
      SC_CTOR(fifo)
        : rd_addr("rd_addr") // name your ports
        , wr_addr("wr_addr")
      {
           SC_METHOD(buffer_full);
           sensitive << rd_addr << wr_addr; // sensitivity works now
      }
};

When using your FIFO, you then need to bind matching sc_signal<int> instances to these address ports:

int sc_main(int, char*[]) {
  sc_signal<int> rd_addr_s("rd_addr_s"), wr_addr_s("wr_addr_s");
  fifo fifo_i("fifo_i");

  // bind signals to ports
  fifo_i.rd_addr(rd_addr_s);
  fifo_i.wr_addr(wr_addr_s);
  // ...
  return 0;
}

Upvotes: 2

Related Questions