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

/* 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

case (sel)

2'b00 : mydemux = {3'b000 ,a };

2'b01 : mydemux = {2'b00 ,a, 1'b0 };

2'b10 : mydemux = {1'b0 ,a, 2'b00 };

default : mydemux = { a, 3'b000};

endcase

end

endfunction

assign out=mydemux(s,in);

endmodule

{a, 1'b0, 1'b0, 1'b0}

も間違いではない