Files
nand2tetris_verilog/mux.v
2024-06-13 13:29:36 -07:00

20 lines
376 B
Verilog

`ifndef _mux_v
`define _mux_v
`include "not.v"
`include "and.v"
`include "or.v"
module Mux (input a, input b, input sel, output out);
wire sel_bar;
wire a_sel;
wire b_sel;
Not u1 (.in(sel), .out(sel_bar));
And u2 (.a(a), .b(sel_bar), .out(a_sel));
And u3 (.a(b), .b(sel), .out(b_sel));
Or u4 (.a(a_sel), .b(b_sel), .out(out));
endmodule
`endif