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

Cascaded 4-to-1 Multiplexer

EasyVerilog / SystemVerilogBuild

FPGA architectures often provide native 2-to-1 multiplexers within their logic cells. Synthesizing wider data selection buses requires cascading these foundational primitives into a larger routing tree. 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 when s is 0) • b: 1-bit input (selected when s is 1) • s: 1-bit select input • y: 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 mux2to1 module 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

Combinational LogicMultiplexersStructural Verilog

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