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?

More than 3 years have passed since last update.

高位合成言語NSL その2

Last updated at Posted at 2020-07-04

概要

windowsでiverilogやってみた。
nslやってみた。
_random使ってみた。

サンプルコード

declare test_rand simulation { 
}
module test_rand {
	reg trigger[3] = 0;
	reg temp[8] = 0;
	reg cnt[8] = 0;
	func_self neko();
	trigger := { trigger[1:0], 0b1 };
	if (trigger == 3'b011) neko();
	func neko seq {
		for (cnt := 0; cnt < 5; cnt++) {
			_display("random == %d", _random[7:0]);
		}
		_finish("End Simulation");
	}
}

テストベンチ

module test;
	reg clk,
		rst;
	test_rand u(.clk(clk), .rst(rst));
	always #1 clk = ~clk;
	initial
	begin
		clk = 0;
		rst = 1;
		#1
			rst = 0;
		#1
			rst = 1;
		#100
			$finish;
	end
endmodule

実行結果


Warning: register set hazard(test_rand:cnt) at                    1
random ==  99
random ==  13
random == 141
random == 101
random ==  18
End Simulation


以上。

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?