a BRAM-based "software like" solution will surely be the most area
efficient;
anyway, for signal processing, John might need real time?
here is another solution to find the MEDIAN of M values of N bits.
inputs are stored in M registers. (You might want to shift them along
your sampled values)
design a M bits inputs, 1 bit output module. The output value is 1 if
the number of ones is greater than the number of zeroes.
Plug this on all MSb, the output is the MSb of the final result.
Now design quite the same module, but with Mx2+1 inputs. The Mx2 are
from your M values, starting with D_M(N downto N-1), the lonely input
'i' is the previous module's output.
for each pair, if i=D_M(N), keep D_M(N-1) as is.
if not, take not(D_M(N-1)).
plug the eventually modified M bits, and plug them into a M-->1 module
just like in step 1.
you instanciate N-1 of such modules, and chain them. N outputs make the
median value requested.
for small M, you can do it in one cycle. with 48, you'll get poor
performance, so you'll design a sequential counter, or pipeline the
modules. If you try, give feedback, it's interresting.
-------------------------------
Now consider this: the method was patented in 92 by Thomson. I don't
know if it is still pending... How can they dare patent such a method
for a given algorithm? Would you dare patenting for example a fast carry
adder??? I think it is a weak patent (haven't checked the claims),
because just an implementation of a well know algorithm, and an
anteriority shall be findable.