nand2/01_Boolean_Logic/Mux4Way16.v

25 lines
550 B
Verilog

/**
* 16-bit multiplexor:
* for i = 0..15 out[i] = a[i] if sel == 0
* b[i] if sel == 1
*/
`default_nettype none
module Mux4Way16(
input [15:0] a,
input [15:0] b,
input [15:0] c,
input [15:0] d,
input [1:0] sel,
output [15:0] out
);
// Put your code here:
wire [15:0] outab;
wire [15:0] outcd;
Mux16 MUX16A(a[15:0], b[15:0], sel[0], outab[15:0]);
Mux16 MUX16B(c[15:0], d[15:0], sel[0], outcd[15:0]);
Mux16 MUX16(outab[15:0], outcd[15:0], sel[1], out[15:0]);
endmodule