简体   繁体   English

SystemC灵敏度列表

[英]SystemC- sensitivity list

I have recently started learning SystemC and I have got an error with sensitivity list in "SC_METHOD". 我最近开始学习SystemC,并且在“ SC_METHOD”中的灵敏度列表中出现错误。 I am trying to implement a fifo and the error corresponds to following part of the code: 我正在尝试实现一个fifo,并且该错误对应于代码的以下部分:

 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. 如何使“ buffer_full”进程对rd_addr和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 非常感谢

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): 如上述评论中@jakub_d所建议,尝试将int变量更改为信号端口(尽管我建议使用输入而不是输出端口):

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: 使用 FIFO时,然后需要将匹配的sc_signal<int>实例绑定到以下地址端口:

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM