Challenge - 5 Problems
Multiplexer Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateWhat is the output of this 2-to-1 multiplexer?
Given the Verilog code below for a 2-to-1 multiplexer, what will be the value of
out when sel = 1, in0 = 0, and in1 = 1?Verilog
module mux2to1(input wire in0, input wire in1, input wire sel, output wire out); assign out = sel ? in1 : in0; endmodule
Attempts:
2 left
💡 Hint
Remember, when sel is 1, the output should be in1.
✗ Incorrect
The multiplexer outputs in1 when sel is 1. Since in1 is 1, out will be 1.
❓ Predict Output
intermediateOutput of 4-to-1 multiplexer with given inputs
Consider this 4-to-1 multiplexer code. What is the output
out when sel = 2'b10 and inputs are in0=0, in1=1, in2=1, in3=0?Verilog
module mux4to1(input wire in0, input wire in1, input wire in2, input wire in3, input wire [1:0] sel, output wire out); assign out = (sel == 2'b00) ? in0 : (sel == 2'b01) ? in1 : (sel == 2'b10) ? in2 : in3; endmodule
Attempts:
2 left
💡 Hint
Check which input corresponds to sel = 2'b10.
✗ Incorrect
When sel is 2'b10, the output is in2, which is 1.
🔧 Debug
advancedIdentify the error in this 8-to-1 multiplexer code
This Verilog code is intended to implement an 8-to-1 multiplexer. What error will it cause?
Verilog
module mux8to1(input wire [7:0] in, input wire [2:0] sel, output wire out); assign out = (sel == 3'b000) ? in[0] : (sel == 3'b001) ? in[1] : (sel == 3'b010) ? in[2] : (sel == 3'b011) ? in[3] : (sel == 3'b100) ? in[4] : (sel == 3'b101) ? in[5] : (sel == 3'b110) ? in[6] : in[7]; endmodule
Attempts:
2 left
💡 Hint
Examine the code for syntax errors, reserved words, or logical issues.
✗ Incorrect
No error; 'in' is not a reserved keyword in Verilog, and the nested ternary operator correctly covers all 8 select values.
📝 Syntax
advancedWhich option correctly implements a 2-to-1 multiplexer using a case statement?
Select the correct Verilog code snippet that implements a 2-to-1 multiplexer using a
case statement inside an always block.Attempts:
2 left
💡 Hint
Use non-blocking assignment inside always block for outputs.
✗ Incorrect
Option B correctly uses non-blocking assignments (<=), proper sensitivity list (@(*) for combinational logic), and case labels with 1-bit selectors.
🚀 Application
expertHow many 4-to-1 multiplexers are needed to build a 16-to-1 multiplexer?
You want to build a 16-to-1 multiplexer using only 4-to-1 multiplexers as building blocks. How many 4-to-1 multiplexers do you need at minimum?
Attempts:
2 left
💡 Hint
16 inputs / 4 = 4 muxes → 4 outputs; 4 outputs / 4 = 1 mux → total 5.
✗ Incorrect
First layer: 4 4-to-1 MUXes reduce 16 inputs to 4 intermediate signals. Second layer: 1 4-to-1 MUX selects from the 4 intermediates to produce the final output. Total: 5 MUXes.
