I try to code a counter with a range from a to b that could be flipped top to bottom when the two generic parameters a and b fulfill a>b. Whether flipping occurs could be determined at compile time by comparing the values and setting a constant to hold the result (used later in the logic). However, the comparison fails. I have distilled the following minimal failing code example:
library IEEE;
use IEEE.std_logic_1164.all;
entity test is
end entity test;
architecture b_test of test is
begin
process
constant t : bit := 3 < 7;
begin
wait;
end process;
end architecture b_test;
ghdl analyze complains about the line with the constant declaration:
no function declarations for operator "<"
The same error is reported if instead a constant, a variable is declared like
variable t : bit := 1 < 3;
How can I precompute a bit typed variable based on comparison of integer values a and b (actually a and b would be generic paramters of a subtype integer range)?
The constant should be defined with type
boolean:Relational operators return that type, see e.g.: