LoginSignup
2
0

More than 5 years have passed since last update.

$displayなどの引数について

Last updated at Posted at 2012-03-21

Verilog HDLのTipsなんぞ需要なさそうだけど、練習がてら投稿します。

$display、$fmonitor、$fstrobeなどの引数はC言語のprintfとほぼ同じですが、
次のように変わった書き方ができます。

$display( "こんな", "書き方が", "できる" );

結果: こんな書き方ができる

$display( "hoge%h", 1000, "piyo", 2000 );

結果: hoge3e8piyo 2000

strobeも、次のように信号ごとに分けると見やすくなります。

reg sig_a, sig_b, sig_c;
reg [7:0] bus;
initial begin
    #10;
    forever begin
        #10;
        $strobe( "%b", sig_a,
                 "%b", sig_b,
                 "%b", sig_c,
                 "%h", bus );
      end
  end

なお、これはIEEE1364で定義されているわけではありません。
なので、シミュレータによっては正しく動作しない可能性があります。
動作確認したシミュレータ = Icarus Verilog、Verilog-XL

2
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0