#author("2023-11-03T12:24:55+09:00","default:shota","shota")
#author("2023-11-03T12:53:04+09:00","default:shota","shota")
[[FrontPage]]

*概要 [#ff6415ed]
-シミュレーションしないとバグも見つからない

*目次 [#p4a9922e]
#contents

*使用ツール [#i87ac2f2]
-IcarusVerilogとGTKWaveを使用する
-IcarusVerilog: シミュレータ
-GTKWave: 波形の表示

*シミュレート対象 [#w8206cc9]
-以下の半加算器をシミュレート対象とする

half_adder.v
#highlightjs(v)
 module half_adder(
     input in0,
     input in1,
     output c,
     output s
 );
 
 assign c = in0 & in1;
 assign s = in0 ^ in1;
 
 endmodule

*シミュレートコード [#f99e5521]
adder_test.v
#highlightjs(v)
 `timescale 1ps/1ps
 
 module adder_test;
 
 reg in0, in1;
 wire c, s;
 
 half_adder adder(
     .in0(in0),
     .in1(in1),
     .c(c),
     .s(s)
 );
 
 initial begin
     $dumpfile("test.vcd");
     $dumpvars(1, adder_test);
 
     in0 = 0; in1 = 0;
     #10 in0 = 1;
     #10 in0 = 0; in1 = 1;
     #10 in0 = 1;
     #10 $finish;
 end
 
 endmodule

*コンパイルと実行 [#nf7b1fad]
-iverilog -o [出力ファイル名] -s [トップモジュール名] [.vファイル]でコンパイルを行う
-vvp [実行ファイル名]でシミュレートが開始される
-gtkwave [ダンプファイル名]で波形の描画ツールが起動される

#highlightjs(shell)
 $ iverilog -o test.out -s addr_test adder_test.v half_adder.v
 $ vvp test.out
 $ gtkwave test.vcd

#ref(2023-11-03_122808.png)

*補足 [#qdcea44b]
-GTKWaveはIcarusVerilog for Windowsをインストールすると付属された
-IcarusVerilogは[[このページ:https://bleyer.org/icarus/]]からインストーラーをダウンロードした

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS