J
Jonathan Bromley
Guest
On Fri, 30 Jul 2004 15:23:40 +0200, Michael Riepe
<michael@stud.uni-hannover.de> wrote:
original poster on this thread. I agree that it's nice.
However, in Xilinx and Altera FPGAs I suspect that it may be
less attractive than the thermometer code version, because
you can very easily construct a thermometer code using the
carry chain (if you're prepared to instantiate the MUXCYs
by hand, as others have noted).
Fun stuff.
--
Jonathan Bromley
Jonathan Bromley
<michael@stud.uni-hannover.de> wrote:
I already posted essentially this solution in response to theHi.
Jonathan Bromley wrote:
[...]
My delight in recursive
solutions is showing itself again
That's a nice solution, but probably the second best one. The problem is
that you'll have to get the thermometer code first. But you can also
process the original operand directly:
function findmsb (X : in std_ulogic_vector) return std_ulogic_vector is
constant N : natural := X'length; -- assume it's a power of two
constant xx : std_ulogic_vector(N-1 downto 0);
begin
xx := to_X01(X); -- convert to something more useful
if N = 2 then
return xx(1 downto 1);
elsif xx(N-1 downto N/2) = (N-1 downto N/2 => '0') then
original poster on this thread. I agree that it's nice.
However, in Xilinx and Altera FPGAs I suspect that it may be
less attractive than the thermometer code version, because
you can very easily construct a thermometer code using the
carry chain (if you're prepared to instantiate the MUXCYs
by hand, as others have noted).
Or by concatenating an extra redundant bit whose value is 1.The only
drawback is that a zero operand and an operand with only the LSB set
will have the same result (others => '0'). But you can change that by
adding another MUX at the output:
Fun stuff.
--
Jonathan Bromley
Jonathan Bromley