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

仮引数のスコープ

module comparator(a,b,y);

input a,b;

output [2:0] y;

function [2:0] mycomp;

input a,b;

begin

 if (a<b) mycomp=3'b001;

 if (a==b) mycomp=3'b010;

 if (a>b) mycomp=3'b100;

end

endfunction

assign y=mycomp(a,b);

endmodule

実引数仮引数を同じにするとどうなるか?

a,bは関数mycompの中だけで有効

(本当はいろいろある)

[結論]

a,ba,bは区別される