summaryrefslogtreecommitdiffstats
path: root/sdram_util.vhd
blob: 7dfcb47929c663f3d4b0f8e00d47e63ad8ed40f3 (plain)
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
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

package sdram_util is

subtype uint3_t is integer range 0 to 7;
subtype uint4_t is integer range 0 to 15;
subtype uint8_t is integer range 0 to 255;
subtype uint13_t is integer range 0 to 8191;
subtype cs_n_t is std_logic_vector(0 downto 0);
subtype addr_t is std_logic_vector(23 downto 0);
subtype data_t is std_logic_vector(15 downto 0);
subtype dqm_t is std_logic_vector(1 downto 0);


  function b2l_ah(constant val : in boolean) return std_logic;
  function l2b_ah(constant val : in std_logic) return boolean;
  function l2b_al(constant val : in std_logic) return boolean;

end package;


package body sdram_util is 

  -- convert boolean to active high logic 
  function b2l_ah(constant val : in boolean) return std_logic is begin
    if val then
      return '1';
    else
      return '0';
    end if;
  end function; 


  -- convert active high logic to boolean value
  function l2b_ah(constant val : in std_logic) return boolean is begin
    return val='1';
  end function; 

  function l2b_al(constant val : in std_logic) return boolean is begin
    return val='0';
  end function; 

end package body;