J
Johan Bernspĺng
Guest
I have a signal of an arbitrary width (say 16, but not necessarily a
width that is a power of two) which is unsigned. I want to determine the
position of the most significant (set) bit, i.e. the position of the
highest '1'.
The brute force method for this would be something like this, but I
doubt it is the most efficient method. Any ideas what would improve the
design in terms of device utilization?
bitwidth_calc : process(clk) is
begin
if rising_edge(clk) then
if new_data = '1' then
for i in current_data'range loop
if current_data(current_data'high - i) = '1' then
bit_width <= (current_data'length - i);
end if;
end loop;
else
bit_width <= (others => '0');
end if;
end if;
end process;
regards
johan
--
-----------------------------------------------
Please remove the x's in the email address if
replying to me personally.
Johan Bernspĺng, xjohbex@xfoix.se
width that is a power of two) which is unsigned. I want to determine the
position of the most significant (set) bit, i.e. the position of the
highest '1'.
The brute force method for this would be something like this, but I
doubt it is the most efficient method. Any ideas what would improve the
design in terms of device utilization?
bitwidth_calc : process(clk) is
begin
if rising_edge(clk) then
if new_data = '1' then
for i in current_data'range loop
if current_data(current_data'high - i) = '1' then
bit_width <= (current_data'length - i);
end if;
end loop;
else
bit_width <= (others => '0');
end if;
end if;
end process;
regards
johan
--
-----------------------------------------------
Please remove the x's in the email address if
replying to me personally.
Johan Bernspĺng, xjohbex@xfoix.se