SystemC 2.3 : disable and enable

SystemC 2.3では、Process Control 編です。
今回は、「disable & enable」についてです。

  • サンプルコード
 #include <stdio.h>
 #include <systemc.h>

SC_MODULE( hoge ){

  sc_in<bool>       clock;
  sc_process_handle t;

  SC_CTOR( hoge )
  {
    SC_THREAD( calling );
    SC_THREAD( target );
      sensitive << clock.pos();
      t = sc_get_current_process_handle();
  }

  void calling(){
    wait(20, SC_NS);
    t.disable();      // @time 20ns
    wait(20, SC_NS);
    t.enable();       // @time 40ns

    wait(110, SC_NS);
    t.disable();      // @time 150ns
    wait(200, SC_NS);
    t.enable();       // @time 350ns
  }

  void target(){
     while (1) {
       wait();
       cout << sc_time_stamp() << endl;
     }
  }

};

int sc_main(int argc, char *argv[]) {

  sc_clock clock( "clock", 100, SC_NS);

  hoge mhoge("hoge");
  mhoge.clock(clock);

  sc_start(500, sc_core::SC_NS);

  return 0;
}
  • 実行結果
$> ./main

             SystemC 2.3.0-ASI --- Dec 14 2012 21:01:01
        Copyright (c) 1996-2012 by all Contributors,
        ALL RIGHTS RESERVED

0 s
100 ns
400 ns

「disable & enable」の場合は、前回の「suspend & resume」と異なり
シミュレーション時間が変わることはありません。
その時刻に「ただ動作しない」だけになります。