/* 2 to 4 Demux (input 2bit, output 2bit)*/
module demux2to4(s,in,out);
input [1:0] s;
input [1:0] in;
output [7:0] out;
function [7:0] mydemux;
input [1:0] sel;
input [1:0] a;
begin
case (sel)
2'b00 : mydemux={ 6'b000000, a };
2'b01 : mydemux={ 4'd0000, a, 2'b00 };
2'b10 : mydemux={ 2'b00, a, 4'b0000 };
default : mydemux={ a, 6'b000000 };
endcase
end
endfunction
assign out=mydemux(s,in);
endmodule
6'd0や6'h0でもよい