Disable the non-standard library and use the standard type signed, which has a built-in function abs:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
...
port (
X: in std_logic_vector(31 downto 0);
Y: in std_logic_vector(31 downto 0);
F: out std_logic_vector(31 downto 0)
);
...
process(X,Y) is
begin
F <= std_logic_vector(abs(signed(X)-signed(Y)));
end process;
There are many [possibly unnecessary] conversions between std_logic_vectorand on the last line signed, so you might prefer this interface if it makes sense with the rest of your design:
port (
X: in signed(31 downto 0);
Y: in signed(31 downto 0);
F: out signed(31 downto 0)
);
Then the last line is simple:
F <= abs(X-Y);
source
share