SystemVerilog
この記事は SystemVerilog Advent Calendar 2020の 1日目になります。 まだまだ空きがありますので、興味あれば参加してください。 プロローグ きっかけはこの本が発売されたことから SystemVerilog入門―設計・仕様・検証のためのハードウェア記述言語― 超久…
UVM Cookbookが改版されたようです。 UVM Cookbook released in new edition UVM Cookbookは Verification Academy's(旧Mentor)が運営しているところからリリースされてます。 更新内容は IEEE1800.2に沿った内容になったということで、OVMなどの内容やリン…
引数にinterfaceで思い出したのですが、interfaceにparameter持たせた時に 仮引数の宣言の仕方がさっぱりわからなかった記憶が。 ってなことだったので、試してみました。 interface if_hoge#(parameter BW = 8)(); logic [BW-1:0] data; endinterface : if_…
きっかけはこちらの Verification Academyにて "hot bit" randomization このスレッドにCVCの方が回答したものが、こちらになります。 Smart constraint modeling in SystemVerilog class c; rand bit[31:0] vec_1; constraint cst_max_2_hot_bits { $counto…
problem about variable part select in SystemVerilog 確かに、こういう風に書きたいと思った時もありますね。 addr[8-:idx_bits] = {idx_bits{1'b1}}; ☆ここでのポイント addr[ const_or_var : const ] = { const { const_or_var } }; ビットスライス右側…
※本内容はシミュレータによって変わる場合があるかもしれません。 きっかけはこちらの記事になります。 SystemVerilog 2009 macro `FILE ? absolute or relative path? こちらの記事のほうでは Questaシミュレータを使用した場合のようです。 私の方は Model…
bit幅に「-(マイナス)」値を使った書き方ができるとは。。。 私自身書いたことがなかったので、試しに書いてみました。 サンプルコード module testbench; int tmp[-2:5]; int data; initial begin for(int i=-2; i<5; i++) begin tmp[i] = data + 1; data++…
IEEE規格では以下のように定義されています。 Table 20.1 Diagnostics for $finish Argument value Diagnostic message 0 Prints nothing 1 Prints simulation time and location 2 Prints simulation time, location, and statistics about the memory and …
SystemVerilogのランダム生成には、以下の functionが存在します。 IEEE1800-2012引用: 18.6.2 Pre_randomize() and post_randomize() Every class contains pre_randomize() and post_randomize() methods, which are automatically called by randomize()…
SystemVerilog:mailbox で mailbox 書いたので、次は「semaphore」書いてみました。 サンプルコード module testbench (); semaphore sm_hoge; task task_put(); sm_hoge.put(); endtask task task_get; forever begin if (sm_hoge.try_get()) begin $displ…
SystemVerilog 2012:unique constraint でも紹介しましたが、SystemVerilogでは if/caseに対して以下の制約が追加されています。 unique unique0 priority これらの予約語を使いことにおいて、シミュレータに検知されることができます。 共通条件 すべての条…
Introducing soft constraints in SystemVerilog 2012 より、SystemVerilog 2012 にて soft constraint が追加されるらしいです。 これって元々こちらからのもの? Soft Constraints for SystemVerilog Package - @Venginnerの戯言 soft constraintってなに…
Bringing in uniqueness constraint to SystemVerilog ? welcome P1800-2012 より、SystemVerilog 2012では constraintにも uniqueが設定出来るようになるみたいです。 これは便利かも! unique とは? case文を記述例としてあげています。 unique/priority…
Plus args in System Verilog is Plus point!! UVMでのテスト指定とかでみたことはあったけど、自分で指定出来るですね。 SystemVerilogでは、2種類の定義が可能です。 $test$plusargs ( string ) $value$plusargs ( user_string, variable ) $test$plusargs…
SystemVerilog 2012の拡張部分の「多重継承」について予習を。 予習するきっかけはこちらのブログになります。 Did you miss multiple-inheritance in SystemVerilog?(VerificationOnWeb(VoW)) 多重継承ってなに? 多重継承とは、1つのクラスが複数のクラス…
SystemVerilogの「mailbox」を書いてみました。 FIFOの拡張版(やり取り制御込み)といったところでしょうか。 ちなみに、キッカケはこちらのブログです。 Is my SystemVerilog mailbox half-full or half-empty? An engineer’s hunger now served! サンプルコ…
こちらのブログにて、 SystemVerilog String Literal "Gotcha" ぱっと見ると、意味がわからなったけど少し眺めてみると内容が理解できた。 つまり、byte型に対して、文字列(本来ありえないけど)を代入した場合に、どの部分が代入されるかということ。 番号 9…
今回の勉強題材はこちら。 SystemVerilog Fork Disable "Gotchas" automatic これはVerilog-HDL 2001から automatic が追加されています。 参考:automaticを意識する。 fork~join_any サンプルコードは書いてあるので、省略。 fork~joinの場合の出力結果…
そういえば、書いてなかったので書いてみた。 サンプルコード class hoge; int int_tmp = 4; function new(int a); int_tmp = a; endfunction endclass module testbench; hoge cl_hoge = new(10); initial begin $display("--- cl_hoge.int_tmp = %3d",cl_h…
「task/functionのオーバーロードを検討してみた。」を見て DPI-Cで書いてみみた ただ、この場合だと C++のオーバーロードを使ったやり方になりますので、 シナリオは C++側に書くことになります。 C++側のコード #include <stdio.h> #ifdef __cplusplus extern "C" {</stdio.h>…
SystemVerilog「this」 を使ってみましょう。というお話です。 サンプルコード class base; int a; virtual function void set_a(int in); a = in; endfunction endclass class hoge extends base ; int a; function void set_a(int in); this.a = in; $disp…
module と同じような感じで、classにもパラメータを渡すことができます。 C++で言うとテンプレートみたいな感じです。 サンプルコード class hoge #(int width = 1); logic [width-1:0] l_a; function void show(); $display("--- a = %3d", l_a); endfuncti…
タイトルは適当につけていますが、規格上の説明は Class scope resolution operator :: のようになってます。 サンプルコード class hoge; static function void show(int a, int b); $display("- a = %3d, b = %3d", a, b); endfunction endclass module te…
SystemVerilogから class が追加されたので出来ます。 サンプルコード class base; virtual function void show(int a, int b); $display("--- base: a = %3d, b = %3d", a, b); endfunction endclass class hoge extends base; virtual function void show(…
SystemVerilog classにて、super というものがあります。 サンプルコード class base; virtual function void show(int a, int b); $display("- a = %3d, b = %3d", a, b); endfunction endclass class hoge extends base; function void show(int a, int b=…