最初のページ 戻る 次へ 最後のページ

関数functionをつかう

module comparator2(a,b,y);

input [1:0] a,b;

output [2:0] y;

function [2:0] mycomp;

input [1:0] u,v;

begin

 if (u<v) mycomp=3'b001;

 if (u==v) mycomp=3'b010;

 if (u>v) mycomp=3'b100;

end

endfunction

assign y=mycomp(a,b);

endmodule

処理の中心は

変更なし

入力は2ビット

a,bは2ビット