Nested Ternary Multiplexer Tree
Data routing in high-speed datapaths often relies on wide multiplexer trees to select between multiple data sources. While procedural case statements are commonly used for this purpose, continuous assignments using ternary operators map cleanly to hardware multiplexers. When writing purely combinational logic, using ternary operators helps designers avoid the unintended latches that often plague poorly written procedural blocks.
The solution module acts as a 4-to-1 data multiplexer. It routes one of four 8-bit data inputs to a single 8-bit output based on a 2-bit selection signal. The output must reflect the selected input immediately.
This is a purely combinational circuit. There is no clock or reset signal. The output must update with zero delay whenever any input or the selection signal changes.
| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | d0 | input | 8 | Data input 0, selected when sel is 2'b00 | | d1 | input | 8 | Data input 1, selected when sel is 2'b01 | | d2 | input | 8 | Data input 2, selected when sel is 2'b10 | | d3 | input | 8 | Data input 3, selected when sel is 2'b11 | | sel | input | 2 | Selection signal determining which input is routed to the output | | y | output | 8 | Multiplexed data output; fully combinational |
Constraints
- The module must be implemented using a single continuous assignment (
assign). - Procedural blocks (
alwaysoralways_comb) are strictly forbidden. caseandif-elsestatements are not permitted.- The output
yis purely combinational and must not be registered.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against a real 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.