summaryrefslogtreecommitdiffstats
path: root/sdram_util.vhd
diff options
context:
space:
mode:
Diffstat (limited to 'sdram_util.vhd')
-rw-r--r--sdram_util.vhd50
1 files changed, 50 insertions, 0 deletions
diff --git a/sdram_util.vhd b/sdram_util.vhd
new file mode 100644
index 0000000..7dfcb47
--- /dev/null
+++ b/sdram_util.vhd
@@ -0,0 +1,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;
+
+
+
+
+