2016-05-12 421 views
-1

比較我有一個問題,usinf sc_time_stamp()systemC的:sc_time_stamp()與其他變量

我想要做的操作(下面寫的句子),只是在time = 20

這樣:

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

但它不起作用。

回答

0

我不知道那個函數但是......根據this page ...方法sc_timeto_string()(的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; 

對不起,我的英語不好。