Min Max Finder
Median filters and sorting networks need the smallest and largest of several values in a single cycle. That means comparing all of them at once.
This module evaluates four independent 8-bit unsigned integer inputs. It combinationally compares these four values and routes the smallest value to the minimum output port and the largest value to the maximum output port.
Because this is a purely combinational circuit, there are no clock or reset signals. The outputs must update immediately in response to any input change.
Example Trace:
a=10,b=20,c=30,d=40→min_val=10,max_val=40a=200,b=50,c=200,d=10→min_val=10,max_val=200a=255,b=255,c=255,d=255→min_val=255,max_val=255
| Signal | Direction | Width | Description |
|---|---|---|---|
a |
input | 8 | First unsigned input value |
b |
input | 8 | Second unsigned input value |
c |
input | 8 | Third unsigned input value |
d |
input | 8 | Fourth unsigned input value |
min_val |
output | 8 | The smallest value among the four inputs |
max_val |
output | 8 | The largest value among the four inputs |
Constraints
- The circuit must be purely combinational. Do not infer any latches or flip-flops.
- All inputs and outputs are treated as 8-bit unsigned integers.
- If multiple inputs share the same minimum or maximum value, the output must simply reflect that value.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's 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.
Part of Datapath Design
Problem 23 of 27 in the Datapath Design track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks