Public paste
Undefined
By: global-p.vhd | Date: Mar 20 2008 09:55 | Format: None | Expires: never | Size: 2.83 KB | Hits: 1291

  1. -------------------------------------------------------------------------------
  2. -- Title      : Global Project Package
  3. -- Project    : Audio Signal Processing
  4. -------------------------------------------------------------------------------
  5. -- $Id: Global-p.vhd,v 1.7 2003/12/01 19:51:06 pfaff Mod $
  6. -------------------------------------------------------------------------------
  7. -- Author     : Copyright 2003: Markus Pfaff
  8. -- Standard   : Using VHDL'93
  9. -- Simulation : Model Technology Modelsim
  10. -- Synthesis  : Exemplar Leonardo
  11. -------------------------------------------------------------------------------
  12. -- Description:
  13. --
  14. -------------------------------------------------------------------------------
  15.  
  16. library ieee;
  17. use ieee.std_logic_1164.all;
  18. use ieee.numeric_std.all;
  19.  
  20. package Global is
  21.  
  22.   -----------------------------------------------------------------------------
  23.   -- Definitions that are not project specific.
  24.   -----------------------------------------------------------------------------
  25.   -- Avoid the traps of inverted logic and make the code more text like by
  26.   -- reducing numbers.
  27.   constant cActivated   : std_ulogic := '1';
  28.   constant cInactivated : std_ulogic := '0';
  29.  
  30.   -- Now the same for inverted logic.
  31.   constant cnActivated   : std_ulogic := '0';
  32.   constant cnInactivated : std_ulogic := '1';
  33.  
  34.   -- constants for unitEdgeDetector
  35.   constant cDetectRisingEdge  : natural := 0;
  36.   constant cDetectFallingEdge : natural := 1;
  37.   constant cDetectAnyEdge     : natural := 2;
  38.  
  39.   -----------------------------------------------------------------------------
  40.   -- Project specific definitions that will typically exist for every project.
  41.   -----------------------------------------------------------------------------
  42.   -- Reset polarity
  43.   -- This constant is not used in this project. Instead a low active reset
  44.   -- is used.
  45.   -- constant cResetActive : std_ulogic := cnActivated;
  46.  
  47.   ------------------------------------------------------------------------------
  48.   -- Function Definitions
  49.   ------------------------------------------------------------------------------
  50.   -- function log2 returns the logarithm of base 2 as an integer
  51.   function LogDualis(cNumber : natural) return natural;
  52.  
  53.  
  54. end Global;
  55.  
  56.  
  57.  
  58. package body Global is
  59.  
  60.  
  61.   -- Function LogDualis returns the logarithm of base 2 as an integer.
  62.   -- Although the implementation of this function was not done with synthesis
  63.   -- efficiency in mind, the function has to be synthesizable, because it is
  64.   -- often used in static calcualions.
  65.   function LogDualis(cNumber : natural) return natural is
  66.     variable vClimbUp : natural := 1;
  67.     variable vResult  : natural;
  68.   begin
  69.     while vClimbUp < cNumber loop
  70.       vClimbUp := vClimbUp * 2;
  71.       vResult  := vResult+1;
  72.     end loop;
  73.     return vResult;
  74.   end LogDualis;
  75.  
  76.  
  77. end Global;