module mux4to1(s,in,out);
input [1:0] s;
input [3:0] in;
output out;
function mymux;
input [1:0] sel ;
input [3:0] x;
begin
case (sel)
2'b00 : mymux=x[0];
2'b01 : mymux=x[1];
2'b10 : mymux=x[2];
default : mymux=x[3];
endcase
end
endfunction
assign out=mymux(s,in);
endmodule
functionの中で
case文を使った
s,inは配列
if文でもよい