diff options
Diffstat (limited to 'libraries/openieee')
-rwxr-xr-x | libraries/openieee/build_1164.py | 10 | ||||
-rwxr-xr-x | libraries/openieee/build_numeric.py | 80 | ||||
-rw-r--r-- | libraries/openieee/numeric_bit-body.proto | 10 | ||||
-rw-r--r-- | libraries/openieee/numeric_bit-body.v87 | 70 | ||||
-rw-r--r-- | libraries/openieee/numeric_bit-body.v93 | 202 | ||||
-rw-r--r-- | libraries/openieee/numeric_bit.proto | 3 | ||||
-rw-r--r-- | libraries/openieee/numeric_bit.v87 | 63 | ||||
-rw-r--r-- | libraries/openieee/numeric_bit.v93 | 63 | ||||
-rw-r--r-- | libraries/openieee/numeric_common.proto | 60 | ||||
-rw-r--r-- | libraries/openieee/numeric_std-body.v87 | 60 | ||||
-rw-r--r-- | libraries/openieee/numeric_std-body.v93 | 192 | ||||
-rw-r--r-- | libraries/openieee/numeric_std.v87 | 60 | ||||
-rw-r--r-- | libraries/openieee/numeric_std.v93 | 60 | ||||
-rw-r--r-- | libraries/openieee/std_logic_1164-body.v87 | 26 | ||||
-rw-r--r-- | libraries/openieee/std_logic_1164-body.v93 | 28 | ||||
-rw-r--r-- | libraries/openieee/std_logic_1164.v87 | 18 | ||||
-rw-r--r-- | libraries/openieee/std_logic_1164.v93 | 18 | ||||
-rw-r--r-- | libraries/openieee/std_logic_1164.vhdl | 16 |
18 files changed, 725 insertions, 314 deletions
diff --git a/libraries/openieee/build_1164.py b/libraries/openieee/build_1164.py index 20dd2dc3e..06f25c30b 100755 --- a/libraries/openieee/build_1164.py +++ b/libraries/openieee/build_1164.py @@ -117,7 +117,7 @@ vec_types = ['ulogic', 'logic'] def disp_scalar_binary(fun): "Generate scalar binary function body" w(""" - function "{0}" (l, r : std_ulogic) return UX01 is + function "{0}" (l : std_ulogic; r : std_ulogic) return UX01 is begin return {0}_table (l, r); end "{0}";\n""".format(fun)) @@ -221,11 +221,11 @@ def disp_bv_to_sv_conv(typ): def disp_sv_to_sv_conv(s,d): "Generate logic vector to logic vector function body" w(""" - function to_std{1}vector (b : std_{0}_vector) return std_{1}_vector + function to_std{1}vector (s : std_{0}_vector) return std_{1}_vector is - subtype res_type is std_{1}_vector (b'length - 1 downto 0); + subtype res_type is std_{1}_vector (s'length - 1 downto 0); begin - return res_type (b); + return res_type (s); end to_std{1}vector;\n""".format(s,d)) def disp_all_conv_funcs(): @@ -329,7 +329,7 @@ spec_file='std_logic_1164.vhdl' proto_file='std_logic_1164-body.proto' def gen_body(): - w('-- This file was generated from ' + proto_file + '\n') + w('-- This -*- vhdl -*- file was generated from ' + proto_file + '\n') for line in open(proto_file): if line in pats: pats[line]() diff --git a/libraries/openieee/build_numeric.py b/libraries/openieee/build_numeric.py index a8914d0ce..c00e74e5c 100755 --- a/libraries/openieee/build_numeric.py +++ b/libraries/openieee/build_numeric.py @@ -37,6 +37,8 @@ logic_undefs = {'bit' : "'0'", 'std': "'X'" } logic = 'xx' # Current logic, either bit or std +v93=False + # Stream to write. out=sys.stdout @@ -115,7 +117,7 @@ def extract_extend_bit(name,typ): def disp_vec_vec_binary(func, typ): "Generate vector binary function body" res = """ - function "{0}" (l : {1}; r : {1}) return {1} + function "{0}" (l, r : {1}) return {1} is constant lft : integer := MAX (l'length, r'length) - 1; subtype res_type is {1} (lft downto 0); @@ -366,7 +368,7 @@ def disp_vec_int_compare(func, left, right): def disp_vec_vec_gcompare(func, typ): "Generate comparison function" res = """ - function {func} (l : {typ}; r : {typ}) return compare_type + function {func} (l, r : {typ}) return compare_type is constant sz : integer := MAX (l'length, r'length) - 1; alias la : {typ} (l'length - 1 downto 0) is l; @@ -418,7 +420,7 @@ def disp_vec_vec_gcompare(func, typ): def disp_vec_vec_compare(func, typ): "Generate comparison function" res = """ - function "{func}" (l : {typ}; r : {typ}) return boolean + function "{func}" (l, r : {typ}) return boolean is variable res : compare_type; begin @@ -498,6 +500,40 @@ def disp_resize(typ): end resize;\n""" w(res.format(typ)) +def gen_shift(dir, inv): + if (dir == 'left') ^ inv: + res = """ + res (res'left downto {opp}count) := arg1 (arg1'left {sub} count downto 0);""" + else: + res = """ + res (res'left {sub} count downto 0) := arg1 (arg1'left downto {opp}count);""" + if inv: + return res.format(opp="-", sub="+") + else: + return res.format(opp="", sub="-") + +def disp_shift_op(name, typ, dir): + res = """ + function {0} (ARG : {1}; COUNT: INTEGER) return {1} + is + subtype res_type is {1} (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_{1}; + end if; + if count >= 0 and count <= arg1'left then""" + res += gen_shift(dir, False) + res += """ + elsif count < 0 and count >= -arg1'left then""" + res += gen_shift(dir, True) + res += """ + end if; + return res; + end {0};\n""" + w(res.format(name, typ)) + def disp_shift(name, typ, dir): res = """ function {0} (ARG : {1}; COUNT: NATURAL) return {1} @@ -515,12 +551,7 @@ def disp_shift(name, typ, dir): return null_{1}; end if; if count <= arg1'left then""" - if dir == 'left': - res += """ - res (res'left downto count) := arg1 (arg1'left - count downto 0);""" - else: - res += """ - res (res'left - count downto 0) := arg1 (arg1'left downto count);""" + res += gen_shift(dir, False) res += """ end if; return res; @@ -528,8 +559,14 @@ def disp_shift(name, typ, dir): w(res.format(name, typ)) def disp_rotate(name, typ, dir): + if 'rotate' in name: + count_type = 'natural' + op = 'rem' + else: + count_type = 'integer' + op = 'mod' res = """ - function {0} (ARG : {1}; COUNT: NATURAL) return {1} + function {0} (ARG : {1}; COUNT: {2}) return {1} is subtype res_type is {1} (ARG'length - 1 downto 0); alias arg1 : res_type is arg; @@ -539,7 +576,7 @@ def disp_rotate(name, typ, dir): if res'length = 0 then return null_{1}; end if; - cnt := count rem res'length;""" + cnt := count """ + op + " res'length;" if dir == 'left': res += """ res (res'left downto cnt) := arg1 (res'left - cnt downto 0); @@ -551,11 +588,11 @@ def disp_rotate(name, typ, dir): res += """ return res; end {0};\n""" - w(res.format(name, typ)) + w(res.format(name, typ, count_type)) def disp_vec_vec_mul(func, typ): res = """ - function "{0}" (L : {1}; R : {1}) return {1} + function "{0}" (L, R : {1}) return {1} is alias la : {1} (L'Length - 1 downto 0) is l; alias ra : {1} (R'Length - 1 downto 0) is r; @@ -780,7 +817,7 @@ def disp_divmod(): def disp_vec_vec_udiv(func): res = """ - function "{func}" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED + function "{func}" (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); @@ -853,7 +890,7 @@ def disp_vec_int_udiv(func): def disp_vec_vec_sdiv(func): res = """ - function "{func}" (L : SIGNED; R : SIGNED) return SIGNED + function "{func}" (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); @@ -994,6 +1031,11 @@ def disp_all_log_funcs(): disp_shift('shift_' + d, t, d); for d in ['left', 'right']: disp_rotate('rotate_' + d, t, d); + if v93: + disp_shift_op('"sll"', t, 'left') + disp_shift_op('"srl"', t, 'right') + disp_rotate('"rol"', t, 'left') + disp_rotate('"ror"', t, 'right') def disp_match(typ): res = """ @@ -1089,7 +1131,11 @@ for log in logics: for lcom in open('numeric_common.proto'): if lcom[0:2] == '--': pass - elif std == '87' and '"xnor"' in lcom: + elif std == '87' and ('"xnor"' in lcom + or '"sll"' in lcom + or '"srl"' in lcom + or '"rol"' in lcom + or '"ror"' in lcom): w("--" + lcom[2:]) else: w(lcom) @@ -1098,12 +1144,14 @@ for log in logics: out.close() # Generate bodies +v93=False for l in logics: logic = l out=open('numeric_{0}-body.v87'.format(l), 'w') gen_body('numeric_{0}-body.proto'.format(l)) out.close() +v93=True binary_funcs.append("xnor") for l in logics: logic = l diff --git a/libraries/openieee/numeric_bit-body.proto b/libraries/openieee/numeric_bit-body.proto index 715f9f573..91a5bd6a7 100644 --- a/libraries/openieee/numeric_bit-body.proto +++ b/libraries/openieee/numeric_bit-body.proto @@ -177,4 +177,14 @@ package body NUMERIC_BIT is @ARITH @LOG + + 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; diff --git a/libraries/openieee/numeric_bit-body.v87 b/libraries/openieee/numeric_bit-body.v87 index 83f1a8032..3bdc634ac 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; diff --git a/libraries/openieee/numeric_bit-body.v93 b/libraries/openieee/numeric_bit-body.v93 index ae4d453ed..869b0d2b2 100644 --- a/libraries/openieee/numeric_bit-body.v93 +++ b/libraries/openieee/numeric_bit-body.v93 @@ -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); @@ -1450,7 +1450,7 @@ package body NUMERIC_BIT 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; @@ -1480,7 +1480,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; @@ -1589,7 +1589,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 @@ -1604,7 +1604,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 @@ -1697,7 +1697,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 @@ -1712,7 +1712,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 @@ -1805,7 +1805,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 @@ -1820,7 +1820,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 @@ -1913,7 +1913,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 @@ -1928,7 +1928,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 @@ -2021,7 +2021,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 @@ -2036,7 +2036,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 @@ -2129,7 +2129,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 @@ -2144,7 +2144,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 @@ -2267,7 +2267,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; @@ -2283,7 +2283,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; @@ -2299,6 +2299,72 @@ package body NUMERIC_BIT 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); @@ -2329,7 +2395,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; @@ -2345,7 +2411,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; @@ -2360,4 +2426,80 @@ package body NUMERIC_BIT 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"; + + 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; diff --git a/libraries/openieee/numeric_bit.proto b/libraries/openieee/numeric_bit.proto index 8ece1bf19..ef7bfb72e 100644 --- a/libraries/openieee/numeric_bit.proto +++ b/libraries/openieee/numeric_bit.proto @@ -21,4 +21,7 @@ package NUMERIC_BIT is type SIGNED is array (natural range <>) of BIT; @COMMON + + function rising_edge (signal s : bit) return boolean; + function falling_edge (signal s : bit) return boolean; end NUMERIC_BIT; diff --git a/libraries/openieee/numeric_bit.v87 b/libraries/openieee/numeric_bit.v87 index ee3b1e074..6a6dcc393 100644 --- a/libraries/openieee/numeric_bit.v87 +++ b/libraries/openieee/numeric_bit.v87 @@ -42,41 +42,41 @@ package NUMERIC_BIT is -- Result index range is NEW_SIZE - 1 downto 0 (unless null array). -- For SIGNED, the sign of the result is the sign of ARG. - function "=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "=" (L, R : UNSIGNED) return BOOLEAN; function "=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "/=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "/=" (L, R : UNSIGNED) return BOOLEAN; function "/=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "/=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "<" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "<" (L, R : UNSIGNED) return BOOLEAN; function "<" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "<" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "<=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "<=" (L, R : UNSIGNED) return BOOLEAN; function "<=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "<=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function ">" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function ">" (L, R : UNSIGNED) return BOOLEAN; function ">" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function ">" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function ">=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function ">=" (L, R : UNSIGNED) return BOOLEAN; function ">=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function ">=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "=" (L, R : SIGNED) return BOOLEAN; function "=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "/=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "/=" (L, R : SIGNED) return BOOLEAN; function "/=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "/=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "<" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "<" (L, R : SIGNED) return BOOLEAN; function "<" (L : SIGNED; R : INTEGER) return BOOLEAN; function "<" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "<=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "<=" (L, R : SIGNED) return BOOLEAN; function "<=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "<=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function ">" (L : SIGNED; R : SIGNED) return BOOLEAN; + function ">" (L, R : SIGNED) return BOOLEAN; function ">" (L : SIGNED; R : INTEGER) return BOOLEAN; function ">" (L : INTEGER; R : SIGNED) return BOOLEAN; - function ">=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function ">=" (L, R : SIGNED) return BOOLEAN; function ">=" (L : SIGNED; R : INTEGER) return BOOLEAN; function ">=" (L : INTEGER; R : SIGNED) return BOOLEAN; -- Issue a warning in case of non-logical value. @@ -89,10 +89,10 @@ package NUMERIC_BIT is -- Compute abs ARG. -- Result index range is Arg'length - 1 downto 0. - function "+" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "+" (L : SIGNED; R : SIGNED) return SIGNED; - function "-" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "-" (L : SIGNED; R : SIGNED) return SIGNED; + function "+" (L, R : UNSIGNED) return UNSIGNED; + function "+" (L, R : SIGNED) return SIGNED; + function "-" (L, R : UNSIGNED) return UNSIGNED; + function "-" (L, R : SIGNED) return SIGNED; -- Compute L +/- R. -- Result index range is max (L'Length, R'Length) - 1 downto 0. -- Issue a warning in case of non-logical value. @@ -111,8 +111,8 @@ package NUMERIC_BIT is -- Issue a warning in case of non-logical value. -- Issue a warning if value is truncated. - function "*" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "*" (L : SIGNED; R : SIGNED) return SIGNED; + function "*" (L, R : UNSIGNED) return UNSIGNED; + function "*" (L, R : SIGNED) return SIGNED; -- Compute L * R -- Result index range is L'Length + R'Length - 1 downto 0. @@ -126,12 +126,12 @@ package NUMERIC_BIT is -- Compute L * R -- L is converted to a vector of length R'length - function "/" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "/" (L : SIGNED; R : SIGNED) return SIGNED; - function "rem" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "rem" (L : SIGNED; R : SIGNED) return SIGNED; - function "mod" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "mod" (L : SIGNED; R : SIGNED) return SIGNED; + function "/" (L, R : UNSIGNED) return UNSIGNED; + function "/" (L, R : SIGNED) return SIGNED; + function "rem" (L, R : UNSIGNED) return UNSIGNED; + function "rem" (L, R : SIGNED) return SIGNED; + function "mod" (L, R : UNSIGNED) return UNSIGNED; + function "mod" (L, R : SIGNED) return SIGNED; -- Compute L op R -- Result index range is L'Length - 1 downto 0. -- Issue a warning in case of non-logical value. @@ -193,4 +193,19 @@ package NUMERIC_BIT is function rotate_right (ARG : UNSIGNED; COUNT: NATURAL) return UNSIGNED; function rotate_right (ARG : SIGNED; COUNT: NATURAL) return SIGNED; -- Result index range is ARG'Length - 1 downto 0. + +--function "sll" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; +--function "sll" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; +--function "srl" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; +--function "srl" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + -- Result index range is ARG'Length - 1 downto 0. + +--function "rol" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; +--function "rol" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; +--function "ror" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; +--function "ror" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + -- Result index range is ARG'Length - 1 downto 0. + + function rising_edge (signal s : bit) return boolean; + function falling_edge (signal s : bit) return boolean; end NUMERIC_BIT; diff --git a/libraries/openieee/numeric_bit.v93 b/libraries/openieee/numeric_bit.v93 index cd35bb022..eb21bbc2f 100644 --- a/libraries/openieee/numeric_bit.v93 +++ b/libraries/openieee/numeric_bit.v93 @@ -42,41 +42,41 @@ package NUMERIC_BIT is -- Result index range is NEW_SIZE - 1 downto 0 (unless null array). -- For SIGNED, the sign of the result is the sign of ARG. - function "=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "=" (L, R : UNSIGNED) return BOOLEAN; function "=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "/=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "/=" (L, R : UNSIGNED) return BOOLEAN; function "/=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "/=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "<" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "<" (L, R : UNSIGNED) return BOOLEAN; function "<" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "<" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "<=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "<=" (L, R : UNSIGNED) return BOOLEAN; function "<=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "<=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function ">" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function ">" (L, R : UNSIGNED) return BOOLEAN; function ">" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function ">" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function ">=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function ">=" (L, R : UNSIGNED) return BOOLEAN; function ">=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function ">=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "=" (L, R : SIGNED) return BOOLEAN; function "=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "/=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "/=" (L, R : SIGNED) return BOOLEAN; function "/=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "/=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "<" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "<" (L, R : SIGNED) return BOOLEAN; function "<" (L : SIGNED; R : INTEGER) return BOOLEAN; function "<" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "<=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "<=" (L, R : SIGNED) return BOOLEAN; function "<=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "<=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function ">" (L : SIGNED; R : SIGNED) return BOOLEAN; + function ">" (L, R : SIGNED) return BOOLEAN; function ">" (L : SIGNED; R : INTEGER) return BOOLEAN; function ">" (L : INTEGER; R : SIGNED) return BOOLEAN; - function ">=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function ">=" (L, R : SIGNED) return BOOLEAN; function ">=" (L : SIGNED; R : INTEGER) return BOOLEAN; function ">=" (L : INTEGER; R : SIGNED) return BOOLEAN; -- Issue a warning in case of non-logical value. @@ -89,10 +89,10 @@ package NUMERIC_BIT is -- Compute abs ARG. -- Result index range is Arg'length - 1 downto 0. - function "+" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "+" (L : SIGNED; R : SIGNED) return SIGNED; - function "-" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "-" (L : SIGNED; R : SIGNED) return SIGNED; + function "+" (L, R : UNSIGNED) return UNSIGNED; + function "+" (L, R : SIGNED) return SIGNED; + function "-" (L, R : UNSIGNED) return UNSIGNED; + function "-" (L, R : SIGNED) return SIGNED; -- Compute L +/- R. -- Result index range is max (L'Length, R'Length) - 1 downto 0. -- Issue a warning in case of non-logical value. @@ -111,8 +111,8 @@ package NUMERIC_BIT is -- Issue a warning in case of non-logical value. -- Issue a warning if value is truncated. - function "*" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "*" (L : SIGNED; R : SIGNED) return SIGNED; + function "*" (L, R : UNSIGNED) return UNSIGNED; + function "*" (L, R : SIGNED) return SIGNED; -- Compute L * R -- Result index range is L'Length + R'Length - 1 downto 0. @@ -126,12 +126,12 @@ package NUMERIC_BIT is -- Compute L * R -- L is converted to a vector of length R'length - function "/" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "/" (L : SIGNED; R : SIGNED) return SIGNED; - function "rem" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "rem" (L : SIGNED; R : SIGNED) return SIGNED; - function "mod" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "mod" (L : SIGNED; R : SIGNED) return SIGNED; + function "/" (L, R : UNSIGNED) return UNSIGNED; + function "/" (L, R : SIGNED) return SIGNED; + function "rem" (L, R : UNSIGNED) return UNSIGNED; + function "rem" (L, R : SIGNED) return SIGNED; + function "mod" (L, R : UNSIGNED) return UNSIGNED; + function "mod" (L, R : SIGNED) return SIGNED; -- Compute L op R -- Result index range is L'Length - 1 downto 0. -- Issue a warning in case of non-logical value. @@ -193,4 +193,19 @@ package NUMERIC_BIT is function rotate_right (ARG : UNSIGNED; COUNT: NATURAL) return UNSIGNED; function rotate_right (ARG : SIGNED; COUNT: NATURAL) return SIGNED; -- Result index range is ARG'Length - 1 downto 0. + + function "sll" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; + function "sll" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + function "srl" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; + function "srl" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + -- Result index range is ARG'Length - 1 downto 0. + + function "rol" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; + function "rol" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + function "ror" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; + function "ror" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + -- Result index range is ARG'Length - 1 downto 0. + + function rising_edge (signal s : bit) return boolean; + function falling_edge (signal s : bit) return boolean; end NUMERIC_BIT; diff --git a/libraries/openieee/numeric_common.proto b/libraries/openieee/numeric_common.proto index a40e8a910..aa940e22f 100644 --- a/libraries/openieee/numeric_common.proto +++ b/libraries/openieee/numeric_common.proto @@ -37,41 +37,41 @@ -- Result index range is NEW_SIZE - 1 downto 0 (unless null array). -- For SIGNED, the sign of the result is the sign of ARG. - function "=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "=" (L, R : UNSIGNED) return BOOLEAN; function "=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "/=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "/=" (L, R : UNSIGNED) return BOOLEAN; function "/=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "/=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "<" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "<" (L, R : UNSIGNED) return BOOLEAN; function "<" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "<" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "<=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "<=" (L, R : UNSIGNED) return BOOLEAN; function "<=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "<=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function ">" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function ">" (L, R : UNSIGNED) return BOOLEAN; function ">" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function ">" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function ">=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function ">=" (L, R : UNSIGNED) return BOOLEAN; function ">=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function ">=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "=" (L, R : SIGNED) return BOOLEAN; function "=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "/=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "/=" (L, R : SIGNED) return BOOLEAN; function "/=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "/=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "<" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "<" (L, R : SIGNED) return BOOLEAN; function "<" (L : SIGNED; R : INTEGER) return BOOLEAN; function "<" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "<=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "<=" (L, R : SIGNED) return BOOLEAN; function "<=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "<=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function ">" (L : SIGNED; R : SIGNED) return BOOLEAN; + function ">" (L, R : SIGNED) return BOOLEAN; function ">" (L : SIGNED; R : INTEGER) return BOOLEAN; function ">" (L : INTEGER; R : SIGNED) return BOOLEAN; - function ">=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function ">=" (L, R : SIGNED) return BOOLEAN; function ">=" (L : SIGNED; R : INTEGER) return BOOLEAN; function ">=" (L : INTEGER; R : SIGNED) return BOOLEAN; -- Issue a warning in case of non-logical value. @@ -84,10 +84,10 @@ -- Compute abs ARG. -- Result index range is Arg'length - 1 downto 0. - function "+" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "+" (L : SIGNED; R : SIGNED) return SIGNED; - function "-" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "-" (L : SIGNED; R : SIGNED) return SIGNED; + function "+" (L, R : UNSIGNED) return UNSIGNED; + function "+" (L, R : SIGNED) return SIGNED; + function "-" (L, R : UNSIGNED) return UNSIGNED; + function "-" (L, R : SIGNED) return SIGNED; -- Compute L +/- R. -- Result index range is max (L'Length, R'Length) - 1 downto 0. -- Issue a warning in case of non-logical value. @@ -106,8 +106,8 @@ -- Issue a warning in case of non-logical value. -- Issue a warning if value is truncated. - function "*" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "*" (L : SIGNED; R : SIGNED) return SIGNED; + function "*" (L, R : UNSIGNED) return UNSIGNED; + function "*" (L, R : SIGNED) return SIGNED; -- Compute L * R -- Result index range is L'Length + R'Length - 1 downto 0. @@ -121,12 +121,12 @@ -- Compute L * R -- L is converted to a vector of length R'length - function "/" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "/" (L : SIGNED; R : SIGNED) return SIGNED; - function "rem" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "rem" (L : SIGNED; R : SIGNED) return SIGNED; - function "mod" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "mod" (L : SIGNED; R : SIGNED) return SIGNED; + function "/" (L, R : UNSIGNED) return UNSIGNED; + function "/" (L, R : SIGNED) return SIGNED; + function "rem" (L, R : UNSIGNED) return UNSIGNED; + function "rem" (L, R : SIGNED) return SIGNED; + function "mod" (L, R : UNSIGNED) return UNSIGNED; + function "mod" (L, R : SIGNED) return SIGNED; -- Compute L op R -- Result index range is L'Length - 1 downto 0. -- Issue a warning in case of non-logical value. @@ -188,3 +188,15 @@ function rotate_right (ARG : UNSIGNED; COUNT: NATURAL) return UNSIGNED; function rotate_right (ARG : SIGNED; COUNT: NATURAL) return SIGNED; -- Result index range is ARG'Length - 1 downto 0. + + function "sll" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; + function "sll" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + function "srl" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; + function "srl" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + -- Result index range is ARG'Length - 1 downto 0. + + function "rol" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; + function "rol" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + function "ror" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; + function "ror" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + -- Result index range is ARG'Length - 1 downto 0. diff --git a/libraries/openieee/numeric_std-body.v87 b/libraries/openieee/numeric_std-body.v87 index 5f47f97c0..c716b19f3 100644 --- a/libraries/openieee/numeric_std-body.v87 +++ b/libraries/openieee/numeric_std-body.v87 @@ -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); @@ -1758,7 +1758,7 @@ package body NUMERIC_STD 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; @@ -1791,7 +1791,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; @@ -1909,7 +1909,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 @@ -1930,7 +1930,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 @@ -2053,7 +2053,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 @@ -2074,7 +2074,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 @@ -2197,7 +2197,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 @@ -2218,7 +2218,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 @@ -2341,7 +2341,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 @@ -2362,7 +2362,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 @@ -2485,7 +2485,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 @@ -2506,7 +2506,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 @@ -2629,7 +2629,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 @@ -2650,7 +2650,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 @@ -2803,7 +2803,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; @@ -2819,7 +2819,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; @@ -2865,7 +2865,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; @@ -2881,7 +2881,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; 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; diff --git a/libraries/openieee/numeric_std.v87 b/libraries/openieee/numeric_std.v87 index c24867eb1..e1fa946ca 100644 --- a/libraries/openieee/numeric_std.v87 +++ b/libraries/openieee/numeric_std.v87 @@ -59,41 +59,41 @@ package NUMERIC_STD is -- Result index range is NEW_SIZE - 1 downto 0 (unless null array). -- For SIGNED, the sign of the result is the sign of ARG. - function "=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "=" (L, R : UNSIGNED) return BOOLEAN; function "=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "/=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "/=" (L, R : UNSIGNED) return BOOLEAN; function "/=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "/=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "<" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "<" (L, R : UNSIGNED) return BOOLEAN; function "<" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "<" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "<=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "<=" (L, R : UNSIGNED) return BOOLEAN; function "<=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "<=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function ">" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function ">" (L, R : UNSIGNED) return BOOLEAN; function ">" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function ">" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function ">=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function ">=" (L, R : UNSIGNED) return BOOLEAN; function ">=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function ">=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "=" (L, R : SIGNED) return BOOLEAN; function "=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "/=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "/=" (L, R : SIGNED) return BOOLEAN; function "/=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "/=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "<" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "<" (L, R : SIGNED) return BOOLEAN; function "<" (L : SIGNED; R : INTEGER) return BOOLEAN; function "<" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "<=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "<=" (L, R : SIGNED) return BOOLEAN; function "<=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "<=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function ">" (L : SIGNED; R : SIGNED) return BOOLEAN; + function ">" (L, R : SIGNED) return BOOLEAN; function ">" (L : SIGNED; R : INTEGER) return BOOLEAN; function ">" (L : INTEGER; R : SIGNED) return BOOLEAN; - function ">=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function ">=" (L, R : SIGNED) return BOOLEAN; function ">=" (L : SIGNED; R : INTEGER) return BOOLEAN; function ">=" (L : INTEGER; R : SIGNED) return BOOLEAN; -- Issue a warning in case of non-logical value. @@ -106,10 +106,10 @@ package NUMERIC_STD is -- Compute abs ARG. -- Result index range is Arg'length - 1 downto 0. - function "+" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "+" (L : SIGNED; R : SIGNED) return SIGNED; - function "-" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "-" (L : SIGNED; R : SIGNED) return SIGNED; + function "+" (L, R : UNSIGNED) return UNSIGNED; + function "+" (L, R : SIGNED) return SIGNED; + function "-" (L, R : UNSIGNED) return UNSIGNED; + function "-" (L, R : SIGNED) return SIGNED; -- Compute L +/- R. -- Result index range is max (L'Length, R'Length) - 1 downto 0. -- Issue a warning in case of non-logical value. @@ -128,8 +128,8 @@ package NUMERIC_STD is -- Issue a warning in case of non-logical value. -- Issue a warning if value is truncated. - function "*" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "*" (L : SIGNED; R : SIGNED) return SIGNED; + function "*" (L, R : UNSIGNED) return UNSIGNED; + function "*" (L, R : SIGNED) return SIGNED; -- Compute L * R -- Result index range is L'Length + R'Length - 1 downto 0. @@ -143,12 +143,12 @@ package NUMERIC_STD is -- Compute L * R -- L is converted to a vector of length R'length - function "/" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "/" (L : SIGNED; R : SIGNED) return SIGNED; - function "rem" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "rem" (L : SIGNED; R : SIGNED) return SIGNED; - function "mod" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "mod" (L : SIGNED; R : SIGNED) return SIGNED; + function "/" (L, R : UNSIGNED) return UNSIGNED; + function "/" (L, R : SIGNED) return SIGNED; + function "rem" (L, R : UNSIGNED) return UNSIGNED; + function "rem" (L, R : SIGNED) return SIGNED; + function "mod" (L, R : UNSIGNED) return UNSIGNED; + function "mod" (L, R : SIGNED) return SIGNED; -- Compute L op R -- Result index range is L'Length - 1 downto 0. -- Issue a warning in case of non-logical value. @@ -210,4 +210,16 @@ package NUMERIC_STD is function rotate_right (ARG : UNSIGNED; COUNT: NATURAL) return UNSIGNED; function rotate_right (ARG : SIGNED; COUNT: NATURAL) return SIGNED; -- Result index range is ARG'Length - 1 downto 0. + +--function "sll" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; +--function "sll" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; +--function "srl" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; +--function "srl" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + -- Result index range is ARG'Length - 1 downto 0. + +--function "rol" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; +--function "rol" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; +--function "ror" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; +--function "ror" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + -- Result index range is ARG'Length - 1 downto 0. end NUMERIC_STD; diff --git a/libraries/openieee/numeric_std.v93 b/libraries/openieee/numeric_std.v93 index 61faa6da9..8f58221ee 100644 --- a/libraries/openieee/numeric_std.v93 +++ b/libraries/openieee/numeric_std.v93 @@ -59,41 +59,41 @@ package NUMERIC_STD is -- Result index range is NEW_SIZE - 1 downto 0 (unless null array). -- For SIGNED, the sign of the result is the sign of ARG. - function "=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "=" (L, R : UNSIGNED) return BOOLEAN; function "=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "/=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "/=" (L, R : UNSIGNED) return BOOLEAN; function "/=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "/=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "<" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "<" (L, R : UNSIGNED) return BOOLEAN; function "<" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "<" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "<=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function "<=" (L, R : UNSIGNED) return BOOLEAN; function "<=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function "<=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function ">" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function ">" (L, R : UNSIGNED) return BOOLEAN; function ">" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function ">" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function ">=" (L : UNSIGNED; R : UNSIGNED) return BOOLEAN; + function ">=" (L, R : UNSIGNED) return BOOLEAN; function ">=" (L : UNSIGNED; R : NATURAL) return BOOLEAN; function ">=" (L : NATURAL; R : UNSIGNED) return BOOLEAN; - function "=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "=" (L, R : SIGNED) return BOOLEAN; function "=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "/=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "/=" (L, R : SIGNED) return BOOLEAN; function "/=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "/=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "<" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "<" (L, R : SIGNED) return BOOLEAN; function "<" (L : SIGNED; R : INTEGER) return BOOLEAN; function "<" (L : INTEGER; R : SIGNED) return BOOLEAN; - function "<=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function "<=" (L, R : SIGNED) return BOOLEAN; function "<=" (L : SIGNED; R : INTEGER) return BOOLEAN; function "<=" (L : INTEGER; R : SIGNED) return BOOLEAN; - function ">" (L : SIGNED; R : SIGNED) return BOOLEAN; + function ">" (L, R : SIGNED) return BOOLEAN; function ">" (L : SIGNED; R : INTEGER) return BOOLEAN; function ">" (L : INTEGER; R : SIGNED) return BOOLEAN; - function ">=" (L : SIGNED; R : SIGNED) return BOOLEAN; + function ">=" (L, R : SIGNED) return BOOLEAN; function ">=" (L : SIGNED; R : INTEGER) return BOOLEAN; function ">=" (L : INTEGER; R : SIGNED) return BOOLEAN; -- Issue a warning in case of non-logical value. @@ -106,10 +106,10 @@ package NUMERIC_STD is -- Compute abs ARG. -- Result index range is Arg'length - 1 downto 0. - function "+" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "+" (L : SIGNED; R : SIGNED) return SIGNED; - function "-" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "-" (L : SIGNED; R : SIGNED) return SIGNED; + function "+" (L, R : UNSIGNED) return UNSIGNED; + function "+" (L, R : SIGNED) return SIGNED; + function "-" (L, R : UNSIGNED) return UNSIGNED; + function "-" (L, R : SIGNED) return SIGNED; -- Compute L +/- R. -- Result index range is max (L'Length, R'Length) - 1 downto 0. -- Issue a warning in case of non-logical value. @@ -128,8 +128,8 @@ package NUMERIC_STD is -- Issue a warning in case of non-logical value. -- Issue a warning if value is truncated. - function "*" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "*" (L : SIGNED; R : SIGNED) return SIGNED; + function "*" (L, R : UNSIGNED) return UNSIGNED; + function "*" (L, R : SIGNED) return SIGNED; -- Compute L * R -- Result index range is L'Length + R'Length - 1 downto 0. @@ -143,12 +143,12 @@ package NUMERIC_STD is -- Compute L * R -- L is converted to a vector of length R'length - function "/" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "/" (L : SIGNED; R : SIGNED) return SIGNED; - function "rem" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "rem" (L : SIGNED; R : SIGNED) return SIGNED; - function "mod" (L : UNSIGNED; R : UNSIGNED) return UNSIGNED; - function "mod" (L : SIGNED; R : SIGNED) return SIGNED; + function "/" (L, R : UNSIGNED) return UNSIGNED; + function "/" (L, R : SIGNED) return SIGNED; + function "rem" (L, R : UNSIGNED) return UNSIGNED; + function "rem" (L, R : SIGNED) return SIGNED; + function "mod" (L, R : UNSIGNED) return UNSIGNED; + function "mod" (L, R : SIGNED) return SIGNED; -- Compute L op R -- Result index range is L'Length - 1 downto 0. -- Issue a warning in case of non-logical value. @@ -210,4 +210,16 @@ package NUMERIC_STD is function rotate_right (ARG : UNSIGNED; COUNT: NATURAL) return UNSIGNED; function rotate_right (ARG : SIGNED; COUNT: NATURAL) return SIGNED; -- Result index range is ARG'Length - 1 downto 0. + + function "sll" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; + function "sll" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + function "srl" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; + function "srl" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + -- Result index range is ARG'Length - 1 downto 0. + + function "rol" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; + function "rol" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + function "ror" (ARG : UNSIGNED; COUNT: INTEGER) return UNSIGNED; + function "ror" (ARG : SIGNED; COUNT: INTEGER) return SIGNED; + -- Result index range is ARG'Length - 1 downto 0. end NUMERIC_STD; diff --git a/libraries/openieee/std_logic_1164-body.v87 b/libraries/openieee/std_logic_1164-body.v87 index 02bfb0ff3..b6dd265d0 100644 --- a/libraries/openieee/std_logic_1164-body.v87 +++ b/libraries/openieee/std_logic_1164-body.v87 @@ -1,4 +1,4 @@ --- This file was generated from std_logic_1164-body.proto +-- This -*- vhdl -*- file was generated from std_logic_1164-body.proto -- This is an implementation of -*- vhdl -*- ieee.std_logic_1164 based only -- on the specifications. This file is part of GHDL. -- Copyright (C) 2015 Tristan Gingold @@ -14,7 +14,7 @@ -- for more details. -- -- You should have received a copy of the GNU General Public License --- along with GCC; see the file COPYING3. If not see +-- along with GCC; see the file COPYING2. If not see -- <http://www.gnu.org/licenses/>. -- This is a template file. To avoid errors and duplication, the python @@ -119,27 +119,27 @@ package body std_logic_1164 is "UX10XX10X"; - function "and" (l, r : std_ulogic) return UX01 is + function "and" (l : std_ulogic; r : std_ulogic) return UX01 is begin return and_table (l, r); end "and"; - function "nand" (l, r : std_ulogic) return UX01 is + function "nand" (l : std_ulogic; r : std_ulogic) return UX01 is begin return nand_table (l, r); end "nand"; - function "or" (l, r : std_ulogic) return UX01 is + function "or" (l : std_ulogic; r : std_ulogic) return UX01 is begin return or_table (l, r); end "or"; - function "nor" (l, r : std_ulogic) return UX01 is + function "nor" (l : std_ulogic; r : std_ulogic) return UX01 is begin return nor_table (l, r); end "nor"; - function "xor" (l, r : std_ulogic) return UX01 is + function "xor" (l : std_ulogic; r : std_ulogic) return UX01 is begin return xor_table (l, r); end "xor"; @@ -450,18 +450,18 @@ package body std_logic_1164 is return res; end to_stdlogicvector; - function to_stdulogicvector (b : std_logic_vector) return std_ulogic_vector + function to_stdulogicvector (s : std_logic_vector) return std_ulogic_vector is - subtype res_type is std_ulogic_vector (b'length - 1 downto 0); + subtype res_type is std_ulogic_vector (s'length - 1 downto 0); begin - return res_type (b); + return res_type (s); end to_stdulogicvector; - function to_stdlogicvector (b : std_ulogic_vector) return std_logic_vector + function to_stdlogicvector (s : std_ulogic_vector) return std_logic_vector is - subtype res_type is std_logic_vector (b'length - 1 downto 0); + subtype res_type is std_logic_vector (s'length - 1 downto 0); begin - return res_type (b); + return res_type (s); end to_stdlogicvector; function to_stdulogic (b : bit) return std_ulogic is diff --git a/libraries/openieee/std_logic_1164-body.v93 b/libraries/openieee/std_logic_1164-body.v93 index fc93dacda..af43ba306 100644 --- a/libraries/openieee/std_logic_1164-body.v93 +++ b/libraries/openieee/std_logic_1164-body.v93 @@ -1,4 +1,4 @@ --- This file was generated from std_logic_1164-body.proto +-- This -*- vhdl -*- file was generated from std_logic_1164-body.proto -- This is an implementation of -*- vhdl -*- ieee.std_logic_1164 based only -- on the specifications. This file is part of GHDL. -- Copyright (C) 2015 Tristan Gingold @@ -14,7 +14,7 @@ -- for more details. -- -- You should have received a copy of the GNU General Public License --- along with GCC; see the file COPYING3. If not see +-- along with GCC; see the file COPYING2. If not see -- <http://www.gnu.org/licenses/>. -- This is a template file. To avoid errors and duplication, the python @@ -132,32 +132,32 @@ package body std_logic_1164 is "UX10XX10X"; - function "and" (l, r : std_ulogic) return UX01 is + function "and" (l : std_ulogic; r : std_ulogic) return UX01 is begin return and_table (l, r); end "and"; - function "nand" (l, r : std_ulogic) return UX01 is + function "nand" (l : std_ulogic; r : std_ulogic) return UX01 is begin return nand_table (l, r); end "nand"; - function "or" (l, r : std_ulogic) return UX01 is + function "or" (l : std_ulogic; r : std_ulogic) return UX01 is begin return or_table (l, r); end "or"; - function "nor" (l, r : std_ulogic) return UX01 is + function "nor" (l : std_ulogic; r : std_ulogic) return UX01 is begin return nor_table (l, r); end "nor"; - function "xor" (l, r : std_ulogic) return UX01 is + function "xor" (l : std_ulogic; r : std_ulogic) return UX01 is begin return xor_table (l, r); end "xor"; - function "xnor" (l, r : std_ulogic) return UX01 is + function "xnor" (l : std_ulogic; r : std_ulogic) return UX01 is begin return xnor_table (l, r); end "xnor"; @@ -506,18 +506,18 @@ package body std_logic_1164 is return res; end to_stdlogicvector; - function to_stdulogicvector (b : std_logic_vector) return std_ulogic_vector + function to_stdulogicvector (s : std_logic_vector) return std_ulogic_vector is - subtype res_type is std_ulogic_vector (b'length - 1 downto 0); + subtype res_type is std_ulogic_vector (s'length - 1 downto 0); begin - return res_type (b); + return res_type (s); end to_stdulogicvector; - function to_stdlogicvector (b : std_ulogic_vector) return std_logic_vector + function to_stdlogicvector (s : std_ulogic_vector) return std_logic_vector is - subtype res_type is std_logic_vector (b'length - 1 downto 0); + subtype res_type is std_logic_vector (s'length - 1 downto 0); begin - return res_type (b); + return res_type (s); end to_stdlogicvector; function to_stdulogic (b : bit) return std_ulogic is diff --git a/libraries/openieee/std_logic_1164.v87 b/libraries/openieee/std_logic_1164.v87 index 964ed956c..841be73a4 100644 --- a/libraries/openieee/std_logic_1164.v87 +++ b/libraries/openieee/std_logic_1164.v87 @@ -13,7 +13,7 @@ -- for more details. -- -- You should have received a copy of the GNU General Public License --- along with GCC; see the file COPYING3. If not see +-- along with GCC; see the file COPYING2. If not see -- <http://www.gnu.org/licenses/>. -- This package is valid for VHDL version until but not including 2008. @@ -65,12 +65,12 @@ package std_logic_1164 is -- 0 and L are normalized to 0, 1 and 1 are normalized to 1, U isnt changed, -- all other states are normalized to X. -- Then the classical electric rules are followed. - function "and" (l, r : std_ulogic) return UX01; - function "nand" (l, r : std_ulogic) return UX01; - function "or" (l, r : std_ulogic) return UX01; - function "nor" (l, r : std_ulogic) return UX01; - function "xor" (l, r : std_ulogic) return UX01; ---function "xnor" (l, r : std_ulogic) return UX01; + function "and" (l : std_ulogic; r : std_ulogic) return UX01; + function "nand" (l : std_ulogic; r : std_ulogic) return UX01; + function "or" (l : std_ulogic; r : std_ulogic) return UX01; + function "nor" (l : std_ulogic; r : std_ulogic) return UX01; + function "xor" (l : std_ulogic; r : std_ulogic) return UX01; +--function "xnor" (l : std_ulogic; r : std_ulogic) return UX01; function "not" (l : std_ulogic) return UX01; -- Logical operators for vectors. @@ -103,9 +103,9 @@ package std_logic_1164 is function to_stdulogic (b : bit) return std_ulogic; function to_stdlogicvector (b : bit_vector) return std_logic_vector; - function to_stdlogicvector (b : std_ulogic_vector) return std_logic_vector; + function to_stdlogicvector (s : std_ulogic_vector) return std_logic_vector; function to_stdulogicvector (b : bit_vector) return std_ulogic_vector; - function to_stdulogicvector (b : std_logic_vector) return std_ulogic_vector; + function to_stdulogicvector (s : std_logic_vector) return std_ulogic_vector; -- Normalization. -- The result range (for vectors) is 1 to S'Length. diff --git a/libraries/openieee/std_logic_1164.v93 b/libraries/openieee/std_logic_1164.v93 index 0ee62a1a6..b5136f538 100644 --- a/libraries/openieee/std_logic_1164.v93 +++ b/libraries/openieee/std_logic_1164.v93 @@ -13,7 +13,7 @@ -- for more details. -- -- You should have received a copy of the GNU General Public License --- along with GCC; see the file COPYING3. If not see +-- along with GCC; see the file COPYING2. If not see -- <http://www.gnu.org/licenses/>. -- This package is valid for VHDL version until but not including 2008. @@ -65,12 +65,12 @@ package std_logic_1164 is -- 0 and L are normalized to 0, 1 and 1 are normalized to 1, U isnt changed, -- all other states are normalized to X. -- Then the classical electric rules are followed. - function "and" (l, r : std_ulogic) return UX01; - function "nand" (l, r : std_ulogic) return UX01; - function "or" (l, r : std_ulogic) return UX01; - function "nor" (l, r : std_ulogic) return UX01; - function "xor" (l, r : std_ulogic) return UX01; - function "xnor" (l, r : std_ulogic) return UX01; + function "and" (l : std_ulogic; r : std_ulogic) return UX01; + function "nand" (l : std_ulogic; r : std_ulogic) return UX01; + function "or" (l : std_ulogic; r : std_ulogic) return UX01; + function "nor" (l : std_ulogic; r : std_ulogic) return UX01; + function "xor" (l : std_ulogic; r : std_ulogic) return UX01; + function "xnor" (l : std_ulogic; r : std_ulogic) return UX01; function "not" (l : std_ulogic) return UX01; -- Logical operators for vectors. @@ -103,9 +103,9 @@ package std_logic_1164 is function to_stdulogic (b : bit) return std_ulogic; function to_stdlogicvector (b : bit_vector) return std_logic_vector; - function to_stdlogicvector (b : std_ulogic_vector) return std_logic_vector; + function to_stdlogicvector (s : std_ulogic_vector) return std_logic_vector; function to_stdulogicvector (b : bit_vector) return std_ulogic_vector; - function to_stdulogicvector (b : std_logic_vector) return std_ulogic_vector; + function to_stdulogicvector (s : std_logic_vector) return std_ulogic_vector; -- Normalization. -- The result range (for vectors) is 1 to S'Length. diff --git a/libraries/openieee/std_logic_1164.vhdl b/libraries/openieee/std_logic_1164.vhdl index f05f8f08b..b5136f538 100644 --- a/libraries/openieee/std_logic_1164.vhdl +++ b/libraries/openieee/std_logic_1164.vhdl @@ -65,12 +65,12 @@ package std_logic_1164 is -- 0 and L are normalized to 0, 1 and 1 are normalized to 1, U isnt changed, -- all other states are normalized to X. -- Then the classical electric rules are followed. - function "and" (l, r : std_ulogic) return UX01; - function "nand" (l, r : std_ulogic) return UX01; - function "or" (l, r : std_ulogic) return UX01; - function "nor" (l, r : std_ulogic) return UX01; - function "xor" (l, r : std_ulogic) return UX01; - function "xnor" (l, r : std_ulogic) return UX01; + function "and" (l : std_ulogic; r : std_ulogic) return UX01; + function "nand" (l : std_ulogic; r : std_ulogic) return UX01; + function "or" (l : std_ulogic; r : std_ulogic) return UX01; + function "nor" (l : std_ulogic; r : std_ulogic) return UX01; + function "xor" (l : std_ulogic; r : std_ulogic) return UX01; + function "xnor" (l : std_ulogic; r : std_ulogic) return UX01; function "not" (l : std_ulogic) return UX01; -- Logical operators for vectors. @@ -103,9 +103,9 @@ package std_logic_1164 is function to_stdulogic (b : bit) return std_ulogic; function to_stdlogicvector (b : bit_vector) return std_logic_vector; - function to_stdlogicvector (b : std_ulogic_vector) return std_logic_vector; + function to_stdlogicvector (s : std_ulogic_vector) return std_logic_vector; function to_stdulogicvector (b : bit_vector) return std_ulogic_vector; - function to_stdulogicvector (b : std_logic_vector) return std_ulogic_vector; + function to_stdulogicvector (s : std_logic_vector) return std_ulogic_vector; -- Normalization. -- The result range (for vectors) is 1 to S'Length. |