diff options
Diffstat (limited to 'libraries/openieee/numeric_bit-body.v87')
-rw-r--r-- | libraries/openieee/numeric_bit-body.v87 | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/libraries/openieee/numeric_bit-body.v87 b/libraries/openieee/numeric_bit-body.v87 index 83f1a80..3bdc634 100644 --- a/libraries/openieee/numeric_bit-body.v87 +++ b/libraries/openieee/numeric_bit-body.v87 @@ -176,7 +176,7 @@ package body NUMERIC_BIT is end TO_SIGNED; - function "+" (l : UNSIGNED; r : UNSIGNED) return UNSIGNED + function "+" (l, r : UNSIGNED) return UNSIGNED is constant lft : integer := MAX (l'length, r'length) - 1; subtype res_type is UNSIGNED (lft downto 0); @@ -206,7 +206,7 @@ package body NUMERIC_BIT is return res; end "+"; - function "+" (l : SIGNED; r : SIGNED) return SIGNED + function "+" (l, r : SIGNED) return SIGNED is constant lft : integer := MAX (l'length, r'length) - 1; subtype res_type is SIGNED (lft downto 0); @@ -376,7 +376,7 @@ package body NUMERIC_BIT is return res; end "+"; - function "-" (l : UNSIGNED; r : UNSIGNED) return UNSIGNED + function "-" (l, r : UNSIGNED) return UNSIGNED is constant lft : integer := MAX (l'length, r'length) - 1; subtype res_type is UNSIGNED (lft downto 0); @@ -407,7 +407,7 @@ package body NUMERIC_BIT is return res; end "-"; - function "-" (l : SIGNED; r : SIGNED) return SIGNED + function "-" (l, r : SIGNED) return SIGNED is constant lft : integer := MAX (l'length, r'length) - 1; subtype res_type is SIGNED (lft downto 0); @@ -582,7 +582,7 @@ package body NUMERIC_BIT is return res; end "-"; - function "*" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED + function "*" (L, R : UNSIGNED) return UNSIGNED is alias la : UNSIGNED (L'Length - 1 downto 0) is l; alias ra : UNSIGNED (R'Length - 1 downto 0) is r; @@ -616,7 +616,7 @@ package body NUMERIC_BIT is return res; end "*"; - function "*" (L : SIGNED; R : SIGNED) return SIGNED + function "*" (L, R : SIGNED) return SIGNED is alias la : SIGNED (L'Length - 1 downto 0) is l; alias ra : SIGNED (R'Length - 1 downto 0) is r; @@ -781,7 +781,7 @@ package body NUMERIC_BIT is return res; end size_signed; - function "/" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED + function "/" (L, R : UNSIGNED) return UNSIGNED is subtype l_type is UNSIGNED (L'length - 1 downto 0); subtype r_type is UNSIGNED (R'length - 1 downto 0); @@ -821,7 +821,7 @@ package body NUMERIC_BIT is return resize (to_unsigned (l, l_size) / r, r'length); end "/"; - function "rem" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED + function "rem" (L, R : UNSIGNED) return UNSIGNED is subtype l_type is UNSIGNED (L'length - 1 downto 0); subtype r_type is UNSIGNED (R'length - 1 downto 0); @@ -861,7 +861,7 @@ package body NUMERIC_BIT is return to_unsigned (l, l_size) rem r; end "rem"; - function "mod" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED + function "mod" (L, R : UNSIGNED) return UNSIGNED is subtype l_type is UNSIGNED (L'length - 1 downto 0); subtype r_type is UNSIGNED (R'length - 1 downto 0); @@ -952,7 +952,7 @@ package body NUMERIC_BIT is return res; end "abs"; - function "/" (L : SIGNED; R : SIGNED) return SIGNED + function "/" (L, R : SIGNED) return SIGNED is subtype l_type is SIGNED (L'length - 1 downto 0); subtype r_type is SIGNED (R'length - 1 downto 0); @@ -1010,7 +1010,7 @@ package body NUMERIC_BIT is return resize (to_signed (l, max (l_size, r'length)) / r, r'length); end "/"; - function "rem" (L : SIGNED; R : SIGNED) return SIGNED + function "rem" (L, R : SIGNED) return SIGNED is subtype l_type is SIGNED (L'length - 1 downto 0); subtype r_type is SIGNED (R'length - 1 downto 0); @@ -1069,7 +1069,7 @@ package body NUMERIC_BIT is return to_signed (l, l_size) rem r; end "rem"; - function "mod" (L : SIGNED; R : SIGNED) return SIGNED + function "mod" (L, R : SIGNED) return SIGNED is subtype l_type is SIGNED (L'length - 1 downto 0); subtype r_type is SIGNED (R'length - 1 downto 0); @@ -1410,7 +1410,7 @@ package body NUMERIC_BIT is return res; end "xor"; - function ucompare (l : UNSIGNED; r : UNSIGNED) return compare_type + function ucompare (l, r : UNSIGNED) return compare_type is constant sz : integer := MAX (l'length, r'length) - 1; alias la : UNSIGNED (l'length - 1 downto 0) is l; @@ -1440,7 +1440,7 @@ package body NUMERIC_BIT is return res; end ucompare; - function scompare (l : SIGNED; r : SIGNED) return compare_type + function scompare (l, r : SIGNED) return compare_type is constant sz : integer := MAX (l'length, r'length) - 1; alias la : SIGNED (l'length - 1 downto 0) is l; @@ -1549,7 +1549,7 @@ package body NUMERIC_BIT is return res; end scompare; - function "=" (l : UNSIGNED; r : UNSIGNED) return boolean + function "=" (l, r : UNSIGNED) return boolean is variable res : compare_type; begin @@ -1564,7 +1564,7 @@ package body NUMERIC_BIT is return res = compare_eq; end "="; - function "=" (l : SIGNED; r : SIGNED) return boolean + function "=" (l, r : SIGNED) return boolean is variable res : compare_type; begin @@ -1657,7 +1657,7 @@ package body NUMERIC_BIT is return compare_eq = res; end "="; - function "/=" (l : UNSIGNED; r : UNSIGNED) return boolean + function "/=" (l, r : UNSIGNED) return boolean is variable res : compare_type; begin @@ -1672,7 +1672,7 @@ package body NUMERIC_BIT is return res /= compare_eq; end "/="; - function "/=" (l : SIGNED; r : SIGNED) return boolean + function "/=" (l, r : SIGNED) return boolean is variable res : compare_type; begin @@ -1765,7 +1765,7 @@ package body NUMERIC_BIT is return compare_eq /= res; end "/="; - function ">" (l : UNSIGNED; r : UNSIGNED) return boolean + function ">" (l, r : UNSIGNED) return boolean is variable res : compare_type; begin @@ -1780,7 +1780,7 @@ package body NUMERIC_BIT is return res > compare_eq; end ">"; - function ">" (l : SIGNED; r : SIGNED) return boolean + function ">" (l, r : SIGNED) return boolean is variable res : compare_type; begin @@ -1873,7 +1873,7 @@ package body NUMERIC_BIT is return compare_eq > res; end ">"; - function ">=" (l : UNSIGNED; r : UNSIGNED) return boolean + function ">=" (l, r : UNSIGNED) return boolean is variable res : compare_type; begin @@ -1888,7 +1888,7 @@ package body NUMERIC_BIT is return res >= compare_eq; end ">="; - function ">=" (l : SIGNED; r : SIGNED) return boolean + function ">=" (l, r : SIGNED) return boolean is variable res : compare_type; begin @@ -1981,7 +1981,7 @@ package body NUMERIC_BIT is return compare_eq >= res; end ">="; - function "<" (l : UNSIGNED; r : UNSIGNED) return boolean + function "<" (l, r : UNSIGNED) return boolean is variable res : compare_type; begin @@ -1996,7 +1996,7 @@ package body NUMERIC_BIT is return res < compare_eq; end "<"; - function "<" (l : SIGNED; r : SIGNED) return boolean + function "<" (l, r : SIGNED) return boolean is variable res : compare_type; begin @@ -2089,7 +2089,7 @@ package body NUMERIC_BIT is return compare_eq < res; end "<"; - function "<=" (l : UNSIGNED; r : UNSIGNED) return boolean + function "<=" (l, r : UNSIGNED) return boolean is variable res : compare_type; begin @@ -2104,7 +2104,7 @@ package body NUMERIC_BIT is return res <= compare_eq; end "<="; - function "<=" (l : SIGNED; r : SIGNED) return boolean + function "<=" (l, r : SIGNED) return boolean is variable res : compare_type; begin @@ -2227,7 +2227,7 @@ package body NUMERIC_BIT is return res; end shift_right; - function rotate_left (ARG : UNSIGNED; COUNT: NATURAL) return UNSIGNED + function rotate_left (ARG : UNSIGNED; COUNT: natural) return UNSIGNED is subtype res_type is UNSIGNED (ARG'length - 1 downto 0); alias arg1 : res_type is arg; @@ -2243,7 +2243,7 @@ package body NUMERIC_BIT is return res; end rotate_left; - function rotate_right (ARG : UNSIGNED; COUNT: NATURAL) return UNSIGNED + function rotate_right (ARG : UNSIGNED; COUNT: natural) return UNSIGNED is subtype res_type is UNSIGNED (ARG'length - 1 downto 0); alias arg1 : res_type is arg; @@ -2289,7 +2289,7 @@ package body NUMERIC_BIT is return res; end shift_right; - function rotate_left (ARG : SIGNED; COUNT: NATURAL) return SIGNED + function rotate_left (ARG : SIGNED; COUNT: natural) return SIGNED is subtype res_type is SIGNED (ARG'length - 1 downto 0); alias arg1 : res_type is arg; @@ -2305,7 +2305,7 @@ package body NUMERIC_BIT is return res; end rotate_left; - function rotate_right (ARG : SIGNED; COUNT: NATURAL) return SIGNED + function rotate_right (ARG : SIGNED; COUNT: natural) return SIGNED is subtype res_type is SIGNED (ARG'length - 1 downto 0); alias arg1 : res_type is arg; @@ -2320,4 +2320,14 @@ package body NUMERIC_BIT is res (res'left downto res'left - cnt + 1) := arg1 (cnt - 1 downto 0); return res; end rotate_right; + + function rising_edge (signal s : bit) return boolean is + begin + return s'event and s = '1'; + end rising_edge; + + function falling_edge (signal s : bit) return boolean is + begin + return s'event and s = '0'; + end falling_edge; end NUMERIC_BIT; |