CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Combinational Logic

Nested Ternary Multiplexer Tree

MediumVerilog / SystemVerilogBuild

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 (always or always_comb) are strictly forbidden.
  • case and if-else statements are not permitted.
  • The output y is purely combinational and must not be registered.

Topics

CombinationalMultiplexerData RoutingOperators

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.

Sign in to solveSee what Pro unlocks

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.

Related problems

  • Single Continuous AssignmentEasy
  • Basic Vector ConcatenationEasy
  • Ternary Operator MuxEasy
  • Underscores for ReadabilityEasy
  • Left Hand Side ConcatenationEasy
  • Inout Port MechanicsEasy
  • Explicit Binary LiteralsEasy
  • Vector Port EndiannessEasy

Browse all problems · Learning tracks