FC2カウンター FPGAの部屋 Verilatorを試してみる2(C++モード2:モジュール内部信号の観測)
FC2ブログ

FPGAやCPLDの話題やFPGA用のツールの話題などです。 マニアックです。 日記も書きます。

FPGAの部屋

FPGAの部屋の有用と思われるコンテンツのまとめサイトを作りました。Xilinx ISEの初心者の方には、FPGAリテラシーおよびチュートリアルのページをお勧めいたします。

Verilatorを試してみる2(C++モード2:モジュール内部信号の観測)

Verilatorを試してみる1(C++モード1)”でC++のテストベンチでのVerilogファイルのシミュレーションができたが、モジュールの入力、出力信号を見ただけである。今回は、モジュール内部信号を見てみる。

verilator --cc -Wno-lint dice_state_machine.v --exe dsm_test.cpp


上のコマンドで作られたobj_dirフォルダのファイルを見てみる。
Verilator_8_110523.png

このファイルの意味は、Verilator ManualのFILESに書いてある。
そのうちのVdice_state_machine.h に注目してみよう。一部を引用する。

VL_MODULE(Vdice_state_machine) {
  public:
    // CELLS

    // Public to allow access to /*verilator_public*/ items;
    // otherwise the application code can consider these internals.
    
    // PORTS

    // The application code writes and reads these signals to

    // propagate new values into/out from the Verilated model.
    VL_IN8(clk,0,0);
    VL_IN8(reset_sw,0,0);
    VL_IN8(roll,0,0);
    VL_IN8(roll_ena,0,0);
    VL_OUT8(spots,2,0);
    //char    __VpadToAlign5[3];
    
    // LOCAL SIGNALS

    // Internals; generally not touched by application code

    VL_SIG8(v__DOT__current_state,5,0);
    VL_SIG8(v__DOT__spots_node,2,0);
    //char    __VpadToAlign14[2];


VL_IN8()やVL_OUT8()には入力信号、出力信号が定義されている。
VL_SIG8(v__DOT__current_state,5,0);で内部信号のcurrent_state が定義されているようだ。これならば、テストベンチにtop->v__DOT__current_state で参照すれば、現在のステートのコードを表示することができるのではないだろうか?
そこで、dsm_test.cppのprintfを下のように書きなおした。つまり、ステートマシンのステート値の表示を追加した。

printf("Time %d : clk = %d roll_ena = %d spots = %d current_state = %.2x\n", main_time, top->clk, top->roll_ena, top->spots, top->v__DOT__current_state);


これで、”Verilatorを試してみる1(C++モード1)”と同様にコンパイル、make、実行ファイルの実行をした。その結果、current_stateの値を表示することができた。
Verilator_9_110523.png

シミュレーション結果のprintfの出力を下に示す。

Time 0 : clk = 1 roll_ena = 0 spots = 1 current_state = 01
Time 1 : clk = 1 roll_ena = 0 spots = 1 current_state = 01
Time 2 : clk = 1 roll_ena = 0 spots = 1 current_state = 01
Time 3 : clk = 1 roll_ena = 0 spots = 1 current_state = 01
Time 4 : clk = 1 roll_ena = 0 spots = 1 current_state = 01
Time 5 : clk = 0 roll_ena = 0 spots = 1 current_state = 01
Time 6 : clk = 0 roll_ena = 0 spots = 1 current_state = 01
Time 7 : clk = 0 roll_ena = 0 spots = 1 current_state = 01
Time 8 : clk = 0 roll_ena = 0 spots = 1 current_state = 01
Time 9 : clk = 0 roll_ena = 0 spots = 1 current_state = 01
Time 10 : clk = 1 roll_ena = 0 spots = 1 current_state = 01
Time 11 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 12 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 13 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 14 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 15 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 16 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 17 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 18 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 19 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 20 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 21 : clk = 1 roll_ena = 0 spots = 1 current_state = 01
Time 22 : clk = 1 roll_ena = 0 spots = 1 current_state = 01
Time 23 : clk = 1 roll_ena = 0 spots = 1 current_state = 01
Time 24 : clk = 1 roll_ena = 0 spots = 1 current_state = 01
Time 25 : clk = 0 roll_ena = 0 spots = 1 current_state = 01
Time 26 : clk = 0 roll_ena = 0 spots = 1 current_state = 01
Time 27 : clk = 0 roll_ena = 0 spots = 1 current_state = 01
Time 28 : clk = 0 roll_ena = 0 spots = 1 current_state = 01
Time 29 : clk = 0 roll_ena = 0 spots = 1 current_state = 01
Time 30 : clk = 1 roll_ena = 0 spots = 1 current_state = 01
Time 31 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 32 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 33 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 34 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 35 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 36 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 37 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 38 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 39 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 40 : clk = 1 roll_ena = 1 spots = 1 current_state = 02
Time 41 : clk = 1 roll_ena = 0 spots = 1 current_state = 02
Time 42 : clk = 1 roll_ena = 0 spots = 1 current_state = 02
Time 43 : clk = 1 roll_ena = 0 spots = 1 current_state = 02
Time 44 : clk = 1 roll_ena = 0 spots = 1 current_state = 02
Time 45 : clk = 0 roll_ena = 0 spots = 1 current_state = 02
Time 46 : clk = 0 roll_ena = 0 spots = 1 current_state = 02
Time 47 : clk = 0 roll_ena = 0 spots = 1 current_state = 02
Time 48 : clk = 0 roll_ena = 0 spots = 1 current_state = 02
Time 49 : clk = 0 roll_ena = 0 spots = 1 current_state = 02
Time 50 : clk = 1 roll_ena = 0 spots = 2 current_state = 02
Time 51 : clk = 1 roll_ena = 1 spots = 2 current_state = 02
Time 52 : clk = 1 roll_ena = 1 spots = 2 current_state = 02
Time 53 : clk = 1 roll_ena = 1 spots = 2 current_state = 02
Time 54 : clk = 1 roll_ena = 1 spots = 2 current_state = 02
Time 55 : clk = 0 roll_ena = 1 spots = 2 current_state = 02
Time 56 : clk = 0 roll_ena = 1 spots = 2 current_state = 02
Time 57 : clk = 0 roll_ena = 1 spots = 2 current_state = 02
Time 58 : clk = 0 roll_ena = 1 spots = 2 current_state = 02
Time 59 : clk = 0 roll_ena = 1 spots = 2 current_state = 02
Time 60 : clk = 1 roll_ena = 1 spots = 2 current_state = 04
Time 61 : clk = 1 roll_ena = 0 spots = 2 current_state = 04
Time 62 : clk = 1 roll_ena = 0 spots = 2 current_state = 04
Time 63 : clk = 1 roll_ena = 0 spots = 2 current_state = 04
Time 64 : clk = 1 roll_ena = 0 spots = 2 current_state = 04
Time 65 : clk = 0 roll_ena = 0 spots = 2 current_state = 04
Time 66 : clk = 0 roll_ena = 0 spots = 2 current_state = 04
Time 67 : clk = 0 roll_ena = 0 spots = 2 current_state = 04
Time 68 : clk = 0 roll_ena = 0 spots = 2 current_state = 04
Time 69 : clk = 0 roll_ena = 0 spots = 2 current_state = 04
Time 70 : clk = 1 roll_ena = 0 spots = 3 current_state = 04
Time 71 : clk = 1 roll_ena = 1 spots = 3 current_state = 04
Time 72 : clk = 1 roll_ena = 1 spots = 3 current_state = 04
Time 73 : clk = 1 roll_ena = 1 spots = 3 current_state = 04
Time 74 : clk = 1 roll_ena = 1 spots = 3 current_state = 04
Time 75 : clk = 0 roll_ena = 1 spots = 3 current_state = 04
Time 76 : clk = 0 roll_ena = 1 spots = 3 current_state = 04
Time 77 : clk = 0 roll_ena = 1 spots = 3 current_state = 04
Time 78 : clk = 0 roll_ena = 1 spots = 3 current_state = 04
Time 79 : clk = 0 roll_ena = 1 spots = 3 current_state = 04
Time 80 : clk = 1 roll_ena = 1 spots = 3 current_state = 08
Time 81 : clk = 1 roll_ena = 0 spots = 3 current_state = 08
Time 82 : clk = 1 roll_ena = 0 spots = 3 current_state = 08
Time 83 : clk = 1 roll_ena = 0 spots = 3 current_state = 08
Time 84 : clk = 1 roll_ena = 0 spots = 3 current_state = 08
Time 85 : clk = 0 roll_ena = 0 spots = 3 current_state = 08
Time 86 : clk = 0 roll_ena = 0 spots = 3 current_state = 08
Time 87 : clk = 0 roll_ena = 0 spots = 3 current_state = 08
Time 88 : clk = 0 roll_ena = 0 spots = 3 current_state = 08
Time 89 : clk = 0 roll_ena = 0 spots = 3 current_state = 08
Time 90 : clk = 1 roll_ena = 0 spots = 4 current_state = 08
Time 91 : clk = 1 roll_ena = 1 spots = 4 current_state = 08
Time 92 : clk = 1 roll_ena = 1 spots = 4 current_state = 08
Time 93 : clk = 1 roll_ena = 1 spots = 4 current_state = 08
Time 94 : clk = 1 roll_ena = 1 spots = 4 current_state = 08
Time 95 : clk = 0 roll_ena = 1 spots = 4 current_state = 08
Time 96 : clk = 0 roll_ena = 1 spots = 4 current_state = 08
Time 97 : clk = 0 roll_ena = 1 spots = 4 current_state = 08
Time 98 : clk = 0 roll_ena = 1 spots = 4 current_state = 08
Time 99 : clk = 0 roll_ena = 1 spots = 4 current_state = 08
Time 100 : clk = 1 roll_ena = 1 spots = 4 current_state = 10
Time 101 : clk = 1 roll_ena = 0 spots = 4 current_state = 10
Time 102 : clk = 1 roll_ena = 0 spots = 4 current_state = 10
Time 103 : clk = 1 roll_ena = 0 spots = 4 current_state = 10
Time 104 : clk = 1 roll_ena = 0 spots = 4 current_state = 10
Time 105 : clk = 0 roll_ena = 0 spots = 4 current_state = 10
Time 106 : clk = 0 roll_ena = 0 spots = 4 current_state = 10
Time 107 : clk = 0 roll_ena = 0 spots = 4 current_state = 10
Time 108 : clk = 0 roll_ena = 0 spots = 4 current_state = 10
Time 109 : clk = 0 roll_ena = 0 spots = 4 current_state = 10
Time 110 : clk = 1 roll_ena = 0 spots = 5 current_state = 10
Time 111 : clk = 1 roll_ena = 1 spots = 5 current_state = 10
Time 112 : clk = 1 roll_ena = 1 spots = 5 current_state = 10
Time 113 : clk = 1 roll_ena = 1 spots = 5 current_state = 10
Time 114 : clk = 1 roll_ena = 1 spots = 5 current_state = 10
Time 115 : clk = 0 roll_ena = 1 spots = 5 current_state = 10
Time 116 : clk = 0 roll_ena = 1 spots = 5 current_state = 10
Time 117 : clk = 0 roll_ena = 1 spots = 5 current_state = 10
Time 118 : clk = 0 roll_ena = 1 spots = 5 current_state = 10
Time 119 : clk = 0 roll_ena = 1 spots = 5 current_state = 10
Time 120 : clk = 1 roll_ena = 1 spots = 5 current_state = 20
Time 121 : clk = 1 roll_ena = 0 spots = 5 current_state = 20
Time 122 : clk = 1 roll_ena = 0 spots = 5 current_state = 20
Time 123 : clk = 1 roll_ena = 0 spots = 5 current_state = 20
Time 124 : clk = 1 roll_ena = 0 spots = 5 current_state = 20
Time 125 : clk = 0 roll_ena = 0 spots = 5 current_state = 20
Time 126 : clk = 0 roll_ena = 0 spots = 5 current_state = 20
Time 127 : clk = 0 roll_ena = 0 spots = 5 current_state = 20
Time 128 : clk = 0 roll_ena = 0 spots = 5 current_state = 20
Time 129 : clk = 0 roll_ena = 0 spots = 5 current_state = 20
Time 130 : clk = 1 roll_ena = 0 spots = 6 current_state = 20
Time 131 : clk = 1 roll_ena = 1 spots = 6 current_state = 20
Time 132 : clk = 1 roll_ena = 1 spots = 6 current_state = 20
Time 133 : clk = 1 roll_ena = 1 spots = 6 current_state = 20
Time 134 : clk = 1 roll_ena = 1 spots = 6 current_state = 20
Time 135 : clk = 0 roll_ena = 1 spots = 6 current_state = 20
Time 136 : clk = 0 roll_ena = 1 spots = 6 current_state = 20
Time 137 : clk = 0 roll_ena = 1 spots = 6 current_state = 20
Time 138 : clk = 0 roll_ena = 1 spots = 6 current_state = 20
Time 139 : clk = 0 roll_ena = 1 spots = 6 current_state = 20
Time 140 : clk = 1 roll_ena = 1 spots = 6 current_state = 01
Time 141 : clk = 1 roll_ena = 0 spots = 6 current_state = 01
Time 142 : clk = 1 roll_ena = 0 spots = 6 current_state = 01
Time 143 : clk = 1 roll_ena = 0 spots = 6 current_state = 01
Time 144 : clk = 1 roll_ena = 0 spots = 6 current_state = 01
Time 145 : clk = 0 roll_ena = 0 spots = 6 current_state = 01
Time 146 : clk = 0 roll_ena = 0 spots = 6 current_state = 01
Time 147 : clk = 0 roll_ena = 0 spots = 6 current_state = 01
Time 148 : clk = 0 roll_ena = 0 spots = 6 current_state = 01
Time 149 : clk = 0 roll_ena = 0 spots = 6 current_state = 01
Time 150 : clk = 1 roll_ena = 0 spots = 1 current_state = 01
Time 151 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 152 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 153 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 154 : clk = 1 roll_ena = 1 spots = 1 current_state = 01
Time 155 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 156 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 157 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 158 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 159 : clk = 0 roll_ena = 1 spots = 1 current_state = 01
Time 160 : clk = 1 roll_ena = 1 spots = 1 current_state = 02
Time 161 : clk = 1 roll_ena = 0 spots = 1 current_state = 02
Time 162 : clk = 1 roll_ena = 0 spots = 1 current_state = 02
Time 163 : clk = 1 roll_ena = 0 spots = 1 current_state = 02
Time 164 : clk = 1 roll_ena = 0 spots = 1 current_state = 02
Time 165 : clk = 0 roll_ena = 0 spots = 1 current_state = 02
Time 166 : clk = 0 roll_ena = 0 spots = 1 current_state = 02
Time 167 : clk = 0 roll_ena = 0 spots = 1 current_state = 02
Time 168 : clk = 0 roll_ena = 0 spots = 1 current_state = 02
Time 169 : clk = 0 roll_ena = 0 spots = 1 current_state = 02
Time 170 : clk = 1 roll_ena = 0 spots = 2 current_state = 02
Time 171 : clk = 1 roll_ena = 1 spots = 2 current_state = 02
Time 172 : clk = 1 roll_ena = 1 spots = 2 current_state = 02
Time 173 : clk = 1 roll_ena = 1 spots = 2 current_state = 02
Time 174 : clk = 1 roll_ena = 1 spots = 2 current_state = 02
Time 175 : clk = 0 roll_ena = 1 spots = 2 current_state = 02
Time 176 : clk = 0 roll_ena = 1 spots = 2 current_state = 02
Time 177 : clk = 0 roll_ena = 1 spots = 2 current_state = 02
Time 178 : clk = 0 roll_ena = 1 spots = 2 current_state = 02
Time 179 : clk = 0 roll_ena = 1 spots = 2 current_state = 02
Time 180 : clk = 1 roll_ena = 1 spots = 2 current_state = 04
Time 181 : clk = 1 roll_ena = 0 spots = 2 current_state = 04
Time 182 : clk = 1 roll_ena = 0 spots = 2 current_state = 04
Time 183 : clk = 1 roll_ena = 0 spots = 2 current_state = 04
Time 184 : clk = 1 roll_ena = 0 spots = 2 current_state = 04
Time 185 : clk = 0 roll_ena = 0 spots = 2 current_state = 04
Time 186 : clk = 0 roll_ena = 0 spots = 2 current_state = 04
Time 187 : clk = 0 roll_ena = 0 spots = 2 current_state = 04
Time 188 : clk = 0 roll_ena = 0 spots = 2 current_state = 04
Time 189 : clk = 0 roll_ena = 0 spots = 2 current_state = 04
Time 190 : clk = 1 roll_ena = 0 spots = 3 current_state = 04
Time 191 : clk = 1 roll_ena = 1 spots = 3 current_state = 04
Time 192 : clk = 1 roll_ena = 1 spots = 3 current_state = 04
Time 193 : clk = 1 roll_ena = 1 spots = 3 current_state = 04
Time 194 : clk = 1 roll_ena = 1 spots = 3 current_state = 04
Time 195 : clk = 0 roll_ena = 1 spots = 3 current_state = 04
Time 196 : clk = 0 roll_ena = 1 spots = 3 current_state = 04
Time 197 : clk = 0 roll_ena = 1 spots = 3 current_state = 04
Time 198 : clk = 0 roll_ena = 1 spots = 3 current_state = 04
Time 199 : clk = 0 roll_ena = 1 spots = 3 current_state = 04
Time 200 : clk = 1 roll_ena = 1 spots = 3 current_state = 08
Time 201 : clk = 1 roll_ena = 0 spots = 3 current_state = 08


これで、モジュール内部の信号も表示することができた。

Verilatorを試してみる3(C++モード3:VCDファイルを出力)”に続く。
  1. 2011年05月23日 21:59 |
  2. シミュレーション
  3. | トラックバック:0
  4. | コメント:0

コメント

コメントの投稿


管理者にだけ表示を許可する

トラックバック URL
http://marsee101.blog.fc2.com/tb.php/1808-da2e3c1e
この記事にトラックバックする(FC2ブログユーザー)