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

Min Max Circuit

MediumVerilog / SystemVerilogBuild

Hardware sorting networks and non-linear median filters rely heavily on compare-and-swap primitives. These primitives take two values and route the smaller to one output and the larger to another, forming the fundamental building blocks of hardware sorting algorithms.

This module computes the minimum and maximum of two 8-bit unsigned integer inputs simultaneously. It routes the smaller of the two inputs to the out_min port and the larger to the out_max port. If the inputs are exactly equal, the outputs simply equal the inputs.

The circuit is purely combinational. There is no clock or reset.

| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | a | input | 8 | First unsigned operand | | b | input | 8 | Second unsigned operand | | out_min | output | 8 | The smaller of a and b | | out_max | output | 8 | The larger of a and b |

Constraints

  • The circuit must be purely combinational; do not use any clocked elements.
  • Inputs are 8-bit unsigned values.
  • To optimize for synthesis area, the design must logically infer exactly one relational comparator block.
  • The boolean result of the single comparison must drive the multiplexer select lines for both outputs.

Topics

combinationalmultiplexercomparatorsynthesis

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