Skip to content

Commit

Permalink
リセット付きフリフロのテストベンチを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
kentaroy47 committed Nov 25, 2021
1 parent be3379d commit 6db1761
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions 03_register/chap4_register_tb.sv
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,33 @@ module floptest;
always #1
d <= d + 1;

endmodule

// 4b リセット付きレジスタのテストベンチ
module floprtest;
// テスト信号を定義
reg [3:0] d;
reg clk;
reg rst;
wire [3:0] q;

flopr u1(.*);

// 信号の動きを宣言
// 初期値
initial begin
d = 0;
clk = 0;
rst = 1;
#20 rst = 0; // 20後、rstを立ち下げる
#100 $stop; // 終了時間の定義。これがないと延々に回ってしまう!
end

// 周期変動
// ノンブロッキング代入することで遷移を同時にする。
always #5
clk = clk + 1;
always #1
d <= d + 1;

endmodule

0 comments on commit 6db1761

Please sign in to comment.