aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/openieee/numeric_std-body.v93
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/openieee/numeric_std-body.v93')
-rw-r--r--libraries/openieee/numeric_std-body.v93192
1 files changed, 162 insertions, 30 deletions
diff --git a/libraries/openieee/numeric_std-body.v93 b/libraries/openieee/numeric_std-body.v93
index 6a3817e23..0625a49f0 100644
--- a/libraries/openieee/numeric_std-body.v93
+++ b/libraries/openieee/numeric_std-body.v93
@@ -370,7 +370,7 @@ package body NUMERIC_STD is
end std_match;
- 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_STD 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);
@@ -616,7 +616,7 @@ package body NUMERIC_STD 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);
@@ -654,7 +654,7 @@ package body NUMERIC_STD 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);
@@ -868,7 +868,7 @@ package body NUMERIC_STD 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;
@@ -906,7 +906,7 @@ package body NUMERIC_STD 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;
@@ -1078,7 +1078,7 @@ package body NUMERIC_STD 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);
@@ -1124,7 +1124,7 @@ package body NUMERIC_STD 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);
@@ -1170,7 +1170,7 @@ package body NUMERIC_STD 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);
@@ -1282,7 +1282,7 @@ package body NUMERIC_STD 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);
@@ -1346,7 +1346,7 @@ package body NUMERIC_STD 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);
@@ -1411,7 +1411,7 @@ package body NUMERIC_STD 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);
@@ -1798,7 +1798,7 @@ package body NUMERIC_STD is
return res;
end "xnor";
- 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;
@@ -1831,7 +1831,7 @@ package body NUMERIC_STD 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;
@@ -1949,7 +1949,7 @@ package body NUMERIC_STD is
return res;
end scompare;
- function "=" (l : UNSIGNED; r : UNSIGNED) return boolean
+ function "=" (l, r : UNSIGNED) return boolean
is
variable res : compare_type;
begin
@@ -1970,7 +1970,7 @@ package body NUMERIC_STD 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
@@ -2093,7 +2093,7 @@ package body NUMERIC_STD 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
@@ -2114,7 +2114,7 @@ package body NUMERIC_STD 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
@@ -2237,7 +2237,7 @@ package body NUMERIC_STD 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
@@ -2258,7 +2258,7 @@ package body NUMERIC_STD 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
@@ -2381,7 +2381,7 @@ package body NUMERIC_STD 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
@@ -2402,7 +2402,7 @@ package body NUMERIC_STD 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
@@ -2525,7 +2525,7 @@ package body NUMERIC_STD 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
@@ -2546,7 +2546,7 @@ package body NUMERIC_STD 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
@@ -2669,7 +2669,7 @@ package body NUMERIC_STD 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
@@ -2690,7 +2690,7 @@ package body NUMERIC_STD 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
@@ -2843,7 +2843,7 @@ package body NUMERIC_STD 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;
@@ -2859,7 +2859,7 @@ package body NUMERIC_STD 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;
@@ -2875,6 +2875,72 @@ package body NUMERIC_STD is
return res;
end rotate_right;
+ function "sll" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED
+ is
+ subtype res_type is UNSIGNED (ARG'length - 1 downto 0);
+ alias arg1 : res_type is arg;
+ variable res : res_type := (others => '0');
+ begin
+ if res'length = 0 then
+ return null_UNSIGNED;
+ end if;
+ if count >= 0 and count <= arg1'left then
+ res (res'left downto count) := arg1 (arg1'left - count downto 0);
+ elsif count < 0 and count >= -arg1'left then
+ res (res'left + count downto 0) := arg1 (arg1'left downto -count);
+ end if;
+ return res;
+ end "sll";
+
+ function "srl" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED
+ is
+ subtype res_type is UNSIGNED (ARG'length - 1 downto 0);
+ alias arg1 : res_type is arg;
+ variable res : res_type := (others => '0');
+ begin
+ if res'length = 0 then
+ return null_UNSIGNED;
+ end if;
+ if count >= 0 and count <= arg1'left then
+ res (res'left - count downto 0) := arg1 (arg1'left downto count);
+ elsif count < 0 and count >= -arg1'left then
+ res (res'left downto -count) := arg1 (arg1'left + count downto 0);
+ end if;
+ return res;
+ end "srl";
+
+ function "rol" (ARG : UNSIGNED; COUNT: integer) return UNSIGNED
+ is
+ subtype res_type is UNSIGNED (ARG'length - 1 downto 0);
+ alias arg1 : res_type is arg;
+ variable res : res_type := (others => '0');
+ variable cnt : natural;
+ begin
+ if res'length = 0 then
+ return null_UNSIGNED;
+ end if;
+ cnt := count mod res'length;
+ res (res'left downto cnt) := arg1 (res'left - cnt downto 0);
+ res (cnt - 1 downto 0) := arg1 (res'left downto res'left - cnt + 1);
+ return res;
+ end "rol";
+
+ function "ror" (ARG : UNSIGNED; COUNT: integer) return UNSIGNED
+ is
+ subtype res_type is UNSIGNED (ARG'length - 1 downto 0);
+ alias arg1 : res_type is arg;
+ variable res : res_type := (others => '0');
+ variable cnt : natural;
+ begin
+ if res'length = 0 then
+ return null_UNSIGNED;
+ end if;
+ cnt := count mod res'length;
+ res (res'left - cnt downto 0) := arg1 (res'left downto cnt);
+ res (res'left downto res'left - cnt + 1) := arg1 (cnt - 1 downto 0);
+ return res;
+ end "ror";
+
function shift_left (ARG : SIGNED; COUNT: NATURAL) return SIGNED
is
subtype res_type is SIGNED (ARG'length - 1 downto 0);
@@ -2905,7 +2971,7 @@ package body NUMERIC_STD 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;
@@ -2921,7 +2987,7 @@ package body NUMERIC_STD 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;
@@ -2936,4 +3002,70 @@ package body NUMERIC_STD is
res (res'left downto res'left - cnt + 1) := arg1 (cnt - 1 downto 0);
return res;
end rotate_right;
+
+ function "sll" (ARG : SIGNED; COUNT: INTEGER) return SIGNED
+ is
+ subtype res_type is SIGNED (ARG'length - 1 downto 0);
+ alias arg1 : res_type is arg;
+ variable res : res_type := (others => '0');
+ begin
+ if res'length = 0 then
+ return null_SIGNED;
+ end if;
+ if count >= 0 and count <= arg1'left then
+ res (res'left downto count) := arg1 (arg1'left - count downto 0);
+ elsif count < 0 and count >= -arg1'left then
+ res (res'left + count downto 0) := arg1 (arg1'left downto -count);
+ end if;
+ return res;
+ end "sll";
+
+ function "srl" (ARG : SIGNED; COUNT: INTEGER) return SIGNED
+ is
+ subtype res_type is SIGNED (ARG'length - 1 downto 0);
+ alias arg1 : res_type is arg;
+ variable res : res_type := (others => '0');
+ begin
+ if res'length = 0 then
+ return null_SIGNED;
+ end if;
+ if count >= 0 and count <= arg1'left then
+ res (res'left - count downto 0) := arg1 (arg1'left downto count);
+ elsif count < 0 and count >= -arg1'left then
+ res (res'left downto -count) := arg1 (arg1'left + count downto 0);
+ end if;
+ return res;
+ end "srl";
+
+ function "rol" (ARG : SIGNED; COUNT: integer) return SIGNED
+ is
+ subtype res_type is SIGNED (ARG'length - 1 downto 0);
+ alias arg1 : res_type is arg;
+ variable res : res_type := (others => '0');
+ variable cnt : natural;
+ begin
+ if res'length = 0 then
+ return null_SIGNED;
+ end if;
+ cnt := count mod res'length;
+ res (res'left downto cnt) := arg1 (res'left - cnt downto 0);
+ res (cnt - 1 downto 0) := arg1 (res'left downto res'left - cnt + 1);
+ return res;
+ end "rol";
+
+ function "ror" (ARG : SIGNED; COUNT: integer) return SIGNED
+ is
+ subtype res_type is SIGNED (ARG'length - 1 downto 0);
+ alias arg1 : res_type is arg;
+ variable res : res_type := (others => '0');
+ variable cnt : natural;
+ begin
+ if res'length = 0 then
+ return null_SIGNED;
+ end if;
+ cnt := count mod res'length;
+ res (res'left - cnt downto 0) := arg1 (res'left downto cnt);
+ res (res'left downto res'left - cnt + 1) := arg1 (cnt - 1 downto 0);
+ return res;
+ end "ror";
end NUMERIC_STD;