OpenCores
URL https://opencores.org/ocsvn/special_functions_unit/special_functions_unit/trunk

Subversion Repositories special_functions_unit

[/] [special_functions_unit/] [Open_source_SFU/] [log2_pkg.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 divadnauj
-- f_log2 calcula el logaritmo natural de dos de un numero,
2
-- retorna entero: f_log2(23) = 5, f_log2(16) = 4, f_log2(17)=5 
3
library ieee;
4
use ieee.std_logic_1164.all;
5
 
6
 
7
package log2_pkg is
8
 
9
        function f_log2 (x : positive) return natural;
10
 
11
end package;
12
 
13
 
14
package body log2_pkg is
15
 
16
        function f_log2 (x : positive) return natural is
17
                variable i : natural:=0;
18
        begin
19
                i := 0;
20
                while (2**i < x) and i < 31 loop
21
                                i := i + 1;
22
                end loop;
23
                return i;
24
        end function;
25
 
26
end package body;

powered by: WebSVN 2.1.0

© copyright 1999-2022 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.