The comparison functions

The basic comparison operations, less than (<), less than or equal (<=) greater than (>), greater than or equal (>=) equal to (=) and not equal to (/=) are defined on the unsigned and signed types.

Each of the operators can take unsigned, signed and integer values as arguments. They all return boolean values.

Note that this library doesn't allow you to do comparisons on std_logic_vector values. That's because it's impossible for it to determine whether a particular std_logic_vector is representing a signed or unsigned value. To do this, you need to use either the std_logic_unsigned or std_logic_signed libraries.

Examples

signal u1, u2 : unsigned (3 downto 0);
signal s1 : signed (3 downto 0);
signal o1,o2 : std_logic;
...
u1 <= "1001";    -- = 9
u2 <= "0111";    -- = 7
s1 <= "1001";    -- = -7
wait for 10 ns;
if u1 > u2 then
  o1 <= '1';       -- o1 set to '1'
else
  o1 <= '0';
end if;
if s1 > u2 then
  o2 <= '1';
else
  o2 <= '0';       -- o2 set to '0'
end if;