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

Ternary Operator Mux

EasyVerilog / SystemVerilogBuildFree4 solved

Data routing is a fundamental operation in digital design. A multiplexer acts as a controlled switch, allowing a system to select between multiple data sources to drive a single shared bus or execution unit.

This module routes one of two 8-bit input data buses to an 8-bit output bus based on the state of a single select bit. When the select bit is high, the first input bus is routed to the output. When the select bit is low, the second input bus is routed to the output.

This is a purely combinational circuit. There is no clock and no reset. The output must reflect the selected input immediately without any registered delay.

| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | a | input | 8 | Data input selected when sel is 1 | | b | input | 8 | Data input selected when sel is 0 | | sel | input | 1 | Select signal; determines which input drives out | | out | output | 8 | Selected data output |

Constraints

  • The module must be purely combinational.
  • Output out must strictly follow a when sel is 1, and b when sel is 0.
  • The design must not use clocks, resets, or flip-flops.
  • The data buses are exactly 8 bits wide.

Topics

CombinationalMultiplexerData RoutingTernary Operator

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.

Free to solve. A Codiode account keeps your progress.

Sign in to solve

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
  • Underscores for ReadabilityEasy
  • Left Hand Side ConcatenationEasy
  • Inout Port MechanicsEasy
  • Explicit Binary LiteralsEasy
  • Hexadecimal and Octal LiteralsEasy
  • Vector Port EndiannessEasy

Browse all problems · Learning tracks