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

/* 2 to 4 Demux (input 1bit, output 1bit)*/

module demux2to4(s,in,out);

input [1:0] s;

input in;

output [3:0] out;

function [3:0] mydemux;

input [1:0] sel;

input a;

begin

casex ({sel,a})

3'bxx0 : mydemux=4'b0000;

3'b001 : mydemux=4'b0001;

3'b011 : mydemux=4'b0010;

3'b101 : mydemux=4'b0100;

default : mydemux=4'b1000;

endcase

end

endfunction

assign out=mydemux(s,in);

endmodule

aが0であるとき

出力はすべて0