systemC:sc_time_stamp()与其他变量进行比较

时间:2016-05-12 08:21:41

标签: c++ systemc

我对usinf sc_time_stamp()

有疑问

我想在time = 20

处进行操作(写下面的句子)

这样:

1t1 = sc_time_stamp(); if (t1.to_string() == "20" ) { cout<<"Current time is "<< t1 << endl; }1

但它不起作用。

1 个答案:

答案 0 :(得分:0)

我不知道这个功能,但是......根据this page ...... to_string()的方法sc_time(我认为t1的类型)打印非时间的数值,还有打印度单位(“s”?“ms”?“ns”?)。

因此,通过示例(如果度量单位是第二个),可以工作

if ( t1.to_string() ==  "20 s" )
    cout<<"Current time is "<< t1 << endl;

但我建议(用sc_set_time_resolution()修复时间分辨率)来检查数值,而不是字符串值;如果我不好看,像

if ( t1 ==  20 )
    cout<<"Current time is "<< t1.to_string() << endl;

p.s:抱歉我的英语不好。

相关问题