如何在SystemC中使用next_trigger()模拟输出延迟?
我一直在阅读 Stack Overflow 上的这个 upvoted 答案:https ://stackoverflow.com/a/26129960/12311164
它说将wait(delay, units);SC_THREAD替换为next_trigger(delay, units)SC_METHOD 有效。
但是当我尝试时,它不起作用。我正在尝试构建具有 2 ns 输出延迟的加法器模块。加法器输出不是 2 ns 的输出延迟,而是每 2 ns 更新一次。
设计:
#include "systemc.h"
#define WIDTH 4
SC_MODULE(adder) {
sc_in<sc_uint<WIDTH> > A, B;
sc_out<sc_uint<WIDTH> > OUT;
void add(){
sc_time t1 = sc_time_stamp();
int current_time = t1.value();
int intermediate = A.read() + B.read();
next_trigger(2, SC_NS);
OUT.write(intermediate);
cout << " SC_METHOD add triggered at "<<sc_time_stamp() <<endl;
}
SC_CTOR(adder){
SC_METHOD(add);
sensitive << A << B;
}
};
我知道如何使用 2 种技术模拟延迟:sc_event和 中SC_METHOD的wait语句SC_THREAD,但我想使用 next_trigger() 模拟延迟。我已经阅读了语言参考手册,但不知道如何去做。
在 EDA Playground 上模拟:https : //edaplayground.com/x/dFzc
我想我需要在输入改变后触发 2 NS,怎么做?