VerilogCPU/mux4.sv

28 lines
524 B
Systemverilog
Raw Permalink Normal View History

2018-06-05 23:42:20 -07:00
/**
* A four-input multiplexer.
*/
2018-06-05 00:06:45 -07:00
module mux4 #(width=32)
(input logic [width-1:0] first, second, third, fourth,
input logic [1:0] select,
output logic [width-1:0] out);
2018-06-05 23:42:20 -07:00
2018-06-05 00:06:45 -07:00
logic [width-1:0] lower, upper;
2018-06-05 23:42:20 -07:00
2018-06-05 00:06:45 -07:00
mux2 lower_mux(
.left(first),
.right(second),
.select(select[0]),
.out(lower));
mux2 upper_mux(
.left(third),
.right(fourth),
.select(select[0]),
.out(upper));
2018-06-05 23:42:20 -07:00
2018-06-05 00:06:45 -07:00
mux2 final_mux(
.left(lower),
.right(upper),
.select(select[1]),
.out(out));
2018-06-05 23:42:20 -07:00
endmodule