16.2.7.2 SystemCとの協調シミュレーション
DPIを使うことで、SystemCを呼び出すこともできます。 DLL化を行いmain()をインポートすればよいですね。この場合、二つのシミュレータ、VerilogHDLとSystemC、二つの独立した時刻を持って動きます。SystemCが時刻を消費しなければ、このモデルでも問題ありませんが、SystemCも時刻を消費するモデルの場合は、それぞれの時刻に気を配らなくてはいけないのが面倒になります。そのために、HDLと接続する場合は、大抵のシミュレーションベンダは、OSCIの提供するシミュレータではなく、それぞれのベンダのシミュレーションカーネルと統合したシングルシミュレーションカーネルを独自に持っています。
VeritakSVも、独自のシングルシミュレーションカーネルを持っています。
これを使えば、SystemCとSystemVerilogの時刻は、共通に進みますから、後は、インターフェースの部分をDPI上で、ファンクション・タスクコールすることで、接続を行います。書きようによっては、ピン間接続を模擬する書き方もできますが、トランザクションとしてまとめてコールした方がイベント数は少なく済み、シミュレーション負荷は低減できます。
< VeritakSVでのSystemC統合カーネル>
下のソースで、コメント部が、協調シミュレーションで追加した全てです。ライブラリは、パッケージに含まれるSystemC.lib
veritak_sv.libを追加します。このライブラリは、OSCIとは異なるVeritakSV専用のライブラリです。これらを下のように加えることでHDLとSystemCは、シングルカーネルで動きます。
SV側のソースです。
結果です。SystemC側とSV側では、共通の時刻で動作しています。
C:\Users\tak.sugawara\Documents\Visual Studio 2005\Projects\dpi_sample\fir.v(2)::export_test1 Verilogのシミュレーションの準備が完了しました。スタートは,Goボタンを押してください。 ***** Veritak SV Engine Version 0.27 Build no.27.2009 ***** Veritak-SystemC Simulation Kernel Initialized. Nov.27.2009. SystemC 2.2.0 --- Nov 27 2009 01:32:46 Copyright (c) 1996-2006 by all Contributors ALL RIGHTS RESERVED Stimuli : 0 at time 9000 ........................................................SV時刻は、 10 Display : 0 at time 10000 Stimuli : 1 at time 19000 ........................................................SV時刻は、 20 Display : -6 at time 20000 Stimuli : 2 at time 29000 ........................................................SV時刻は、 30 Display : -16 at time 30000 Stimuli : 3 at time 39000 ........................................................SV時刻は、 40 Display : -13 at time 40000 Stimuli : 4 at time 49000 ........................................................SV時刻は、 50 Display : 6 at time 50000 Stimuli : 5 at time 59000 ........................................................SV時刻は、 60 Display : 7 at time 60000 Stimuli : 6 at time 69000 ........................................................SV時刻は、 70 Display : -33 at time 70000 Stimuli : 7 at time 79000 ........................................................SV時刻は、 80 Display : -50 at time 80000 Stimuli : 8 at time 89000 ........................................................SV時刻は、 90 Display : 87 at time 90000 Stimuli : 9 at time 99000 ........................................................SV時刻は、 100 Display : 446 at time 100000 Stimuli : 10 at time 109000 ........................................................SV時刻は、 110 Display : 959 at time 110000 Stimuli : 11 at time 119000 ........................................................SV時刻は、 120 Display : 1495 at time 120000 Stimuli : 12 at time 129000 ........................................................SV時刻は、 130 Display : 1990 at time 130000 Stimuli : 13 at time 139000 ........................................................SV時刻は、 140 Display : 2467 at time 140000 Stimuli : 14 at time 149000 ........................................................SV時刻は、 150 Display : 2960 at time 150000 Stimuli : 15 at time 159000 ........................................................SV時刻は、 160 Display : 3466 at time 160000 Stimuli : 16 at time 169000 ........................................................SV時刻は、 170 Display : 3968 at time 170000 Stimuli : 17 at time 179000 ........................................................SV時刻は、 180 Display : 4470 at time 180000 Stimuli : 18 at time 189000 ........................................................SV時刻は、 190 Display : 4972 at time 190000 Stimuli : 19 at time 199000 ........................................................SV時刻は、 200 Display : 5474 at time 200000 Stimuli : 20 at time 209000 ........................................................SV時刻は、 210 Display : 5976 at time 210000 Stimuli : 21 at time 219000 ........................................................SV時刻は、 220 Display : 6478 at time 220000 Stimuli : 22 at time 229000 ........................................................SV時刻は、 230 Display : 6980 at time 230000 Stimuli : 23 at time 239000 ........................................................SV時刻は、 240 Display : 7482 at time 240000 Simulation of 24 items finished at time 240000 ........................................................SV時刻は、 250 ........................................................SV時刻は、 260 ........................................................SV時刻は、 270 ........................................................SV時刻は、 280 ........................................................SV時刻は、 290 ........................................................SV時刻は、 300 **** Test Done. Total 109.00[msec] ****
<SystemVerilog-SystemC間の通信>
SVソースです。function ならば、CThread,Thread,Methodによらず、どこからでも呼び出せます。しかしながら、functionでは、ブロッキングプロセスを書けないので、fork
-join_noneを使っているのがポイントです。
上のソースにさらに下を追加しました。
結果です。
C:\Users\tak.sugawara\Documents\Visual Studio 2005\Projects\dpi_sample\fir.v(2)::export_test1 Verilogのシミュレーションの準備が完了しました。スタートは,Goボタンを押してください。 ***** Veritak SV Engine Version 0.27 Build no.27.2009 ***** Veritak-SystemC Simulation Kernel Initialized. Nov.27.2009. SystemC 2.2.0 --- Nov 29 2009 06:40:39 Copyright (c) 1996-2006 by all Contributors ALL RIGHTS RESERVED reset=0 Power Up Command 受領 0 Stimuli : 0 at time 9000 ........................................................SV時刻は、 10 Display : 0 at time 10000 Stimuli : 1 at time 19000 ........................................................SV時刻は、 20 Display : -6 at time 20000 Stimuli : 2 at time 29000 ........................................................SV時刻は、 30 Display : -16 at time 30000 Stimuli : 3 at time 39000 ........................................................SV時刻は、 40 Display : -13 at time 40000 Stimuli : 4 at time 49000 ........................................................SV時刻は、 50 Display : 6 at time 50000 Stimuli : 5 at time 59000 ........................................................SV時刻は、 60 Display : 7 at time 60000 Stimuli : 6 at time 69000 Power Up 終了 70 Notify Power Up: notify しました。 ........................................................SV時刻は、 70 Power up Seq 終了を認識しました。 Display : -33 at time 70000 Stimuli : 7 at time 79000 ........................................................SV時刻は、 80 Display : -50 at time 80000 Stimuli : 8 at time 89000 ........................................................SV時刻は、 90 Display : 87 at time 90000 Stimuli : 9 at time 99000 ........................................................SV時刻は、 100 Display : 446 at time 100000 Stimuli : 10 at time 109000 ........................................................SV時刻は、 110 Display : 959 at time 110000 Stimuli : 11 at time 119000 ........................................................SV時刻は、 120 Display : 1495 at time 120000 Stimuli : 12 at time 129000 ........................................................SV時刻は、 130 Display : 1990 at time 130000 Stimuli : 13 at time 139000 ........................................................SV時刻は、 140 Display : 2467 at time 140000 Stimuli : 14 at time 149000 ........................................................SV時刻は、 150 Display : 2960 at time 150000 Stimuli : 15 at time 159000 ........................................................SV時刻は、 160 Display : 3466 at time 160000 Stimuli : 16 at time 169000 ........................................................SV時刻は、 170 Display : 3968 at time 170000 Stimuli : 17 at time 179000 ........................................................SV時刻は、 180 Display : 4470 at time 180000 Stimuli : 18 at time 189000 ........................................................SV時刻は、 190 Display : 4972 at time 190000 Stimuli : 19 at time 199000 ........................................................SV時刻は、 200 Display : 5474 at time 200000 Stimuli : 20 at time 209000 ........................................................SV時刻は、 210 Display : 5976 at time 210000 Stimuli : 21 at time 219000 ........................................................SV時刻は、 220 Display : 6478 at time 220000 Stimuli : 22 at time 229000 ........................................................SV時刻は、 230 Display : 6980 at time 230000 Stimuli : 23 at time 239000 ........................................................SV時刻は、 240 Display : 7482 at time 240000 Simulation of 24 items finished at time 240000 ........................................................SV時刻は、 250 ........................................................SV時刻は、 260 ........................................................SV時刻は、 270 ........................................................SV時刻は、 280 ........................................................SV時刻は、 290 ........................................................SV時刻は、 300 join_anyを脱出しました。 **** Test Done. Total 30.00[msec] ****