There are quite a few articles (for example, this) that can be found online discussing the design of a comparator that takes two numbers (say,
B) as inputs, and outputs whether
A > B,
A < B or
A = B. But what if I want to compare multiple numbers?
Let's say we have four 4-bit binary numbers denoted as
i3. I want the output of the circuit to be the index of the minimum value
among them. Below are some examples:
The highlighted value in each row represents the minimum value among the four which the output should correspond to.
I've thought of comparing the bits one-by-one starting from the MSB, but things got ugly when I tried to realize using combinational gates. Is there any efficient ways to do this?