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 その4

Last updated at Posted at 2020-07-05

概要

windowsでiverilogやってみた。
nslやってみた。
全加算器、書いてみた。

サンプルコード

declare ha {
	input a;
	input b;
	output c;
	output o;
}
module ha {
	{
		c = a & b;
		o = a ^ b;
	}
}
declare fa {
	input a;
	input b;
	input c;
	output o;
	output s;
}
module fa {
	ha ha0;
	ha ha1;
	{
		ha0.a = a;
		ha0.b = b;
		ha1.a = ha0.o;
		ha1.b = c;
		o = ha1.o;
		s = ha0.c | ha1.c;
	}
}

テストベンチ

module test;
	reg clk,
		rst;
	reg a,
		b,
		c;
	fa u(.clk(clk), .rst(rst), .a(a), .b(b), .c(c), .o(o), .s(s));
	always #1 clk = ~clk;
	integer i,
		j,
		k;
	initial
	begin
		clk = 0;
		rst = 1;
		#1
			rst = 0;
		#1
			rst = 1;
		$display("a b c o s");
		$monitor("%b %b %b %b %b", a, b, c, o, s);
		for(i = 0; i < 2; i = i + 1) begin
			for(j = 0; j < 2; j = j + 1) begin
				for(k = 0; k < 2; k = k + 1) begin
					a = i;
					b = j;
					c = k;
					#1;
				end
			end
		end
		$finish;
	end
endmodule

実行結果


a b c o s
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1


以上。

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?