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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.communication/] [pkt_codec_mk2/] [1.0/] [vhd/] [log2_pkg.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : log2_ceil function
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : log2_pkg.vhdl
6
-- Author     : Lasse Lehtonen
7
-- Company    : 
8
-- Created    : 2010-06-16
9
-- Last update: 2011-10-07
10
-- Platform   : 
11
-- Standard   : VHDL'93
12
-------------------------------------------------------------------------------
13
-- Description: 
14
-------------------------------------------------------------------------------
15
-- Copyright (c) 2010 
16
-------------------------------------------------------------------------------
17
-- Revisions  :
18
-- Date        Version  Author  Description
19
-- 2010-06-16  1.0      ase     Created
20
-------------------------------------------------------------------------------
21
 
22
library ieee;
23
use ieee.std_logic_1164.all;
24
 
25
 
26
-------------------------------------------------------------------------------
27
-- PACKAGE DECLARATION
28
-------------------------------------------------------------------------------
29
 
30
package log2_pkg is
31
 
32
  -----------------------------------------------------------------------------
33
  -- HELPER FUNCTIONS
34
  -----------------------------------------------------------------------------
35
 
36
  -- purpose: Return ceiling log 2 of n
37
  function log2_ceil (
38
    constant n : positive)
39
    return positive;
40
 
41
end package log2_pkg;
42
 
43
 
44
-------------------------------------------------------------------------------
45
-- PACKAGE BODY
46
-------------------------------------------------------------------------------
47
 
48
package body log2_pkg is
49
 
50
  -- purpose: Return ceiling log 2 of n
51
  function log2_ceil (
52
    constant n : positive)
53
    return positive is
54
    variable retval : positive := 1;
55
  begin  -- function log2_ceil
56
    while 2**retval < n loop
57
      retval := retval + 1;
58
    end loop;
59
    return retval;
60
  end function log2_ceil;
61
 
62
end package body log2_pkg;

powered by: WebSVN 2.1.0

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