0
0

ビジュアルプログラミングで高位合成 その10

Last updated at Posted at 2024-09-22

概要

ビジュアルプログラミングで組み合わせ回路を組み立てて、シュミレーションして、verilogを生成します。
高位合成です。
実は、今の実装では、全加算器が高位合成できません。
全加算器の高位合成を実装しました。検証します。
検証編

テストベンチを書く。


module x(input B, input A, input Cin, output Sum, output Cout);
	wire w0;
	wire w1;
	wire w2;
	wire w3;
	assign Sum = (Cin ^ w0);
	assign w0 = (A ^ B);
	assign w1 = (A ^ B);
	assign w2 = (A & B);
	assign Cout = (w3 | w2);
	assign w3 = (Cin & w1);
endmodule


module test;
	reg A;
	reg B;
	reg Cin;
	x u(.A(A), .B(B), .Cin(Cin), .Sum(Sum), .Cout(Cout));
	initial
	begin
		$display(" A   B   Cin Sum Cout");
		$monitor(" %b   %b   %b   %b   %b", A, B, Cin, Sum, Cout);
		A = 0;
		B = 0;
		Cin = 0;
	#10;
		A = 0;
		B = 1;
		Cin = 0;
	#10;
		A = 1;
		B = 0;
		Cin = 0;
	#10;
		A = 1;
		B = 1;
		Cin = 0;
	#10;
		A = 0;
		B = 0;
		Cin = 1;
	#10;
		A = 0;
		B = 1;
		Cin = 1;
	#10;
		A = 1;
		B = 0;
		Cin = 1;
	#10;
		A = 1;
		B = 1;
		Cin = 1;
	#10;
		$finish;
	end
endmodule





iverilogでシュミレーション実行

>iverilog fa1.v

>vvp a.out
 A   B   Cin Sum Cout
 0   0   0   0   0
 0   1   0   1   0
 1   0   0   1   0
 1   1   0   0   1
 0   0   1   1   0
 0   1   1   0   1
 1   0   1   0   1
 1   1   1   1   1
fa1.v:58: $finish called at 80 (1s)

以上

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