2-to-1 Multiplexer
beginner · combinational · 50 XP
Sign in to write your solution, run it in the simulator and submit it for grading.
Sign in or create a free account →Problem
2-to-1 Multiplexer
Implement a 2-to-1 multiplexer: two data inputs `d0`, `d1`, one select `s`, one output `y`.
- When `s=0`: `y = d0`
- When `s=1`: `y = d1`
Implement using an `always @(*)` block with `if-else`.
**Notes** — The `always @(*)` sensitivity list automatically includes every signal read inside the block. This is the preferred style for combinational logic in Verilog-2001.
Constraints
- Use always @(*) with if-else.
- Declare y as reg.
- No latches — both branches must assign y.
Examples
Input: s=0, d0=1, d1=0
Output: y=1
Input: s=1, d0=1, d1=0
Output: y=0
Common questions
- What does the 2-to-1 Multiplexer problem ask you to build?
- 2-to-1 Multiplexer Implement a 2-to-1 multiplexer: two data inputs `d0`, `d1`, one select `s`, one output `y`. - When `s=0`: `y = d0` - When `s=1`: `y = d1` Implement using an `always @(*)` block with `if-else`.
- What constraints does 2-to-1 Multiplexer have?
- Use always @(*) with if-else.; Declare y as reg.; No latches — both branches must assign y.
- What is an example input and output for 2-to-1 Multiplexer?
- Input s=0, d0=1, d1=0 gives output y=1.
- Which Verilog concepts does 2-to-1 Multiplexer practise?
- combinational, always, mux.