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

logarithm to the basis 2

Altera_Forum
Honored Contributor II
1,045 Views

Hi, 

 

is there a way to calculate the logarithm to the basis 2 of a generic parameter? I don't need a synthesizeable circuit. I just want the compiler to to calculate an integer and asign it to another generic parameter of a submodule. 

 

Thanks! 

Sören
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
322 Views

In VHDL: 

function log2 (x : positive) return natural is begin if x = 1 then return 0 ; else return log2(x / 2) + 1; end if; end function log2 ;
0 Kudos
Altera_Forum
Honored Contributor II
322 Views

Many thanks!

0 Kudos
Reply