Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16613 Discussions

about specifying the range of a counter

Altera_Forum
Honored Contributor II
878 Views

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?
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
199 Views

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);

0 Kudos
Altera_Forum
Honored Contributor II
199 Views

The IEEE library has a MAX function for the same purpose.

0 Kudos
Reply