Home    --    Hierarchy    --    Packages    --    Entities    --    Instantiations    --    Sources

Source file System09_base/common.vhd

  1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 
 24 
 25 
 26 
 27 
 28 
 29 
 30 
 31 
 32 
 33 
 34 
 35 
 36 
 37 
 38 
 39 
 40 
 41 
 42 
 43 
 44 
 45 
 46 
 47 
 48 
 49 
 50 
 51 
 52 
 53 
 54 
 55 
 56 
 57 
 58 
 59 
 60 
 61 
 62 
 63 
 64 
 65 
 66 
 67 
 68 
 69 
 70 
 71 
 72 
 73 
 74 
 75 
 76 
 77 
 78 
 79 
 80 
 81 
 82 
 83 
 84 
 85 
 86 
 87 
 88 
 89 
 90 
 91 
 92 
 93 
 94 
 95 
 96 
 97 
 98 
 99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
--------------------------------------------------------------------
-- Company : XESS Corp.
-- Engineer : Dave Vanden Bout
-- Creation Date : 05/17/2005
-- Copyright : 2005, XESS Corp
-- Tool Versions : WebPACK 6.3.03i
--
-- Description:
-- Miscellaneous VHDL constants and functions
--
-- Revision:
-- 1.0.0
--
-- Additional Comments:
-- 1.1.0:
-- Added int_select() and real_select functions.
-- 1.0.0:
-- Initial release.
--
-- License:
-- This code can be freely distributed and modified as long as
-- this header is not removed.
--------------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
--* @brief Miscellaneous VHDL constants and functions
--*
--* @author Dave Vanden Bout
--* @version 1.1.0 from 05/17/2005
package common is
constant YES : std_logic := '1';
constant NO : std_logic := '0';
constant HI : std_logic := '1';
constant LO : std_logic := '0';
constant ONE : std_logic := '1';
constant ZERO : std_logic := '0';
-- convert a Boolean to a std_logic
function boolean2stdlogic(b : in boolean) return std_logic;
-- find the base-2 logarithm of a number
function log2(v : in natural) return natural;
-- select one of two integers based on a Boolean
function int_select(s : in boolean; a : in integer; b : in integer) return integer;
-- select one of two reals based on a Boolean
function real_select(s : in boolean; a : in real; b : in real) return real;
end package common;
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
package body common is
--* convert a Boolean to a std_logic
function boolean2stdlogic(b : in boolean) return std_logic is
variable s : std_logic;
begin
if b then
s := '1';
else
s := '0';
end if;
return s;
end function boolean2stdlogic;
--* find the base 2 logarithm of a number
function log2(v : in natural) return natural is
variable n : natural;
variable logn : natural;
begin
n := 1;
for i in 0 to 128 loop
logn := i;
exit when (n >= v);
n := n * 2;
end loop;
return logn;
end function log2;
--* select one of two integers based on a Boolean
function int_select(s : in boolean; a : in integer; b : in integer) return integer is
begin
if s then
return a;
else
return b;
end if;
return a;
end function int_select;
--* select one of two reals based on a Boolean
function real_select(s : in boolean; a : in real; b : in real) return real is
begin
if s then
return a;
else
return b;
end if;
return a;
end function real_select;
end package body common;

Generated on 1 Jan 2018 19:48:42 with VHDocL V0.2.6