/* Mux / Demux Mux a b sel | out ------------------- 0 0 0 | 0 1 0 0 | 1 0 1 1 | 1 1 0 1 | 0 ... */ module mux_2n1 #(parameter N = 8) ( input [N-1:0] a, input [N-1:0] b, input sel, output [N-1:0] out ); assign out = sel ? b : a; endmodule module demux_1n2 #(parameter N = 8) ( input [N-1:0] in, input sel, output [N-1:0] a, output [N-1:0] b ); assign a = sel ? 0 : in; assign b = sel ? in : 0; endmodule