SystemC 2.3:suspend and resume

SystemC 2.3では、Process Controlはかなり拡張されています。
今回は、「suspend & resume」についてです。

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

SC_MODULE( hoge ){

  sc_event          ev;
  sc_process_handle t;

  SC_CTOR( hoge )
  {
    SC_THREAD( calling );
    SC_THREAD( target );
    SC_THREAD( tick );
      t = sc_get_current_process_handle();
  }

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

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

  void tick(){
     while (1) {
       wait(100, SC_NS);
       ev.notify();
     }
  }

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

};

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

  hoge mhoge("hoge");
  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

100 ns
350 ns
450 ns

t:sc_process_handleは tickのものです。
動作としては、@350ns に再開(resume)していることが分かります。