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

Subversion Repositories mod_sim_exp

[/] [mod_sim_exp/] [trunk/] [rtl/] [vhdl/] [core/] [std_functions.vhd] - Blame information for rev 63

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 59 JonasDC
----------------------------------------------------------------------  
2
----  std_functions                                               ---- 
3
----                                                              ---- 
4
----  This file is part of the                                    ----
5
----    Modular Simultaneous Exponentiation Core project          ---- 
6
----    http://www.opencores.org/cores/mod_sim_exp/               ---- 
7
----                                                              ---- 
8
----  Description                                                 ---- 
9
----    package with standard functions used in this project      ----
10
----                                                              ----
11
----  Authors:                                                    ----
12
----      - Geoffrey Ottoy, DraMCo research group                 ----
13
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
14
----                                                              ---- 
15
---------------------------------------------------------------------- 
16
----                                                              ---- 
17
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
18
----                                                              ---- 
19
---- This source file may be used and distributed without         ---- 
20
---- restriction provided that this copyright statement is not    ---- 
21
---- removed from the file and that any derivative work contains  ---- 
22
---- the original copyright notice and the associated disclaimer. ---- 
23
----                                                              ---- 
24
---- This source file is free software; you can redistribute it   ---- 
25
---- and/or modify it under the terms of the GNU Lesser General   ---- 
26
---- Public License as published by the Free Software Foundation; ---- 
27
---- either version 2.1 of the License, or (at your option) any   ---- 
28
---- later version.                                               ---- 
29
----                                                              ---- 
30
---- This source is distributed in the hope that it will be       ---- 
31
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
32
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
33
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
34
---- details.                                                     ---- 
35
----                                                              ---- 
36
---- You should have received a copy of the GNU Lesser General    ---- 
37
---- Public License along with this source; if not, download it   ---- 
38
---- from http://www.opencores.org/lgpl.shtml                     ---- 
39
----                                                              ---- 
40
----------------------------------------------------------------------
41
library ieee;
42
use ieee.std_logic_1164.all;
43
use ieee.std_logic_unsigned.all;
44
 
45
package std_functions is
46
  function maxV(L, R: INTEGER) return INTEGER;
47
  function minV(L, R: INTEGER) return INTEGER;
48
  function log2 (val: INTEGER) return natural;
49
end std_functions;
50
 
51
package body std_functions is
52
  function maxV(L, R: INTEGER) return INTEGER is
53
  begin
54
      if L > R then
55
          return L;
56
      else
57
          return R;
58
      end if;
59
  end;
60
 
61
  function minV(L, R: INTEGER) return INTEGER is
62
  begin
63
      if L < R then
64
          return L;
65
      else
66
          return R;
67
      end if;
68
  end;
69
 
70
  function log2 (val: INTEGER) return natural is
71
    variable res : natural;
72
  begin
73
        for i in 0 to 31 loop
74
            if (val <= (2**i)) then
75
                res := i;
76
                exit;
77
            end if;
78
        end loop;
79
        return res;
80
  end function Log2;
81
end std_functions;

powered by: WebSVN 2.1.0

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