Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

about specifying the range of a counter

Hi,

Actually this is a question about VHDL.

I need a counter which is loaded with two different initial values T1 or T2 in different cases and then counts down to 0.

How do I specify the range of the counter in declaration?

constant T1 : integer := AA;

constant T2 : integer := BB;

signal cnt : integer range 0 to ??; (here I need an expression to find the larger number of AA and BB)

Is it possible to do it in VHDL?

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    
    function find_larger(a, b : integer) return integer is
    begin
      if a >= b then return a
      else return b;
      end if;
    end function find_larger;
    ....
    signal cnt : integer range 0 to find_larger(T1, T2);