bambooflow Note

デバッグ

最終更新:

Bot(ページ名リンク)

- view
メンバー限定 登録/ログイン

SystemCのデバッグ



信号接続(バインド)の失敗について


コンパイルは通ったが、シミュレーションしようと実行したら、次のようなエラーが出た。
Error: (E109) complete binding failed: port not bound: port 'mod.port_1' (sc_in)
In file: ../../../../src/sysc/communication/sc_port.cpp:265

原因は、sc_in<>もしくはsc_out<>の接続ミス。
次のようなとき、このエラーが出力される。

  • sc_main.cpp
#include <systemc.h>
 #include "mod.h"

 int sc_main(int argc, char* argv[])
 {
     sc_signal< unsigned int > sig_a; 
     sc_signal< unsigned int > sig_b; 
     sc_signal< unsigned int > sig_c;
 
     mod mod0( "mod0" );
     mod0.a( sig_a );
     //mod0.a( sig_b );   // 接続していない
     mod0.a( sig_c );
 
     sc_start( 10, SC_US );
     return 0;
 }
 

  • mod.h
SC_MODULE( mod )
 {
     sc_in< unsigned int >   a;
     sc_in< unsigned int >   b;
     sc_in< unsigned int >   c;
        ・・・
 };
 

今回の場合は、modモジュールのbというsc_in<>ポートに対して、チャネル(sc_signal<>)が接続されていないことが原因。
modで信号の宣言が上から順に"a", "b", "c""となっているが、エラーで"port not bound: port 'mod.port_1'"と表示されていたら、上から数えて2番目の信号”b”が接続ミスだとわかる。
もし、"mod.port0"と表示されたら、1番目の信号"a"が接続ミスだとわかる。
シミュレーション開始前にあるエラボレーションのフェースで信号の接続等の確認を行う。
sc_in<>、sc_out<>を宣言したら、宙ぶらりんにしないこと。かならず、sc_signal<>もしくはsc_buffer<>と接続すること。


マクロ定義

  • Ver2.1
SYSTEMC_VERSION = 20050714
SC_RELEASE_STRING = "2.1.v1"
SC_API_VERSION_STRING sc_api_version_2_1_0
  • Ver2.2
SYSTEMC_VERSION = 20070314

sc_mainの初期表示


sc_version()  =             [[SystemC]] 2.1.v1 --- May 18 2008 17:13:45
sc_copyright()=       Copyright (c) 1996-2005 by all Contributors
                                  ALL RIGHTS RESERVED


時間表示

#include <systemc.h>
#include <iomanip>
 
#ifndef DEBUG_TIME
  #define DEBUG_TIME std::setw(8) << std::right << sc_time_stamp() << "(" << std::dec << std::setw(6) << sc_delta_count() << ") : "
#endif
 
 

  • 使用例
cout << DEBUG_TIME << "example output time" << endl;
  • 表示
    0 s(     0) : example output time


モジュール名の表示

printf("%s\n", this->name());     // 階層構造を含むオブジェクト名
printf("%s\n", this->basename()); // 自オブジェクト名のみ
 

プロセス表示

#ifndef DEBUG_PROCESS
  #if SYSTEMC_VERSION >= 20060606 // Sysc v2.2
    #define DEBUG_TIME sc_get_current_process_handle().name() << " " << this->name() << " : "
  #else
    #define DEBUG_PROCESS sc_get_curr_process_handle()->name() << " " << this->name() << " : "
  #endif
#endif
 

  • 使用例
cout << DEBUG_PROCESS" << "example output process" << endl;
  • 表示
TOP0.DUT0.thread_proc TOP.DUT0 : example output process

sc_assertの使用


・・・
 TopModule top = new TopModule( "top" );
 sc_assert( top );  // topがNULLだと異常終了となる
   ・・・
 

  • 異常終了の表示例
Fatal: (F4) assertion failed: top
In file: main.cpp:14
アボートしました

sc_report

レポートの種類

sc_severityエラーレベルは以下の4つ。
重大度 説明
SC_INFO 情報出力
SC_WARNING 警告、問題である可能性がある
SC_ERROR 重大な問題
SC_FATAL 致命的な問題でシミュレーションを終了

sc_reportによりアクセスする

使用例


try {
...
SC_REPORT_ERROR("msg_type", "msg");
...
} catch ( sc_report e ) {
std::cout << "Caught " << e.what() << std::endl;
}
 

sc_report_handler


モジュール内のレポート記述


SC_REPORT_INFO

SC_REPORT_WARNING

SC_REPORT_ERROR使用例

std::ostringstream  msg;  // log message
    msg.str ("");
 
    msg << " Not supported yet.";
    SC_REPORT_ERROR(filename, __FUNCTION__, msg.str()); 
 

SC_REPORT_FATAL使用例

SC_REPORT_FATAL( "TLM2", "not supported." );
 

タグ:

SystemC
記事メニュー
ウィキ募集バナー