SystemC 2.3 : sync_reset_on/off

SystemC 2.3の「sync_reset_on/off」についてです。

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

SC_MODULE( hoge ){

  sc_event          ev;
  sc_process_handle t;
  int               q;

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

  void calling(){
    wait(10, SC_NS);
    ev.notify();

    wait(10, SC_NS);
    t.sync_reset_on();

    wait(10, SC_NS);
    ev.notify();

    wait(10, SC_NS);
    t.sync_reset_off();

    wait(10, SC_NS);
    ev.notify();
  }

  void target(){
     q = 0;
     while (1) {
       wait(ev);
       ++q;
       cout << sc_time_stamp();
       cout << " q = " << q << 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

10 ns q = 1
50 ns q = 1

sync_reset_on 時に qが初期化(targetプロセスの初期化)されます。