DDCO Lab - Solution 6&7
DDCO Lab - Solution 6&7
4:1 multiplexer:
Fig. 4:1 Multiplexer (TT and expr’n) Fig. 4:1 Multiplexer (logical)
module mux_tb();
reg [3:0]i;
reg [1:0]s;
wire y;
4_1_mux m1 (.i(i), .s(s), .y(y));
Initial
begin
end
endmodule
1:4 de-multiplexer:
always @(*)
begin
case (s)
2'b00 : begin y[0] = din; end
2'b01 : begin y[1] = din; end
2'b10 : begin y[2] = din; end
2'b11 : begin y[3] = din; end
default: y[3:0]=4’b0000;
endcase
end
endmodule
module mux_tb();
reg din;
reg [1:0]s;
wire [3:0]y;
Initial
begin
din = 1’b1;
s = 2'b00; #10;
s = 2'b01; #10;
s = 2'b10; #10;
s = 2'b11; #10;
end
endmodule