Applistar

5. 3. 1 sc_time

TOP > 5 SystemC入門 > 5. 3 時間 > 5. 3. 1 sc_time
  5. 3. 1 sc_time  

5. 3. 1 sc_time

sc_time は時刻あるいは時間の単位となる型です。 実装にも依りますが、内部では 少なくとも 64bit の符号無整数で表現されます。 配置する場合(instance を作る場合)には引数として、 数値と時刻の単位である を指定します。 引数無で配置(instance)する場合には SC_ZERO_TIME (シミュレーション開始時刻) と解釈されます。

記述例
   sc_time t(456, SC_NS)  ; // t = 456 ナノ秒
   sc_time t;               // 0 秒 (シミュレーション開始時刻)
   sc_time t(SC_ZERO_TIME); // 同上

一行目は t を sc_time クラスで 456 nsec の値を持ったものとします。 この sc_time クラスから数値を取出す時のために次のような変換用の関数が 用意されています。

変換用メンバ関数
uint64
value() const;

double
to_double() const;

double
to_default_time_units() const;

double
to_seconds() const;

const sc_string
to_string() const;

例えばシミュレーション時刻を fprintf で文字列にする場合、次のように記述します。

time_string *char;
value        double;
sc_time t(456, SC_NS)  ; // t = 456 ナノ秒
...
      value = fprintf ("time is %l", t.to_double());
time_string = fprintf ("time is %s", t.to_string());
  5. 3. 1 sc_time  
TOP > 5 SystemC入門 > 5. 3 時間 > 5. 3. 1 sc_time