2024-10-17 18:36:58 +00:00
|
|
|
/**
|
2023-01-11 10:13:09 +00:00
|
|
|
* Multiplexor:
|
|
|
|
* out = a if sel == 0
|
|
|
|
* b otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
`default_nettype none
|
|
|
|
module Mux(
|
2024-10-17 18:36:58 +00:00
|
|
|
input a,
|
|
|
|
input b,
|
|
|
|
input sel,
|
|
|
|
output out
|
2023-01-11 10:13:09 +00:00
|
|
|
);
|
|
|
|
|
2024-10-17 18:36:58 +00:00
|
|
|
// Put your code here:
|
|
|
|
wire nsel;
|
|
|
|
wire outx;
|
|
|
|
wire outy;
|
2023-01-11 10:13:09 +00:00
|
|
|
|
2024-10-17 18:36:58 +00:00
|
|
|
Not NOT1(sel, nsel);
|
|
|
|
And AND1(b, sel, outx);
|
|
|
|
And AND2(a, nsel, outy);
|
|
|
|
Or OR(outx, outy, out);
|
2023-01-11 10:13:09 +00:00
|
|
|
endmodule
|