0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

windowsでiverilog その180

Posted at

概要 

windowsでiverilogやってみた。
練習問題やってみた。

練習問題

Dフリップフロップを書け。

サンプルコード


module dff(input D, clk, output reg Q);
	always@(posedge clk)
		Q = D;
endmodule

module test;
	reg d;
	reg clk;
	wire q;
	task check(input di);
		begin
			d <= di;
			clk <= 'b1;
		#1
			clk <= 'b0;
		end
	endtask
	dff u(.D(d), .clk(clk), .Q(q));
	initial
	begin
		$monitor("d=%d clk=%d q=%d", d, clk, q);
		check('b1);
		check('b1);
		check('b0);
		$finish();
	end
endmodule



実行結果

>vvp a.out
d=1 clk=1 q=1
d=1 clk=1 q=1
d=0 clk=1 q=0
dff4.v:28: $finish called at 3 (1s)
d=0 clk=0 q=0

以上。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?