We could not be allowed to assign and integer to a binary value. But we can use a conversion function such as To_unsigned to allow us to achieve this.
use IEEE.NUMERIC_STD.all;
...
signal A: Unsigned(7 downto 0);
signal F: Unsigned(2 downto 0);
...
Priority_encoder: process (A)
begin
F <= "000";
for I in 0 to 7 loop
if A(I) = '1' then
F <= To_unsigned(I, 3);
exit;
end if;
end loop;
end process;
---
The example below is used to assign an integer to a type STD_LOGIC.
use IEEE.NUMERIC_STD.all;
...
signal A: Unsigned(7 downto 0);
signal S: Unsigned(2 downto 0);
signal G: Std_logic;
...
Mux: G <= A(To_integer(S));
Reference
This blog post contains notes taken when working through the Doulos Pacemaker tutorial. Any content copied from the tutorial has been reproduced with permission. http://www.doulos.com.
No comments:
Post a Comment