nand2/01_Boolean_Logic/DMux4Way.v

28 lines
527 B
Verilog

/**
* 4-way demultiplexor:
* {a, b, c, d} = {in, 0, 0, 0} if sel == 00
* {0, in, 0, 0} if sel == 01
* {0, 0, in, 0} if sel == 10
* {0, 0, 0, in} if sel == 11
*/
`default_nettype none
module DMux4Way(
input in,
input [1:0] sel,
output a,
output b,
output c,
output d
);
// Put your code here:
wire outx;
wire outy;
DMux DMUXA(in, sel[1], outx, outy);
DMux DMUXB(outx, sel[0], a, b);
DMux DMUXC(outy, sel[0], c, d);
endmodule