Cascaded 4-to-1 Multiplexer
Large muxes are built from small ones. The solution module acts as a 4-to-1 multiplexer, routing one of four 1-bit data inputs to a single output based on a 2-bit select signal.
Instead of using behavioral Verilog constructs like a case statement, this module must be structurally constructed by instantiating exactly three 2-to-1 multiplexers. A pre-defined module named mux2to1 is provided for this purpose.
The mux2to1 module has the following ports:
a: 1-bit input (selected whensis 0)b: 1-bit input (selected whensis 1)s: 1-bit select inputy: 1-bit data output
| Signal | Direction | Width | Description |
|---|---|---|---|
d0 |
input | 1 | Data input 0; routed to y when sel is 2'b00 |
d1 |
input | 1 | Data input 1; routed to y when sel is 2'b01 |
d2 |
input | 1 | Data input 2; routed to y when sel is 2'b10 |
d3 |
input | 1 | Data input 3; routed to y when sel is 2'b11 |
sel |
input | 2 | Select signal; sel[1] is the MSB, sel[0] is the LSB |
y |
output | 1 | Selected data output |
Constraints
- The design must be purely combinational.
- You must structurally instantiate the provided
mux2to1module exactly three times. - You may not use
assign y = ...for the final 4-to-1 selection logic. - Select signal
sel[1]is the most significant bit;sel[0]is the least significant bit.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.
Part of Combinational RTL
Problem 14 of 15 in the Combinational RTL track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks