From bde1e82a42b1c6468726434f35f80f06c4f83704 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sun, 1 Dec 2019 19:41:42 +0100 Subject: ieee2008: import packages from vhdl 2019. --- libraries/ieee2008/README.ieee | 30 - libraries/ieee2008/fixed_float_types.vhdl | 39 +- libraries/ieee2008/fixed_generic_pkg.vhdl | 87 +- libraries/ieee2008/fixed_pkg.vhdl | 32 +- libraries/ieee2008/float_generic_pkg-body.vhdl | 442 ++++---- libraries/ieee2008/float_generic_pkg.vhdl | 67 +- libraries/ieee2008/float_pkg.vhdl | 31 +- libraries/ieee2008/math_complex-body.vhdl | 34 +- libraries/ieee2008/math_complex.vhdl | 33 +- libraries/ieee2008/math_real-body.vhdl | 74 +- libraries/ieee2008/math_real.vhdl | 33 +- libraries/ieee2008/numeric_bit-body.vhdl | 185 ++- libraries/ieee2008/numeric_bit.vhdl | 145 +-- libraries/ieee2008/numeric_bit_unsigned-body.vhdl | 1181 ++++++++++---------- libraries/ieee2008/numeric_bit_unsigned.vhdl | 1243 +++++++++++---------- libraries/ieee2008/numeric_std-body.vhdl | 157 +-- libraries/ieee2008/numeric_std.vhdl | 146 +-- libraries/ieee2008/numeric_std_unsigned-body.vhdl | 1187 ++++++++++---------- libraries/ieee2008/numeric_std_unsigned.vhdl | 1229 ++++++++++---------- libraries/ieee2008/std_logic_1164-body.vhdl | 302 ++--- libraries/ieee2008/std_logic_1164.vhdl | 107 +- libraries/ieee2008/std_logic_textio.vhdl | 45 +- 22 files changed, 3398 insertions(+), 3431 deletions(-) delete mode 100644 libraries/ieee2008/README.ieee diff --git a/libraries/ieee2008/README.ieee b/libraries/ieee2008/README.ieee deleted file mode 100644 index 39bc281bf..000000000 --- a/libraries/ieee2008/README.ieee +++ /dev/null @@ -1,30 +0,0 @@ -https://standards.ieee.org/news/2013/ieee_1076_vhdl.html - -MODIFICATION TO IEEE 1076™ LICENSING TERMS ALLOWS FOR OPEN USE OF VHDL STANDARD’S SUPPLEMENTAL MATERIAL - -IEEE 1076 working group assists with creation of additional packages for developers to cultivate new hardware-designer tools to expand VHDL systems - -Shuang Yu, Senior Manager, Solutions Marketing -+1 732 981 3424; shuang.yu@ieee.org - -PISCATAWAY, N.J., USA, 16 July 2013 - IEEE, the world's largest professional organization advancing technology for humanity, today announced a licensing term modification to the supplemental materials for IEEE 1076™ “Standard VHDL Language Reference Manual.” The licensing change allows the standard’s supplemental materials or “packages” to be made available to the public without prior authorization from the IEEE Standards Association (IEEE-SA). The supplemental packages provide developers with the necessary machine-readable code to build hardware-designer tools that help create systems using Very High Speed Integrated Circuits (VHSIC) Hardware Description Language (VHDL), which is then used to design electronic systems at the component and board levels. - -By allowing free use of the standard’s VHDL packages each time a new VHDL design is implemented, the new license terms are intended to save developers the time required to request authorization for their legal use in real-world applications. Under the previous terms, users of the IEEE 1076 standard’s packages were required to request permission from the IEEE-SA. The various packages include the definition of standard types, subtypes, natures and constants for hardware modeling. - -“This licensing change is very important to vendors and users of VHDL,” said Stan Krolikoski, chair of the IEEE Computer Society's Design Automation Standards Committee (DASC), which supported the modification to the license for the supplemental materials. “We worked closely with the IEEE 1076 VHDL Analysis and Standardization Working Group to allow anyone to use these files, within the guidelines of the IEEE 1076-2008 standard, of course. The previous header to the standard’s supplemental packages instructed users to request permission from the IEEE-SA for all uses, which is no longer required.” - -The collaboration between the DASC and the IEEE 1076 Working Group to modify the licensing of the supplemental materials to IEEE 1076 was conducted in the spirit of the OpenStand paradigm for global, open standards. Globally adopted design automation standards, such as IEEE 1076, have paved the way for a giant leap forward in industry's ability to define complex electronic solutions and are examples of standards developed under the market-driven OpenStand principles. - -For more information about the IEEE 1076 VHDL Analysis and Standardization Working Group, please visit the Working Group web page. - -Download IEEE 1076’s supplemental materials at the working group web page. IEEE 1076 is available for purchase at the IEEE Standards Store. - -To learn more about IEEE-SA, visit us on Facebook, follow us on Twitter, connect with us on LinkedIn, or on the Standards Insight Blog. - -About the IEEE Standards Association -The IEEE Standards Association, a globally recognized standards-setting body within IEEE, develops consensus standards through an open process that engages industry and brings together a broad stakeholder community. IEEE standards set specifications and best practices based on current scientific and technological knowledge. The IEEE-SA has a portfolio of over 900 active standards and more than 500 standards under development. For more information visit the IEEE-SA Web site. - -About IEEE -IEEE, a large, global technical professional organization, is dedicated to advancing technology for the benefit of humanity. Through its highly cited publications, conferences, technology standards, and professional and educational activities, IEEE is the trusted voice on a wide variety of areas ranging from aerospace systems, computers and telecommunications to biomedical engineering, electric power and consumer electronics. Learn more at the IEEE Web site. external link - -- See more at: https://standards.ieee.org/news/2013/ieee_1076_vhdl.html#sthash.UFLcTc7E.dpuf diff --git a/libraries/ieee2008/fixed_float_types.vhdl b/libraries/ieee2008/fixed_float_types.vhdl index cbadcdf34..6ad3e37ec 100644 --- a/libraries/ieee2008/fixed_float_types.vhdl +++ b/libraries/ieee2008/fixed_float_types.vhdl @@ -1,22 +1,25 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Fixed Point and Floating Point types package -- --- Library : This package shall be compiled into a library --- symbolically named IEEE. +-- Library : This package shall be compiled into a library +-- symbolically named IEEE. -- -- Developers: Accellera VHDL-TC and IEEE P1076 Working Group -- @@ -40,9 +43,9 @@ package fixed_float_types is -- Types used for generics of fixed_generic_pkg - + type fixed_round_style_type is (fixed_round, fixed_truncate); - + type fixed_overflow_style_type is (fixed_saturate, fixed_wrap); -- Type used for generics of float_generic_pkg diff --git a/libraries/ieee2008/fixed_generic_pkg.vhdl b/libraries/ieee2008/fixed_generic_pkg.vhdl index 2486cbe1c..df49433da 100644 --- a/libraries/ieee2008/fixed_generic_pkg.vhdl +++ b/libraries/ieee2008/fixed_generic_pkg.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Fixed-point package (Generic package declaration) -- : @@ -57,7 +60,7 @@ package fixed_generic_pkg is -- Author David Bishop (dbishop@vhdl.org) constant CopyRightNotice : STRING := - "Copyright 2008 by IEEE. All rights reserved."; + "Copyright IEEE P1076 WG. Licensed Apache 2.0"; -- base Unsigned fixed point type, downto direction assumed type UNRESOLVED_ufixed is array (INTEGER range <>) of STD_ULOGIC; @@ -435,7 +438,7 @@ package fixed_generic_pkg is function "<=" (l : NATURAL; r : UNRESOLVED_ufixed) return BOOLEAN; function ">" (l : NATURAL; r : UNRESOLVED_ufixed) return BOOLEAN; function "<" (l : NATURAL; r : UNRESOLVED_ufixed) return BOOLEAN; - + function "?=" (l : UNRESOLVED_ufixed; r : NATURAL) return STD_ULOGIC; function "?/=" (l : UNRESOLVED_ufixed; r : NATURAL) return STD_ULOGIC; function "?>=" (l : UNRESOLVED_ufixed; r : NATURAL) return STD_ULOGIC; @@ -719,7 +722,7 @@ package fixed_generic_pkg is -- In saturate mode, if the number overflows then the largest possible -- representable number is returned. If wrap mode, then the upper bits -- of the number are truncated. - + function resize ( arg : UNRESOLVED_ufixed; -- input constant left_index : INTEGER; -- integer portion @@ -945,17 +948,17 @@ package fixed_generic_pkg is operation : CHARACTER := 'X'; left_index2, right_index2 : INTEGER := 0) return INTEGER; - + function ufixed_low (left_index, right_index : INTEGER; operation : CHARACTER := 'X'; left_index2, right_index2 : INTEGER := 0) return INTEGER; - + function sfixed_high (left_index, right_index : INTEGER; operation : CHARACTER := 'X'; left_index2, right_index2 : INTEGER := 0) return INTEGER; - + function sfixed_low (left_index, right_index : INTEGER; operation : CHARACTER := 'X'; left_index2, right_index2 : INTEGER := 0) @@ -965,22 +968,22 @@ package fixed_generic_pkg is -- signal uf1multuf2 : ufixed (ufixed_high (uf1, '*', uf2) downto -- ufixed_low (uf1, '*', uf2)); -- uf1multuf2 <= uf1 * uf2; - -- + -- function ufixed_high (size_res : UNRESOLVED_ufixed; operation : CHARACTER := 'X'; size_res2 : UNRESOLVED_ufixed) return INTEGER; - + function ufixed_low (size_res : UNRESOLVED_ufixed; operation : CHARACTER := 'X'; size_res2 : UNRESOLVED_ufixed) return INTEGER; - + function sfixed_high (size_res : UNRESOLVED_sfixed; operation : CHARACTER := 'X'; size_res2 : UNRESOLVED_sfixed) return INTEGER; - + function sfixed_low (size_res : UNRESOLVED_sfixed; operation : CHARACTER := 'X'; size_res2 : UNRESOLVED_sfixed) @@ -1035,7 +1038,7 @@ package fixed_generic_pkg is -- These functions are here so that a std_logic_vector can be -- converted to and from sfixed and ufixed. Note that you can -- not convert these vectors because of their negative index. - + function to_slv ( arg : UNRESOLVED_ufixed) -- fixed point vector return STD_LOGIC_VECTOR; @@ -1119,12 +1122,12 @@ package fixed_generic_pkg is -- Where "11" is the width of xxx (xxx'length), -- and 3 is the lower bound (abs (xxx'low)) -- In a pure VHDL environment use "ufixed_high" and "ufixed_low" - + function UFix_high (width, fraction : NATURAL; operation : CHARACTER := 'X'; width2, fraction2 : NATURAL := 0) return INTEGER; - + function UFix_low (width, fraction : NATURAL; operation : CHARACTER := 'X'; width2, fraction2 : NATURAL := 0) @@ -1133,12 +1136,12 @@ package fixed_generic_pkg is -- Same as above but for signed fixed point. Note that the width -- of a signed fixed point number ignores the sign bit, thus -- width = sxxx'length-1 - + function SFix_high (width, fraction : NATURAL; operation : CHARACTER := 'X'; width2, fraction2 : NATURAL := 0) return INTEGER; - + function SFix_low (width, fraction : NATURAL; operation : CHARACTER := 'X'; width2, fraction2 : NATURAL := 0) @@ -1257,26 +1260,26 @@ package fixed_generic_pkg is alias HEX_WRITE is HWRITE [LINE, UNRESOLVED_sfixed, SIDE, WIDTH]; -- returns a string, useful for: - -- assert (x = y) report "error found " & to_string(x) severity error; - function to_string (value : UNRESOLVED_ufixed) return STRING; + -- assert (x = y) report "error found " & TO_STRING(x) severity error; + function TO_STRING (value : UNRESOLVED_ufixed) return STRING; - alias to_bstring is to_string [UNRESOLVED_ufixed return STRING]; + alias TO_BSTRING is TO_STRING [UNRESOLVED_ufixed return STRING]; alias TO_BINARY_STRING is TO_STRING [UNRESOLVED_ufixed return STRING]; - function to_ostring (value : UNRESOLVED_ufixed) return STRING; + function TO_OSTRING (value : UNRESOLVED_ufixed) return STRING; alias TO_OCTAL_STRING is TO_OSTRING [UNRESOLVED_ufixed return STRING]; - function to_hstring (value : UNRESOLVED_ufixed) return STRING; + function TO_HSTRING (value : UNRESOLVED_ufixed) return STRING; alias TO_HEX_STRING is TO_HSTRING [UNRESOLVED_ufixed return STRING]; - function to_string (value : UNRESOLVED_sfixed) return STRING; - alias to_bstring is to_string [UNRESOLVED_sfixed return STRING]; + function TO_STRING (value : UNRESOLVED_sfixed) return STRING; + alias TO_BSTRING is TO_STRING [UNRESOLVED_sfixed return STRING]; alias TO_BINARY_STRING is TO_STRING [UNRESOLVED_sfixed return STRING]; - function to_ostring (value : UNRESOLVED_sfixed) return STRING; + function TO_OSTRING (value : UNRESOLVED_sfixed) return STRING; alias TO_OCTAL_STRING is TO_OSTRING [UNRESOLVED_sfixed return STRING]; - function to_hstring (value : UNRESOLVED_sfixed) return STRING; + function TO_HSTRING (value : UNRESOLVED_sfixed) return STRING; alias TO_HEX_STRING is TO_HSTRING [UNRESOLVED_sfixed return STRING]; -- From string functions allow you to convert a string into a fixed @@ -1286,7 +1289,7 @@ package fixed_generic_pkg is -- The "." is optional in this syntax, however it exist and is -- in the wrong location an error is produced. Overflow will -- result in saturation. - + function from_string ( bstring : STRING; -- binary string constant left_index : INTEGER; @@ -1300,7 +1303,7 @@ package fixed_generic_pkg is -- Octal and hex conversions work as follows: -- uf1 <= from_hstring ("6.8", 3, -3); -- 6.5 (bottom zeros dropped) -- uf1 <= from_ostring ("06.4", 3, -3); -- 6.5 (top zeros dropped) - + function from_ostring ( ostring : STRING; -- Octal string constant left_index : INTEGER; @@ -1395,7 +1398,7 @@ package fixed_generic_pkg is -- uf1 <= from_string ("0110.100"); -- 6.5 -- In this case the "." is not optional, and the size of -- the output must match exactly. - + function from_string ( bstring : STRING) -- binary string return UNRESOLVED_ufixed; @@ -1406,7 +1409,7 @@ package fixed_generic_pkg is -- the string lengths must match. Example: -- signal sf1 := sfixed (5 downto -3); -- sf1 <= from_ostring ("71.4") -- -6.5 - + function from_ostring ( ostring : STRING) -- Octal string return UNRESOLVED_ufixed; diff --git a/libraries/ieee2008/fixed_pkg.vhdl b/libraries/ieee2008/fixed_pkg.vhdl index a77cd280f..1436432ac 100644 --- a/libraries/ieee2008/fixed_pkg.vhdl +++ b/libraries/ieee2008/fixed_pkg.vhdl @@ -1,17 +1,21 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. +-- -- -- Title : Fixed-point package (Instantiated package declaration) -- : diff --git a/libraries/ieee2008/float_generic_pkg-body.vhdl b/libraries/ieee2008/float_generic_pkg-body.vhdl index 2100f4ad0..35a9ce48b 100644 --- a/libraries/ieee2008/float_generic_pkg-body.vhdl +++ b/libraries/ieee2008/float_generic_pkg-body.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Floating-point package (Generic package body) -- : @@ -266,8 +269,8 @@ package body float_generic_pkg is exp := SIGNED(arg(exponent_width-1 downto 0)); exp (exponent_width-1) := not exp(exponent_width-1); when others => - assert NO_WARNING - report FLOAT_GENERIC_PKG'instance_name + assert no_warning + report float_generic_pkg'instance_name & "BREAK_NUMBER: " & "Meta state detected in fp_break_number process" severity warning; @@ -370,14 +373,13 @@ package body float_generic_pkg is arg : UNRESOLVED_float) -- fp vector return STD_ULOGIC_VECTOR is - subtype result_subtype is STD_ULOGIC_VECTOR (arg'length-1 downto 0); - variable result : STD_ULOGIC_VECTOR (arg'length-1 downto 0); + variable intermediate_result : UNRESOLVED_float(arg'length-1 downto 0); begin -- function to_std_ulogic_vector if arg'length < 1 then return NSLV; end if; - result := result_subtype (arg); - return result; + intermediate_result := arg; + return STD_ULOGIC_VECTOR (intermediate_result); end function to_sulv; -- Converts an fp into an SULV @@ -573,7 +575,7 @@ package body float_generic_pkg is begin -- classfp if (arg'length < 1 or fraction_width < 3 or exponent_width < 3 or x'left < x'right) then - report FLOAT_GENERIC_PKG'instance_name + report float_generic_pkg'instance_name & "CLASSFP: " & "Floating point number detected with a bad range" severity error; @@ -633,7 +635,6 @@ package body float_generic_pkg is fract : out UNRESOLVED_UNSIGNED; expon : out UNRESOLVED_SIGNED; sign : out STD_ULOGIC) is - constant fraction_width : NATURAL := -mine(arg'low, arg'low); -- length of FP output fraction variable fptyp : valid_fpstate; begin fptyp := Classfp (arg, check_error); @@ -645,7 +646,7 @@ package body float_generic_pkg is fract => fract, expon => expon); end procedure break_number; - + procedure break_number ( arg : in UNRESOLVED_float; denormalize : in BOOLEAN := float_denormalize; @@ -677,7 +678,7 @@ package body float_generic_pkg is begin if (arg'length > 0) then result := to_01 (arg, 'X'); - result (arg'high) := '0'; -- set the sign bit to positive + result (arg'high) := '0'; -- set the sign bit to positive return result; else return NAFP; @@ -729,8 +730,8 @@ package body float_generic_pkg is if (fraction_width = 0 or l'length < 7 or r'length < 7) then lfptype := isx; else - lfptype := classfp (l, check_error); - rfptype := classfp (r, check_error); + lfptype := Classfp (l, check_error); + rfptype := Classfp (r, check_error); end if; if (lfptype = isx or rfptype = isx) then fpresult := (others => 'X'); @@ -752,18 +753,18 @@ package body float_generic_pkg is fpresult := neg_zerofp (fraction_width => fraction_width, exponent_width => exponent_width); else - lresize := resize (arg => to_x01(l), + lresize := resize (arg => to_X01(l), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - lfptype := classfp (lresize, false); -- errors already checked - rresize := resize (arg => to_x01(r), + lfptype := Classfp (lresize, false); -- errors already checked + rresize := resize (arg => to_X01(r), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - rfptype := classfp (rresize, false); -- errors already checked + rfptype := Classfp (rresize, false); -- errors already checked break_number ( arg => lresize, fptyp => lfptype, @@ -898,8 +899,8 @@ package body float_generic_pkg is if (fraction_width = 0 or l'length < 7 or r'length < 7) then lfptype := isx; else - lfptype := classfp (l, check_error); - rfptype := classfp (r, check_error); + lfptype := Classfp (l, check_error); + rfptype := Classfp (r, check_error); end if; if (lfptype = isx or rfptype = isx) then fpresult := (others => 'X'); @@ -924,18 +925,18 @@ package body float_generic_pkg is fpresult (exponent_width) := fp_sign; else fp_sign := l(l'high) xor r(r'high); -- figure out the sign - lresize := resize (arg => to_x01(l), + lresize := resize (arg => to_X01(l), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - lfptype := classfp (lresize, false); -- errors already checked - rresize := resize (arg => to_x01(r), + lfptype := Classfp (lresize, false); -- errors already checked + rresize := resize (arg => to_X01(r), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - rfptype := classfp (rresize, false); -- errors already checked + rfptype := Classfp (rresize, false); -- errors already checked break_number ( arg => lresize, fptyp => lfptype, @@ -1041,7 +1042,7 @@ package body float_generic_pkg is variable sfract : UNSIGNED (fraction_width+1+divguard downto 0); -- result fraction variable fpresult : UNRESOLVED_float (exponent_width downto -fraction_width); begin -- reciprocal - fptype := classfp(arg, check_error); + fptype := Classfp(arg, check_error); classcase : case fptype is when isx => fpresult := (others => 'X'); @@ -1053,7 +1054,7 @@ package body float_generic_pkg is fpresult := zerofp (fraction_width => fraction_width, exponent_width => exponent_width); when neg_zero | pos_zero => -- 1/0 - report FLOAT_GENERIC_PKG'instance_name + report float_generic_pkg'instance_name & "RECIPROCAL: Floating Point divide by zero" severity error; fpresult := pos_inffp (fraction_width => fraction_width, @@ -1134,8 +1135,8 @@ package body float_generic_pkg is if (fraction_width = 0 or l'length < 7 or r'length < 7) then lfptype := isx; else - lfptype := classfp (l, check_error); - rfptype := classfp (r, check_error); + lfptype := Classfp (l, check_error); + rfptype := Classfp (r, check_error); end if; classcase : case rfptype is when isx => @@ -1192,18 +1193,18 @@ package body float_generic_pkg is fpresult(exponent_width) := fp_sign; when others => fp_sign := l(l'high) xor r(r'high); -- sign - lresize := resize (arg => to_x01(l), + lresize := resize (arg => to_X01(l), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - lfptype := classfp (lresize, false); -- errors already checked - rresize := resize (arg => to_x01(r), + lfptype := Classfp (lresize, false); -- errors already checked + rresize := resize (arg => to_X01(r), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - rfptype := classfp (rresize, false); -- errors already checked + rfptype := Classfp (rresize, false); -- errors already checked break_number ( arg => lresize, fptyp => lfptype, @@ -1277,8 +1278,8 @@ package body float_generic_pkg is if (fraction_width = 0 or l'length < 7 or r'length < 7) then lfptype := isx; else - lfptype := classfp (l, check_error); - rfptype := classfp (r, check_error); + lfptype := Classfp (l, check_error); + rfptype := Classfp (r, check_error); end if; classcase : case rfptype is when isx => @@ -1304,7 +1305,7 @@ package body float_generic_pkg is fpresult := qnanfp (fraction_width => fraction_width, exponent_width => exponent_width); else - report FLOAT_GENERIC_PKG'instance_name + report float_generic_pkg'instance_name & "DIVIDEBYP2: Floating Point divide by zero" severity error; -- Infinity, define in 754-1985-7.2 @@ -1333,18 +1334,18 @@ package body float_generic_pkg is fpresult (exponent_width) := fp_sign; -- sign when others => fp_sign := l(l'high) xor r(r'high); -- sign - lresize := resize (arg => to_x01(l), + lresize := resize (arg => to_X01(l), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - lfptype := classfp (lresize, false); -- errors already checked - rresize := resize (arg => to_x01(r), + lfptype := Classfp (lresize, false); -- errors already checked + rresize := resize (arg => to_X01(r), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - rfptype := classfp (rresize, false); -- errors already checked + rfptype := Classfp (rresize, false); -- errors already checked break_number ( arg => lresize, fptyp => lfptype, @@ -1359,7 +1360,7 @@ package body float_generic_pkg is fract => urfract, expon => exponr); assert (or (urfract (fraction_width-1 downto 0)) = '0') - report FLOAT_GENERIC_PKG'instance_name + report float_generic_pkg'instance_name & "DIVIDEBYP2: " & "Dividebyp2 called with a non power of two divisor" severity error; @@ -1399,7 +1400,7 @@ package body float_generic_pkg is variable fractx : UNSIGNED (fraction_width+guard downto 0); variable fractc, fracts : UNSIGNED (fraction_width+1+guard downto 0); variable rfract : UNSIGNED ((2*(fraction_width))+1 downto 0); -- result fraction - variable sfract, ufract : UNSIGNED (fraction_width+1+guard downto 0); -- result fraction + variable ufract : UNSIGNED (fraction_width+1+guard downto 0); -- result fraction variable exponl, exponr, exponc : SIGNED (exponent_width-1 downto 0); -- exponents variable rexpon, rexpon2 : SIGNED (exponent_width+1 downto 0); -- result exponent variable shifty : INTEGER; -- denormal shift @@ -1413,9 +1414,9 @@ package body float_generic_pkg is if (fraction_width = 0 or l'length < 7 or r'length < 7 or c'length < 7) then lfptype := isx; else - lfptype := classfp (l, check_error); - rfptype := classfp (r, check_error); - cfptype := classfp (c, check_error); + lfptype := Classfp (l, check_error); + rfptype := Classfp (r, check_error); + cfptype := Classfp (c, check_error); end if; if (lfptype = isx or rfptype = isx or cfptype = isx) then fpresult := (others => 'X'); @@ -1441,24 +1442,24 @@ package body float_generic_pkg is fpresult (exponent_width) := l(l'high) xor r(r'high); else fp_sign := l(l'high) xor r(r'high); -- figure out the sign - lresize := resize (arg => to_x01(l), + lresize := resize (arg => to_X01(l), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - lfptype := classfp (lresize, false); -- errors already checked - rresize := resize (arg => to_x01(r), + lfptype := Classfp (lresize, false); -- errors already checked + rresize := resize (arg => to_X01(r), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - rfptype := classfp (rresize, false); -- errors already checked - cresize := resize (arg => to_x01(c), + rfptype := Classfp (rresize, false); -- errors already checked + cresize := resize (arg => to_X01(c), exponent_width => exponent_width, fraction_width => -cresize'low, denormalize_in => denormalize, denormalize => denormalize); - cfptype := classfp (cresize, false); -- errors already checked + cfptype := Classfp (cresize, false); -- errors already checked break_number ( arg => lresize, fptyp => lfptype, @@ -1590,8 +1591,8 @@ package body float_generic_pkg is if (fraction_width = 0 or l'length < 7 or r'length < 7) then lfptype := isx; else - lfptype := classfp (l, check_error); - rfptype := classfp (r, check_error); + lfptype := Classfp (l, check_error); + rfptype := Classfp (r, check_error); end if; if (lfptype = isx or rfptype = isx) then fpresult := (others => 'X'); @@ -1611,18 +1612,18 @@ package body float_generic_pkg is fpresult := l; else fp_sign := to_X01(l(l'high)); -- sign - lresize := resize (arg => to_x01(l), + lresize := resize (arg => to_X01(l), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - lfptype := classfp (lresize, false); -- errors already checked - rresize := resize (arg => to_x01(r), + lfptype := Classfp (lresize, false); -- errors already checked + rresize := resize (arg => to_X01(r), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - rfptype := classfp (rresize, false); -- errors already checked + rfptype := Classfp (rresize, false); -- errors already checked fractl := (others => '0'); break_number ( arg => lresize, @@ -1686,8 +1687,8 @@ package body float_generic_pkg is if (fraction_width = 0 or l'length < 7 or r'length < 7) then lfptype := isx; else - lfptype := classfp (l, check_error); - rfptype := classfp (r, check_error); + lfptype := Classfp (l, check_error); + rfptype := Classfp (r, check_error); end if; if (lfptype = isx or rfptype = isx) then fpresult := (others => 'X'); @@ -1712,10 +1713,10 @@ package body float_generic_pkg is denormalize => denormalize); -- MOD is the same as REM, but you do something different with -- negative values - if (is_negative (l)) then + if (Is_Negative (l)) then remres := - remres; end if; - if (is_negative (l) = is_negative (r) or remres = 0) then + if (Is_Negative (l) = Is_Negative (r) or remres = 0) then fpresult := remres; else fpresult := add (l => remres, @@ -1723,7 +1724,7 @@ package body float_generic_pkg is round_style => round_style, guard => guard, check_error => false, - denormalize => denormalize); + denormalize => denormalize); end if; end if; return fpresult; @@ -1827,19 +1828,19 @@ package body float_generic_pkg is if (fraction_width = 0 or l'length < 7 or r'length < 7) then return false; else - lfptype := classfp (l, check_error); - rfptype := classfp (r, check_error); + lfptype := Classfp (l, check_error); + rfptype := Classfp (r, check_error); end if; if (lfptype = neg_zero or lfptype = pos_zero) and (rfptype = neg_zero or rfptype = pos_zero) then is_equal := true; else - lresize := resize (arg => to_x01(l), + lresize := resize (arg => to_X01(l), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - rresize := resize (arg => to_x01(r), + rresize := resize (arg => to_X01(r), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, @@ -1872,12 +1873,12 @@ package body float_generic_pkg is if (fraction_width = 0 or l'length < 7 or r'length < 7) then is_less_than := false; else - lresize := resize (arg => to_x01(l), + lresize := resize (arg => to_X01(l), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - rresize := resize (arg => to_x01(r), + rresize := resize (arg => to_X01(r), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, @@ -1901,8 +1902,8 @@ package body float_generic_pkg is end if; end if; else - lfptype := classfp (l, check_error); - rfptype := classfp (r, check_error); + lfptype := Classfp (l, check_error); + rfptype := Classfp (r, check_error); if (lfptype = neg_zero and rfptype = pos_zero) then is_less_than := false; -- -0 < 0 returns false. else @@ -1937,12 +1938,12 @@ package body float_generic_pkg is if (fraction_width = 0 or l'length < 7 or r'length < 7) then is_greater_than := false; else - lresize := resize (arg => to_x01(l), + lresize := resize (arg => to_X01(l), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, denormalize => denormalize); - rresize := resize (arg => to_x01(r), + rresize := resize (arg => to_X01(r), exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => denormalize, @@ -1966,8 +1967,8 @@ package body float_generic_pkg is end if; end if; else - lfptype := classfp (l, check_error); - rfptype := classfp (r, check_error); + lfptype := Classfp (l, check_error); + rfptype := Classfp (r, check_error); if (lfptype = pos_zero and rfptype = neg_zero) then is_greater_than := false; -- 0 > -0 returns false. else @@ -2049,28 +2050,28 @@ package body float_generic_pkg is end function ge; function "?=" (L, R : UNRESOLVED_float) return STD_ULOGIC is - constant fraction_width : NATURAL := -mine(l'low, r'low); -- length of FP output fraction - constant exponent_width : NATURAL := maximum(l'high, r'high); -- length of FP output exponent + constant fraction_width : NATURAL := -mine(L'low, R'low); -- length of FP output fraction + constant exponent_width : NATURAL := maximum(L'high, R'high); -- length of FP output exponent variable lfptype, rfptype : valid_fpstate; variable is_equal, is_unordered : STD_ULOGIC; variable lresize, rresize : UNRESOLVED_float (exponent_width downto -fraction_width); begin -- ?= - if (fraction_width = 0 or l'length < 7 or r'length < 7) then + if (fraction_width = 0 or L'length < 7 or R'length < 7) then return 'X'; else - lfptype := classfp (l, float_check_error); - rfptype := classfp (r, float_check_error); + lfptype := Classfp (L, float_check_error); + rfptype := Classfp (R, float_check_error); end if; if (lfptype = neg_zero or lfptype = pos_zero) and (rfptype = neg_zero or rfptype = pos_zero) then is_equal := '1'; else - lresize := resize (arg => l, + lresize := resize (arg => L, exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => float_denormalize, denormalize => float_denormalize); - rresize := resize (arg => r, + rresize := resize (arg => R, exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => float_denormalize, @@ -2091,28 +2092,28 @@ package body float_generic_pkg is end function "?="; function "?/=" (L, R : UNRESOLVED_float) return STD_ULOGIC is - constant fraction_width : NATURAL := -mine(l'low, r'low); -- length of FP output fraction - constant exponent_width : NATURAL := maximum(l'high, r'high); -- length of FP output exponent + constant fraction_width : NATURAL := -mine(L'low, R'low); -- length of FP output fraction + constant exponent_width : NATURAL := maximum(L'high, R'high); -- length of FP output exponent variable lfptype, rfptype : valid_fpstate; variable is_equal, is_unordered : STD_ULOGIC; variable lresize, rresize : UNRESOLVED_float (exponent_width downto -fraction_width); begin -- ?/= - if (fraction_width = 0 or l'length < 7 or r'length < 7) then + if (fraction_width = 0 or L'length < 7 or R'length < 7) then return 'X'; else - lfptype := classfp (l, float_check_error); - rfptype := classfp (r, float_check_error); + lfptype := Classfp (L, float_check_error); + rfptype := Classfp (R, float_check_error); end if; if (lfptype = neg_zero or lfptype = pos_zero) and (rfptype = neg_zero or rfptype = pos_zero) then is_equal := '1'; else - lresize := resize (arg => l, + lresize := resize (arg => L, exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => float_denormalize, denormalize => float_denormalize); - rresize := resize (arg => r, + rresize := resize (arg => R, exponent_width => exponent_width, fraction_width => fraction_width, denormalize_in => float_denormalize, @@ -2133,10 +2134,10 @@ package body float_generic_pkg is end function "?/="; function "?>" (L, R : UNRESOLVED_float) return STD_ULOGIC is - constant fraction_width : NATURAL := -mine(l'low, r'low); + constant fraction_width : NATURAL := -mine(L'low, R'low); variable founddash : BOOLEAN := false; begin - if (fraction_width = 0 or l'length < 7 or r'length < 7) then + if (fraction_width = 0 or L'length < 7 or R'length < 7) then return 'X'; else for i in L'range loop @@ -2154,9 +2155,9 @@ package body float_generic_pkg is & " ""?>"": '-' found in compare string" severity error; return 'X'; - elsif is_x(l) or is_x(r) then + elsif Is_X(L) or Is_X(R) then return 'X'; - elsif l > r then + elsif L > R then return '1'; else return '0'; @@ -2165,10 +2166,10 @@ package body float_generic_pkg is end function "?>"; function "?>=" (L, R : UNRESOLVED_float) return STD_ULOGIC is - constant fraction_width : NATURAL := -mine(l'low, r'low); + constant fraction_width : NATURAL := -mine(L'low, R'low); variable founddash : BOOLEAN := false; begin - if (fraction_width = 0 or l'length < 7 or r'length < 7) then + if (fraction_width = 0 or L'length < 7 or R'length < 7) then return 'X'; else for i in L'range loop @@ -2186,9 +2187,9 @@ package body float_generic_pkg is & " ""?>="": '-' found in compare string" severity error; return 'X'; - elsif is_x(l) or is_x(r) then + elsif Is_X(L) or Is_X(R) then return 'X'; - elsif l >= r then + elsif L >= R then return '1'; else return '0'; @@ -2197,10 +2198,10 @@ package body float_generic_pkg is end function "?>="; function "?<" (L, R : UNRESOLVED_float) return STD_ULOGIC is - constant fraction_width : NATURAL := -mine(l'low, r'low); + constant fraction_width : NATURAL := -mine(L'low, R'low); variable founddash : BOOLEAN := false; begin - if (fraction_width = 0 or l'length < 7 or r'length < 7) then + if (fraction_width = 0 or L'length < 7 or R'length < 7) then return 'X'; else for i in L'range loop @@ -2218,9 +2219,9 @@ package body float_generic_pkg is & " ""?<"": '-' found in compare string" severity error; return 'X'; - elsif is_x(l) or is_x(r) then + elsif Is_X(L) or Is_X(R) then return 'X'; - elsif l < r then + elsif L < R then return '1'; else return '0'; @@ -2229,10 +2230,10 @@ package body float_generic_pkg is end function "?<"; function "?<=" (L, R : UNRESOLVED_float) return STD_ULOGIC is - constant fraction_width : NATURAL := -mine(l'low, r'low); + constant fraction_width : NATURAL := -mine(L'low, R'low); variable founddash : BOOLEAN := false; begin - if (fraction_width = 0 or l'length < 7 or r'length < 7) then + if (fraction_width = 0 or L'length < 7 or R'length < 7) then return 'X'; else for i in L'range loop @@ -2250,9 +2251,9 @@ package body float_generic_pkg is & " ""?<="": '-' found in compare string" severity error; return 'X'; - elsif is_x(l) or is_x(r) then + elsif Is_X(L) or Is_X(R) then return 'X'; - elsif l <= r then + elsif L <= R then return '1'; else return '0'; @@ -2328,14 +2329,14 @@ package body float_generic_pkg is L, R : UNRESOLVED_float) return UNRESOLVED_float is - constant fraction_width : NATURAL := -mine(l'low, r'low); -- length of FP output fraction - constant exponent_width : NATURAL := maximum(l'high, r'high); -- length of FP output exponent + constant fraction_width : NATURAL := -mine(L'low, R'low); -- length of FP output fraction + constant exponent_width : NATURAL := maximum(L'high, R'high); -- length of FP output exponent variable lresize, rresize : UNRESOLVED_float (exponent_width downto -fraction_width); begin if ((L'length < 1) or (R'length < 1)) then return NAFP; end if; - lresize := resize (l, exponent_width, fraction_width); - rresize := resize (r, exponent_width, fraction_width); + lresize := resize (L, exponent_width, fraction_width); + rresize := resize (R, exponent_width, fraction_width); if lresize > rresize then return lresize; else return rresize; end if; @@ -2345,14 +2346,14 @@ package body float_generic_pkg is L, R : UNRESOLVED_float) return UNRESOLVED_float is - constant fraction_width : NATURAL := -mine(l'low, r'low); -- length of FP output fraction - constant exponent_width : NATURAL := maximum(l'high, r'high); -- length of FP output exponent + constant fraction_width : NATURAL := -mine(L'low, R'low); -- length of FP output fraction + constant exponent_width : NATURAL := maximum(L'high, R'high); -- length of FP output exponent variable lresize, rresize : UNRESOLVED_float (exponent_width downto -fraction_width); begin if ((L'length < 1) or (R'length < 1)) then return NAFP; end if; - lresize := resize (l, exponent_width, fraction_width); - rresize := resize (r, exponent_width, fraction_width); + lresize := resize (L, exponent_width, fraction_width); + rresize := resize (R, exponent_width, fraction_width); if lresize > rresize then return rresize; else return lresize; end if; @@ -2380,12 +2381,10 @@ package body float_generic_pkg is variable fptype : valid_fpstate; variable expon_in : SIGNED (in_exponent_width-1 downto 0); variable fract_in : UNSIGNED (in_fraction_width downto 0); - variable round : BOOLEAN; variable expon_out : SIGNED (exponent_width-1 downto 0); -- output fract variable fract_out : UNSIGNED (fraction_width downto 0); -- output fract - variable passguard : NATURAL; begin - fptype := classfp(arg, check_error); + fptype := Classfp(arg, check_error); if ((fptype = pos_denormal or fptype = neg_denormal) and denormalize_in and (in_exponent_width < exponent_width or in_fraction_width < fraction_width)) @@ -2747,8 +2746,8 @@ package body float_generic_pkg is return UNRESOLVED_float is variable result : UNRESOLVED_float (exponent_width downto -fraction_width); - constant ARG_LEFT : INTEGER := ARG'length-1; - alias XARG : UNSIGNED(ARG_LEFT downto 0) is ARG; + constant ARG_LEFT : INTEGER := arg'length-1; + alias XARG : UNRESOLVED_UNSIGNED(ARG_LEFT downto 0) is arg; variable sarg : SIGNED (ARG_LEFT+1 downto 0); -- signed version of arg begin if arg'length < 1 then @@ -2772,10 +2771,10 @@ package body float_generic_pkg is return UNRESOLVED_float is variable result : UNRESOLVED_float (exponent_width downto -fraction_width); - constant ARG_LEFT : INTEGER := ARG'length-1; - alias XARG : SIGNED(ARG_LEFT downto 0) is ARG; - variable arg_int : UNSIGNED(xarg'range); -- Real version of argument - variable argb2 : UNSIGNED(xarg'high/2 downto 0); -- log2 of input + constant ARG_LEFT : INTEGER := arg'length-1; + alias XARG : UNRESOLVED_SIGNED(ARG_LEFT downto 0) is arg; + variable arg_int : UNSIGNED(XARG'range); -- Real version of argument + variable argb2 : UNSIGNED(XARG'high/2 downto 0); -- log2 of input variable rexp : SIGNED (exponent_width - 1 downto 0); variable exp : SIGNED (exponent_width - 1 downto 0); -- signed version of exp. @@ -2791,14 +2790,14 @@ package body float_generic_pkg is if arg'length < 1 then return NAFP; end if; - if Is_X (xarg) then + if Is_X (XARG) then result := (others => 'X'); - elsif (xarg = 0) then + elsif (XARG = 0) then result := zerofp (fraction_width => fraction_width, exponent_width => exponent_width); else -- Normal number (can't be denormal) - sign := to_X01(xarg (xarg'high)); - arg_int := UNSIGNED(abs (to_01(xarg))); + sign := to_X01(XARG (XARG'high)); + arg_int := UNSIGNED(abs (to_01(XARG))); -- Compute Exponent argb2 := to_unsigned(find_leftmost(arg_int, '1'), argb2'length); -- Log2 if argb2 > UNSIGNED(expon_base) then @@ -2894,10 +2893,10 @@ package body float_generic_pkg is constant in_fraction_width : INTEGER := arg'low; variable xresult : sfixed (integer_width downto in_fraction_width); variable result : UNRESOLVED_float (exponent_width downto -fraction_width); - variable arg_int : UNSIGNED(integer_width - in_fraction_width - 1 - downto 0); -- signed version of argument + variable arg_int : UNSIGNED(integer_width - in_fraction_width + downto 0); -- unsigned version of argument variable argx : SIGNED (integer_width - in_fraction_width downto 0); - variable exp, exptmp : SIGNED (exponent_width downto 0); + variable exp, exptmp : SIGNED (exponent_width + 1 downto 0); variable expon : UNSIGNED (exponent_width - 1 downto 0); -- Unsigned version of exp. constant expon_base : SIGNED (exponent_width-1 downto 0) := @@ -2919,11 +2918,11 @@ package body float_generic_pkg is result := (others => '0'); -- zero out the result if argx(argx'left) = '1' then -- toss the sign bit result (exponent_width) := '1'; -- Negative number - argx := -argx; -- Make it positive. + arg_int := UNSIGNED(to_x01(not STD_LOGIC_VECTOR (argx))) + 1; -- Make it positive with two's complement else result (exponent_width) := '0'; + arg_int := UNSIGNED(to_x01(STD_LOGIC_VECTOR (argx))); -- new line: direct conversion to unsigned end if; - arg_int := UNSIGNED(to_x01(STD_LOGIC_VECTOR (argx(arg_int'range)))); -- Compute Exponent exp := to_signed(find_leftmost(arg_int, '1'), exp'length); -- Log2 if exp + in_fraction_width > expon_base then -- return infinity @@ -3150,7 +3149,7 @@ package body float_generic_pkg is variable result : INTEGER; variable base : INTEGER; -- Integer exponent begin - validfp := classfp (arg, check_error); + validfp := Classfp (arg, check_error); classcase : case validfp is when isx | nan | quiet_nan | pos_zero | neg_zero | pos_denormal | neg_denormal => result := 0; -- return 0 @@ -3220,7 +3219,7 @@ package body float_generic_pkg is variable frac : UNRESOLVED_UNSIGNED (size-1 downto 0); -- Fraction variable sign : STD_ULOGIC; -- not used begin - validfp := classfp (arg, check_error); + validfp := Classfp (arg, check_error); classcase : case validfp is when isx | nan | quiet_nan => frac := (others => 'X'); @@ -3253,7 +3252,7 @@ package body float_generic_pkg is variable frac : UNRESOLVED_UNSIGNED (size-1 downto 0); -- Fraction variable result : UNRESOLVED_SIGNED (size-1 downto 0); begin - validfp := classfp (arg, check_error); + validfp := Classfp (arg, check_error); classcase : case validfp is when isx | nan | quiet_nan => result := (others => 'X'); @@ -3319,7 +3318,7 @@ package body float_generic_pkg is variable result_big : UNRESOLVED_ufixed (left_index downto right_index-3); variable result : UNRESOLVED_ufixed (left_index downto right_index); -- result begin -- function to_ufixed - validfp := classfp (arg, check_error); + validfp := Classfp (arg, check_error); classcase : case validfp is when isx | nan | quiet_nan => frac := (others => 'X'); @@ -3395,7 +3394,7 @@ package body float_generic_pkg is variable result : UNRESOLVED_sfixed (left_index downto right_index) := (others => '0'); -- result begin -- function to_sfixed - validfp := classfp (arg, check_error); + validfp := Classfp (arg, check_error); classcase : case validfp is when isx | nan | quiet_nan => result := (others => 'X'); @@ -3468,7 +3467,7 @@ package body float_generic_pkg is is variable result : UNRESOLVED_UNSIGNED (size_res'range); begin - if (SIZE_RES'length = 0) then + if (size_res'length = 0) then return result; else result := to_unsigned ( @@ -3490,7 +3489,7 @@ package body float_generic_pkg is is variable result : UNRESOLVED_SIGNED (size_res'range); begin - if (SIZE_RES'length = 0) then + if (size_res'length = 0) then return result; else result := to_signed ( @@ -3574,7 +3573,7 @@ package body float_generic_pkg is variable expon : UNSIGNED (exponent_width - 1 downto 0) := (others => '1'); -- Vectorized exponent begin - validfp := classfp (arg, check_error); + validfp := Classfp (arg, check_error); classcase : case validfp is when isx | pos_zero | neg_zero | nan | quiet_nan => return 0.0; @@ -3637,8 +3636,8 @@ package body float_generic_pkg is variable result : UNRESOLVED_float (arg'range); begin -- function to_01 if (arg'length < 1) then - assert NO_WARNING - report FLOAT_GENERIC_PKG'instance_name + assert no_warning + report float_generic_pkg'instance_name & "TO_01: null detected, returning NULL" severity warning; return NAFP; @@ -3658,8 +3657,8 @@ package body float_generic_pkg is variable result : UNRESOLVED_float (arg'range); begin if (arg'length < 1) then - assert NO_WARNING - report FLOAT_GENERIC_PKG'instance_name + assert no_warning + report float_generic_pkg'instance_name & "TO_X01: null detected, returning NULL" severity warning; return NAFP; @@ -3673,8 +3672,8 @@ package body float_generic_pkg is variable result : UNRESOLVED_float (arg'range); begin if (arg'length < 1) then - assert NO_WARNING - report FLOAT_GENERIC_PKG'instance_name + assert no_warning + report float_generic_pkg'instance_name & "TO_X01Z: null detected, returning NULL" severity warning; return NAFP; @@ -3688,8 +3687,8 @@ package body float_generic_pkg is variable result : UNRESOLVED_float (arg'range); begin if (arg'length < 1) then - assert NO_WARNING - report FLOAT_GENERIC_PKG'instance_name + assert no_warning + report float_generic_pkg'instance_name & "TO_UX01: null detected, returning NULL" severity warning; return NAFP; @@ -4329,7 +4328,7 @@ package body float_generic_pkg is if (L'high = R'high and L'low = R'low) then RESULT := to_sulv(L) and to_sulv(R); else - assert NO_WARNING + assert no_warning report float_generic_pkg'instance_name & """and"": Range error L'RANGE /= R'RANGE" severity warning; @@ -4344,7 +4343,7 @@ package body float_generic_pkg is if (L'high = R'high and L'low = R'low) then RESULT := to_sulv(L) or to_sulv(R); else - assert NO_WARNING + assert no_warning report float_generic_pkg'instance_name & """or"": Range error L'RANGE /= R'RANGE" severity warning; @@ -4359,7 +4358,7 @@ package body float_generic_pkg is if (L'high = R'high and L'low = R'low) then RESULT := to_sulv(L) nand to_sulv(R); else - assert NO_WARNING + assert no_warning report float_generic_pkg'instance_name & """nand"": Range error L'RANGE /= R'RANGE" severity warning; @@ -4374,7 +4373,7 @@ package body float_generic_pkg is if (L'high = R'high and L'low = R'low) then RESULT := to_sulv(L) nor to_sulv(R); else - assert NO_WARNING + assert no_warning report float_generic_pkg'instance_name & """nor"": Range error L'RANGE /= R'RANGE" severity warning; @@ -4389,7 +4388,7 @@ package body float_generic_pkg is if (L'high = R'high and L'low = R'low) then RESULT := to_sulv(L) xor to_sulv(R); else - assert NO_WARNING + assert no_warning report float_generic_pkg'instance_name & """xor"": Range error L'RANGE /= R'RANGE" severity warning; @@ -4404,7 +4403,7 @@ package body float_generic_pkg is if (L'high = R'high and L'low = R'low) then RESULT := to_sulv(L) xnor to_sulv(R); else - assert NO_WARNING + assert no_warning report float_generic_pkg'instance_name & """xnor"": Range error L'RANGE /= R'RANGE" severity warning; @@ -4568,7 +4567,7 @@ package body float_generic_pkg is -- Returns y * 2**n for integral values of N without computing 2**n function Scalb ( y : UNRESOLVED_float; -- floating point input - N : INTEGER; -- exponent to add + N : INTEGER; -- exponent to add constant round_style : round_type := float_round_style; -- rounding option constant check_error : BOOLEAN := float_check_error; -- check for errors constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP @@ -4580,13 +4579,11 @@ package body float_generic_pkg is variable expon : SIGNED (exponent_width-1 downto 0); -- Vectorized exp variable exp : SIGNED (exponent_width downto 0); variable ufract : UNSIGNED (fraction_width downto 0); - constant expon_base : SIGNED (exponent_width-1 downto 0) - := gen_expon_base(exponent_width); -- exponent offset variable fptype : valid_fpstate; begin -- This can be done by simply adding N to the exponent. arg := to_01 (y, 'X'); - fptype := classfp(arg, check_error); + fptype := Classfp(arg, check_error); classcase : case fptype is when isx => result := (others => 'X'); @@ -4618,7 +4615,7 @@ package body float_generic_pkg is -- Returns y * 2**n for integral values of N without computing 2**n function Scalb ( y : UNRESOLVED_float; -- floating point input - N : UNRESOLVED_SIGNED; -- exponent to add + N : UNRESOLVED_SIGNED; -- exponent to add constant round_style : round_type := float_round_style; -- rounding option constant check_error : BOOLEAN := float_check_error; -- check for errors constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP @@ -4651,7 +4648,7 @@ package body float_generic_pkg is begin -- Just return the exponent. arg := to_01 (x, 'X'); - fptype := classfp(arg); + fptype := Classfp(arg); classcase : case fptype is when isx | nan | quiet_nan => -- Return quiet NAN, IEEE754-1985-7.1,1 @@ -4717,8 +4714,8 @@ package body float_generic_pkg is variable validfpx, validfpy : valid_fpstate; -- Valid FP state begin -- fp_Nextafter -- If Y > X, add one to the fraction, otherwise subtract. - validfpx := classfp (x, check_error); - validfpy := classfp (y, check_error); + validfpx := Classfp (x, check_error); + validfpy := Classfp (y, check_error); if validfpx = isx or validfpy = isx then result := (others => 'X'); return result; @@ -4752,8 +4749,8 @@ package body float_generic_pkg is if and (expon (exponent_width-1 downto 1)) = '1' and expon (0) = '0' then -- Exponent is one away from infinity. - assert NO_WARNING - report FLOAT_GENERIC_PKG'instance_name + assert no_warning + report float_generic_pkg'instance_name & "FP_NEXTAFTER: NextAfter overflow" severity warning; return pos_inffp (fraction_width => fraction_width, @@ -4805,7 +4802,7 @@ package body float_generic_pkg is expon (0) := '0'; fract := (others => '1'); elsif validfpx = pos_zero - or classfp (x) = neg_zero then + or Classfp (x) = neg_zero then -- return smallest negative denormal number sign := '1'; expon := (others => '0'); @@ -4816,8 +4813,8 @@ package body float_generic_pkg is if and (expon (exponent_width-1 downto 1)) = '1' and expon (0) = '0' then -- Exponent is one away from infinity. - assert NO_WARNING - report FLOAT_GENERIC_PKG'instance_name + assert no_warning + report float_generic_pkg'instance_name & "FP_NEXTAFTER: NextAfter overflow" severity warning; return neg_inffp (fraction_width => fraction_width, @@ -4876,8 +4873,8 @@ package body float_generic_pkg is is variable lfptype, rfptype : valid_fpstate; begin - lfptype := classfp (x); - rfptype := classfp (y); + lfptype := Classfp (x); + rfptype := Classfp (y); if (lfptype = nan or lfptype = quiet_nan or rfptype = nan or rfptype = quiet_nan or lfptype = isx or rfptype = isx) then @@ -5070,13 +5067,14 @@ package body float_generic_pkg is -- purpose: Skips white space procedure skip_whitespace ( L : inout LINE) is - variable readOk : BOOLEAN; - variable c : CHARACTER; + variable c : CHARACTER; + variable left : positive; begin while L /= null and L.all'length /= 0 loop - c := l (l'left); + left := L.all'left; + c := L.all(left); if (c = ' ' or c = NBSP or c = HT) then - read (l, c, readOk); + read (L, c); else exit; end if; @@ -5143,7 +5141,7 @@ package body float_generic_pkg is VALUE : in UNRESOLVED_float; -- floating point input JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is - variable s : STRING(1 to value'high - value'low +3); + variable s : STRING(1 to VALUE'high - VALUE'low +3); variable sindx : INTEGER; begin -- function write s(1) := MVL9_to_char(STD_ULOGIC(VALUE(VALUE'high))); @@ -5172,10 +5170,10 @@ package body float_generic_pkg is variable i : INTEGER; -- index variable begin -- READ VALUE := (VALUE'range => 'U'); -- initialize to a "U" - Skip_whitespace (L); - READ (l, c, readOk); + skip_whitespace (L); + READ (L, c, readOk); if VALUE'length > 0 then - i := value'high; + i := VALUE'high; readloop : loop if readOk = false then -- Bail out if there was a bad read report float_generic_pkg'instance_name @@ -5184,7 +5182,7 @@ package body float_generic_pkg is severity error; return; elsif c = ' ' or c = CR or c = HT then -- reading done. - if (i /= value'low) then + if (i /= VALUE'low) then report float_generic_pkg'instance_name & "READ(float): " & "Warning: Value truncated." @@ -5192,7 +5190,7 @@ package body float_generic_pkg is return; end if; elsif c = '_' then - if i = value'high then -- Begins with an "_" + if i = VALUE'high then -- Begins with an "_" report float_generic_pkg'instance_name & "READ(float): " & "String begins with an ""_""" severity error; @@ -5207,7 +5205,7 @@ package body float_generic_pkg is lastu := true; end if; elsif c = ':' or c = '.' then -- separator, ignore - if not (i = -1 or i = value'high-1) then + if not (i = -1 or i = VALUE'high-1) then report float_generic_pkg'instance_name & "READ(float): " & "Warning: Separator point does not match number format: '" @@ -5224,13 +5222,13 @@ package body float_generic_pkg is else mv (i) := char_to_MVL9(c); i := i - 1; - if i < value'low then + if i < VALUE'low then VALUE := mv; return; end if; lastu := false; end if; - READ (l, c, readOk); + READ (L, c, readOk); end loop readloop; end if; end procedure READ; @@ -5245,11 +5243,11 @@ package body float_generic_pkg is variable readOk : BOOLEAN; begin -- READ VALUE := (VALUE'range => 'U'); -- initialize to a "U" - Skip_whitespace (L); - READ (l, c, readOk); + skip_whitespace (L); + READ (L, c, readOk); if VALUE'length > 0 then - i := value'high; - good := false; + i := VALUE'high; + GOOD := false; readloop : loop if readOk = false then -- Bail out if there was a bad read return; @@ -5271,17 +5269,17 @@ package body float_generic_pkg is else mv (i) := char_to_MVL9(c); i := i - 1; - if i < value'low then - good := true; + if i < VALUE'low then + GOOD := true; VALUE := mv; return; end if; lastu := false; end if; - READ (l, c, readOk); + READ (L, c, readOk); end loop readloop; else - good := true; -- read into a null array + GOOD := true; -- read into a null array end if; end procedure READ; @@ -5298,7 +5296,7 @@ package body float_generic_pkg is end procedure OWRITE; procedure OREAD (L : inout LINE; VALUE : out UNRESOLVED_float) is - constant ne : INTEGER := ((value'length+2)/3) * 3; -- pad + constant ne : INTEGER := ((VALUE'length+2)/3) * 3; -- pad variable slv : STD_LOGIC_VECTOR (ne-1 downto 0); -- slv variable slvu : ufixed (VALUE'range); -- Unsigned fixed point variable c : CHARACTER; @@ -5307,7 +5305,7 @@ package body float_generic_pkg is variable colon, dot : BOOLEAN; begin VALUE := (VALUE'range => 'U'); -- initialize to a "U" - Skip_whitespace (L); + skip_whitespace (L); if VALUE'length > 0 then check_punctuation (arg => L.all, colon => colon, @@ -5344,7 +5342,7 @@ package body float_generic_pkg is severity error; return; end if; - read (l, c, ok); -- read the colon + read (L, c, ok); -- read the colon fix_colon (L.all, ne/3); -- replaces the colon with a ".". OREAD (L, slvu (slvu'high-1 downto slvu'low), ok); -- read it like a UFIXED number if not ok then @@ -5377,7 +5375,7 @@ package body float_generic_pkg is end procedure OREAD; procedure OREAD(L : inout LINE; VALUE : out UNRESOLVED_float; GOOD : out BOOLEAN) is - constant ne : INTEGER := ((value'length+2)/3) * 3; -- pad + constant ne : INTEGER := ((VALUE'length+2)/3) * 3; -- pad variable slv : STD_LOGIC_VECTOR (ne-1 downto 0); -- slv variable slvu : ufixed (VALUE'range); -- Unsigned fixed point variable c : CHARACTER; @@ -5387,7 +5385,7 @@ package body float_generic_pkg is begin VALUE := (VALUE'range => 'U'); -- initialize to a "U" GOOD := false; - Skip_whitespace (L); + skip_whitespace (L); if VALUE'length > 0 then check_punctuation (arg => L.all, colon => colon, @@ -5410,7 +5408,7 @@ package body float_generic_pkg is elsif nybble (2 downto 1) /= "00" then return; end if; - read (l, c, ok); -- read the colon + read (L, c, ok); -- read the colon fix_colon (L.all, ne/3); -- replaces the colon with a ".". OREAD (L, slvu (slvu'high-1 downto slvu'low), ok); -- read it like a UFIXED number if not ok then @@ -5447,7 +5445,7 @@ package body float_generic_pkg is end procedure HWRITE; procedure HREAD (L : inout LINE; VALUE : out UNRESOLVED_float) is - constant ne : INTEGER := ((value'length+3)/4) * 4; -- pad + constant ne : INTEGER := ((VALUE'length+3)/4) * 4; -- pad variable slv : STD_LOGIC_VECTOR (ne-1 downto 0); -- slv variable slvu : ufixed (VALUE'range); -- Unsigned fixed point variable c : CHARACTER; @@ -5456,7 +5454,7 @@ package body float_generic_pkg is variable colon, dot : BOOLEAN; begin VALUE := (VALUE'range => 'U'); -- initialize to a "U" - Skip_whitespace (L); + skip_whitespace (L); if VALUE'length > 0 then check_punctuation (arg => L.all, colon => colon, @@ -5493,7 +5491,7 @@ package body float_generic_pkg is severity error; return; end if; - read (l, c, ok); -- read the colon + read (L, c, ok); -- read the colon fix_colon (L.all, ne/4); -- replaces the colon with a ".". HREAD (L, slvu (slvu'high-1 downto slvu'low), ok); -- read it like a UFIXED number if not ok then @@ -5526,7 +5524,7 @@ package body float_generic_pkg is end procedure HREAD; procedure HREAD (L : inout LINE; VALUE : out UNRESOLVED_float; GOOD : out BOOLEAN) is - constant ne : INTEGER := ((value'length+3)/4) * 4; -- pad + constant ne : INTEGER := ((VALUE'length+3)/4) * 4; -- pad variable slv : STD_LOGIC_VECTOR (ne-1 downto 0); -- slv variable slvu : ufixed (VALUE'range); -- Unsigned fixed point variable c : CHARACTER; @@ -5536,7 +5534,7 @@ package body float_generic_pkg is begin VALUE := (VALUE'range => 'U'); -- initialize to a "U" GOOD := false; - Skip_whitespace (L); + skip_whitespace (L); if VALUE'length > 0 then check_punctuation (arg => L.all, colon => colon, @@ -5559,7 +5557,7 @@ package body float_generic_pkg is elsif nybble (3 downto 1) /= "000" then return; end if; - read (l, c, ok); -- read the colon + read (L, c, ok); -- read the colon fix_colon (L.all, ne/4); -- replaces the colon with a ".". HREAD (L, slvu (slvu'high-1 downto slvu'low), ok); -- read it like a UFIXED number if not ok then @@ -5587,17 +5585,17 @@ package body float_generic_pkg is variable s : STRING(1 to value'high - value'low +3); variable sindx : INTEGER; begin -- function write - s(1) := MVL9_to_char(STD_ULOGIC(VALUE(VALUE'high))); + s(1) := MVL9_to_char(STD_ULOGIC(value(value'high))); s(2) := ':'; sindx := 3; - for i in VALUE'high-1 downto 0 loop - s(sindx) := MVL9_to_char(STD_ULOGIC(VALUE(i))); + for i in value'high-1 downto 0 loop + s(sindx) := MVL9_to_char(STD_ULOGIC(value(i))); sindx := sindx + 1; end loop; s(sindx) := ':'; sindx := sindx + 1; - for i in -1 downto VALUE'low loop - s(sindx) := MVL9_to_char(STD_ULOGIC(VALUE(i))); + for i in -1 downto value'low loop + s(sindx) := MVL9_to_char(STD_ULOGIC(value(i))); sindx := sindx + 1; end loop; return s; @@ -5635,7 +5633,7 @@ package body float_generic_pkg is READ (L, result, good); deallocate (L); assert (good) - report FLOAT_GENERIC_PKG'instance_name + report float_generic_pkg'instance_name & "from_string: Bad string " & bstring severity error; return result; @@ -5655,7 +5653,7 @@ package body float_generic_pkg is OREAD (L, result, good); deallocate (L); assert (good) - report FLOAT_GENERIC_PKG'instance_name + report float_generic_pkg'instance_name & "from_ostring: Bad string " & ostring severity error; return result; @@ -5675,7 +5673,7 @@ package body float_generic_pkg is HREAD (L, result, good); deallocate (L); assert (good) - report FLOAT_GENERIC_PKG'instance_name + report float_generic_pkg'instance_name & "from_hstring: Bad string " & hstring severity error; return result; @@ -5683,7 +5681,7 @@ package body float_generic_pkg is function from_string ( bstring : STRING; -- binary string - size_res : UNRESOLVED_float) -- used for sizing only + size_res : UNRESOLVED_float) -- used for sizing only return UNRESOLVED_float is begin return from_string (bstring => bstring, @@ -5693,7 +5691,7 @@ package body float_generic_pkg is function from_ostring ( ostring : STRING; -- Octal string - size_res : UNRESOLVED_float) -- used for sizing only + size_res : UNRESOLVED_float) -- used for sizing only return UNRESOLVED_float is begin return from_ostring (ostring => ostring, @@ -5703,7 +5701,7 @@ package body float_generic_pkg is function from_hstring ( hstring : STRING; -- hex string - size_res : UNRESOLVED_float) -- used for sizing only + size_res : UNRESOLVED_float) -- used for sizing only return UNRESOLVED_float is begin return from_hstring (hstring => hstring, diff --git a/libraries/ieee2008/float_generic_pkg.vhdl b/libraries/ieee2008/float_generic_pkg.vhdl index c83542965..97adbffb6 100644 --- a/libraries/ieee2008/float_generic_pkg.vhdl +++ b/libraries/ieee2008/float_generic_pkg.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Floating-point package (Generic package declaration) -- : @@ -67,7 +70,7 @@ package float_generic_pkg is -- Author David Bishop (dbishop@vhdl.org) constant CopyRightNotice : STRING := - "Copyright 2008 by IEEE. All rights reserved."; + "Copyright IEEE P1076 WG. Licensed Apache 2.0"; use fixed_pkg.all; @@ -805,7 +808,7 @@ package float_generic_pkg is -- Returns y * 2**n for integral values of N without computing 2**n function Scalb ( y : UNRESOLVED_float; -- floating point input - N : INTEGER; -- exponent to add + N : INTEGER; -- exponent to add constant round_style : round_type := float_round_style; -- rounding option constant check_error : BOOLEAN := float_check_error; -- check for errors constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP @@ -814,7 +817,7 @@ package float_generic_pkg is -- Returns y * 2**n for integral values of N without computing 2**n function Scalb ( y : UNRESOLVED_float; -- floating point input - N : UNRESOLVED_SIGNED; -- exponent to add + N : UNRESOLVED_SIGNED; -- exponent to add constant round_style : round_type := float_round_style; -- rounding option constant check_error : BOOLEAN := float_check_error; -- check for errors constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP @@ -900,8 +903,8 @@ package float_generic_pkg is alias BREAD is READ [LINE, UNRESOLVED_float, BOOLEAN]; alias BREAD is READ [LINE, UNRESOLVED_float]; alias BWRITE is WRITE [LINE, UNRESOLVED_float, SIDE, WIDTH]; - alias BINARY_READ is READ [LINE, UNRESOLVED_FLOAT, BOOLEAN]; - alias BINARY_READ is READ [LINE, UNRESOLVED_FLOAT]; + alias BINARY_READ is READ [LINE, UNRESOLVED_float, BOOLEAN]; + alias BINARY_READ is READ [LINE, UNRESOLVED_float]; alias BINARY_WRITE is WRITE [LINE, UNRESOLVED_float, SIDE, WIDTH]; procedure OWRITE ( @@ -914,9 +917,9 @@ package float_generic_pkg is procedure OREAD (L : inout LINE; VALUE : out UNRESOLVED_float); procedure OREAD (L : inout LINE; VALUE : out UNRESOLVED_float; GOOD : out BOOLEAN); - alias OCTAL_READ is OREAD [LINE, UNRESOLVED_FLOAT, BOOLEAN]; - alias OCTAL_READ is OREAD [LINE, UNRESOLVED_FLOAT]; - alias OCTAL_WRITE is OWRITE [LINE, UNRESOLVED_FLOAT, SIDE, WIDTH]; + alias OCTAL_READ is OREAD [LINE, UNRESOLVED_float, BOOLEAN]; + alias OCTAL_READ is OREAD [LINE, UNRESOLVED_float]; + alias OCTAL_WRITE is OWRITE [LINE, UNRESOLVED_float, SIDE, WIDTH]; -- Hex write with padding, no separators procedure HWRITE ( @@ -929,22 +932,22 @@ package float_generic_pkg is procedure HREAD (L : inout LINE; VALUE : out UNRESOLVED_float); procedure HREAD (L : inout LINE; VALUE : out UNRESOLVED_float; GOOD : out BOOLEAN); - alias HEX_READ is HREAD [LINE, UNRESOLVED_FLOAT, BOOLEAN]; - alias HEX_READ is HREAD [LINE, UNRESOLVED_FLOAT]; - alias HEX_WRITE is HWRITE [LINE, UNRESOLVED_FLOAT, SIDE, WIDTH]; + alias HEX_READ is HREAD [LINE, UNRESOLVED_float, BOOLEAN]; + alias HEX_READ is HREAD [LINE, UNRESOLVED_float]; + alias HEX_WRITE is HWRITE [LINE, UNRESOLVED_float, SIDE, WIDTH]; -- returns "S:EEEE:FFFFFFFF" function to_string (value : UNRESOLVED_float) return STRING; - alias TO_BSTRING is TO_STRING [UNRESOLVED_FLOAT return STRING]; - alias TO_BINARY_STRING is TO_STRING [UNRESOLVED_FLOAT return STRING]; + alias TO_BSTRING is TO_STRING [UNRESOLVED_float return STRING]; + alias TO_BINARY_STRING is TO_STRING [UNRESOLVED_float return STRING]; -- Returns a HEX string, with padding function to_hstring (value : UNRESOLVED_float) return STRING; - alias TO_HEX_STRING is TO_HSTRING [UNRESOLVED_FLOAT return STRING]; + alias TO_HEX_STRING is to_hstring [UNRESOLVED_float return STRING]; -- Returns and octal string, with padding function to_ostring (value : UNRESOLVED_float) return STRING; - alias TO_OCTAL_STRING is TO_OSTRING [UNRESOLVED_FLOAT return STRING]; + alias TO_OCTAL_STRING is to_ostring [UNRESOLVED_float return STRING]; function from_string ( bstring : STRING; -- binary string @@ -973,7 +976,7 @@ package float_generic_pkg is function from_string ( bstring : STRING; -- binary string - size_res : UNRESOLVED_float) -- used for sizing only + size_res : UNRESOLVED_float) -- used for sizing only return UNRESOLVED_float; alias from_bstring is from_string [STRING, UNRESOLVED_float return UNRESOLVED_float]; @@ -982,14 +985,14 @@ package float_generic_pkg is function from_ostring ( ostring : STRING; -- Octal string - size_res : UNRESOLVED_float) -- used for sizing only + size_res : UNRESOLVED_float) -- used for sizing only return UNRESOLVED_float; alias from_octal_string is from_ostring [STRING, UNRESOLVED_float return UNRESOLVED_float]; function from_hstring ( hstring : STRING; -- hex string - size_res : UNRESOLVED_float) -- used for sizing only + size_res : UNRESOLVED_float) -- used for sizing only return UNRESOLVED_float; alias from_hex_string is from_hstring [STRING, UNRESOLVED_float return UNRESOLVED_float]; diff --git a/libraries/ieee2008/float_pkg.vhdl b/libraries/ieee2008/float_pkg.vhdl index e69697acf..71df7e118 100644 --- a/libraries/ieee2008/float_pkg.vhdl +++ b/libraries/ieee2008/float_pkg.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Floating-point package (Instantiated package declaration) -- : diff --git a/libraries/ieee2008/math_complex-body.vhdl b/libraries/ieee2008/math_complex-body.vhdl index ecd85e665..6245b8eca 100644 --- a/libraries/ieee2008/math_complex-body.vhdl +++ b/libraries/ieee2008/math_complex-body.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Standard VHDL Mathematical Packages -- : (MATH_COMPLEX package body) @@ -472,7 +475,6 @@ package body MATH_COMPLEX is -- a) Returns Z on error variable ZTEMP : COMPLEX; - variable temp: REAL; variable ZOUT : COMPLEX_POLAR; begin -- Check validity of input arguments @@ -1428,7 +1430,7 @@ package body MATH_COMPLEX is -- Notes: -- a) Returns COMPLEX'(REAL'HIGH, 0.0) on error -- - variable TEMP : REAL := R.RE*R.RE + R.IM*R.IM; + constant TEMP : REAL := R.RE*R.RE + R.IM*R.IM; begin -- Check validity of input arguments if (TEMP = 0.0) then diff --git a/libraries/ieee2008/math_complex.vhdl b/libraries/ieee2008/math_complex.vhdl index 9d4cdcad3..af7c3c3fe 100644 --- a/libraries/ieee2008/math_complex.vhdl +++ b/libraries/ieee2008/math_complex.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Standard VHDL Mathematical Packages -- : (MATH_COMPLEX package declaration) @@ -48,7 +51,7 @@ use WORK.MATH_REAL.all; package MATH_COMPLEX is constant CopyRightNotice : STRING - := "Copyright 2008 IEEE. All rights reserved."; + := "Copyright IEEE P1076 WG. Licensed Apache 2.0"; -- -- Type Definitions diff --git a/libraries/ieee2008/math_real-body.vhdl b/libraries/ieee2008/math_real-body.vhdl index b2f9373c3..2386f82fa 100644 --- a/libraries/ieee2008/math_real-body.vhdl +++ b/libraries/ieee2008/math_real-body.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Standard VHDL Mathematical Packages -- : (MATH_REAL package body) @@ -322,8 +325,8 @@ package body MATH_REAL is -- Notes: -- a) Returns 0.0 on error - variable XNEGATIVE : BOOLEAN := X < 0.0; - variable YNEGATIVE : BOOLEAN := Y < 0.0; + constant XNEGATIVE : BOOLEAN := X < 0.0; + constant YNEGATIVE : BOOLEAN := Y < 0.0; variable VALUE : REAL; begin -- Check validity of input arguments @@ -499,7 +502,7 @@ package body MATH_REAL is variable INIVAL: REAL; variable XLOCAL : REAL := X; - variable NEGATIVE : BOOLEAN := X < 0.0; + constant NEGATIVE : BOOLEAN := X < 0.0; variable OLDVAL : REAL ; variable NEWVAL : REAL ; variable COUNT : INTEGER := 1; @@ -645,7 +648,7 @@ package body MATH_REAL is -- constant EPS : REAL := BASE_EPS*BASE_EPS*BASE_EPS;-- Precision criteria - variable RECIPROCAL: BOOLEAN := X < 0.0;-- Check sign of argument + constant RECIPROCAL: BOOLEAN := X < 0.0;-- Check sign of argument variable XLOCAL : REAL := ABS(X); -- Use positive value variable OLDVAL: REAL ; variable COUNT: INTEGER ; @@ -792,11 +795,7 @@ package body MATH_REAL is -- 2. Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. - -- 3. All advertising materials mentioning features or use of this - -- software must display the following acknowledgement: - -- This product includes software developed by the University of - -- California, Berkeley and its contributors. - -- 4. Neither the name of the University nor the names of its + -- 3. Neither the name of the University nor the names of its -- contributors may be used to endorse or promote products derived -- from this software without specific prior written permission. -- @@ -1099,8 +1098,6 @@ package body MATH_REAL is variable M, J:INTEGER; variable F1, F2, G, Q, U, U2, V: REAL; - variable ZERO: REAL := 0.0;--Made variable so no constant folding occurs - variable ONE: REAL := 1.0; --Made variable so no constant folding occurs -- double logb(), ldexp(); @@ -1276,7 +1273,7 @@ package body MATH_REAL is constant EPS : REAL := BASE_EPS*BASE_EPS; -- Convergence criteria variable N : INTEGER; - variable NEGATIVE : BOOLEAN := X < 0.0; + constant NEGATIVE : BOOLEAN := X < 0.0; variable XLOCAL : REAL := ABS(X) ; variable VALUE: REAL; variable TEMP : REAL; @@ -1407,7 +1404,7 @@ package body MATH_REAL is -- Compute value for general cases if ((XLOCAL < MATH_PI_OVER_2 ) and (XLOCAL > 0.0)) then - VALUE:= CORDIC( KC, 0.0, x, 27, ROTATION)(1); + VALUE:= CORDIC( KC, 0.0, X, 27, ROTATION)(1); end if; N := INTEGER ( FLOOR(XLOCAL/MATH_PI_OVER_2)); @@ -1446,7 +1443,6 @@ package body MATH_REAL is constant EPS : REAL := BASE_EPS*BASE_EPS; variable XLOCAL : REAL := ABS(X); - variable VALUE: REAL; variable TEMP : REAL; begin @@ -1514,7 +1510,7 @@ package body MATH_REAL is -- c) Returns REAL'LOW on error if X < 0.0 -- d) Returns REAL'HIGH on error if X > 0.0 - variable NEGATIVE : BOOLEAN := X < 0.0; + constant NEGATIVE : BOOLEAN := X < 0.0; variable XLOCAL : REAL := ABS(X) ; variable VALUE: REAL; variable TEMP : REAL; @@ -1575,8 +1571,8 @@ package body MATH_REAL is -- a) ARCSIN(-X) = -ARCSIN(X) -- b) Returns X on error - variable NEGATIVE : BOOLEAN := X < 0.0; - variable XLOCAL : REAL := ABS(X); + constant NEGATIVE : BOOLEAN := X < 0.0; + constant XLOCAL : REAL := ABS(X); variable VALUE : REAL; begin @@ -1620,8 +1616,8 @@ package body MATH_REAL is -- a) ARCCOS(-X) = MATH_PI - ARCCOS(X) -- b) Returns X on error - variable NEGATIVE : BOOLEAN := X < 0.0; - variable XLOCAL : REAL := ABS(X); + constant NEGATIVE : BOOLEAN := X < 0.0; + constant XLOCAL : REAL := ABS(X); variable VALUE : REAL; begin @@ -1668,7 +1664,7 @@ package body MATH_REAL is constant EPS : REAL := BASE_EPS*BASE_EPS*BASE_EPS; - variable NEGATIVE : BOOLEAN := Y < 0.0; + constant NEGATIVE : BOOLEAN := Y < 0.0; variable RECIPROCAL : BOOLEAN; variable YLOCAL : REAL := ABS(Y); variable VALUE : REAL; @@ -1786,8 +1782,8 @@ package body MATH_REAL is -- a) Returns (EXP(X) - EXP(-X))/2.0 -- b) SINH(-X) = SINH(X) - variable NEGATIVE : BOOLEAN := X < 0.0; - variable XLOCAL : REAL := ABS(X); + constant NEGATIVE : BOOLEAN := X < 0.0; + constant XLOCAL : REAL := ABS(X); variable TEMP : REAL; variable VALUE : REAL; @@ -1815,7 +1811,7 @@ package body MATH_REAL is -- a) Returns (EXP(X) + EXP(-X))/2.0 -- b) COSH(-X) = COSH(X) - variable XLOCAL : REAL := ABS(X); + constant XLOCAL : REAL := ABS(X); variable TEMP : REAL; variable VALUE : REAL; begin @@ -1839,8 +1835,8 @@ package body MATH_REAL is -- a) Returns (EXP(X) - EXP(-X))/(EXP(X) + EXP(-X)) -- b) TANH(-X) = -TANH(X) - variable NEGATIVE : BOOLEAN := X < 0.0; - variable XLOCAL : REAL := ABS(X); + constant NEGATIVE : BOOLEAN := X < 0.0; + constant XLOCAL : REAL := ABS(X); variable TEMP : REAL; variable VALUE : REAL; diff --git a/libraries/ieee2008/math_real.vhdl b/libraries/ieee2008/math_real.vhdl index f4660a7e1..37d9a35df 100644 --- a/libraries/ieee2008/math_real.vhdl +++ b/libraries/ieee2008/math_real.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Standard VHDL Mathematical Packages -- : (MATH_REAL package declaration) @@ -47,7 +50,7 @@ package MATH_REAL is constant CopyRightNotice : STRING - := "Copyright 2008 IEEE. All rights reserved."; + := "Copyright IEEE P1076 WG. Licensed Apache 2.0"; -- -- Constant Definitions diff --git a/libraries/ieee2008/numeric_bit-body.vhdl b/libraries/ieee2008/numeric_bit-body.vhdl index f3e17b055..da139bacb 100644 --- a/libraries/ieee2008/numeric_bit-body.vhdl +++ b/libraries/ieee2008/numeric_bit-body.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Standard VHDL Synthesis Packages -- : (NUMERIC_BIT package body) @@ -335,8 +338,6 @@ package body NUMERIC_BIT is -- Id: A.3 function "+" (L, R : UNSIGNED) return UNSIGNED is - constant L_LEFT : INTEGER := L'length-1; - constant R_LEFT : INTEGER := R'length-1; constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then return NAU; @@ -362,8 +363,6 @@ package body NUMERIC_BIT is -- Id: A.4 function "+" (L, R : SIGNED) return SIGNED is - constant L_LEFT : INTEGER := L'length-1; - constant R_LEFT : INTEGER := R'length-1; constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then return NAS; @@ -415,8 +414,6 @@ package body NUMERIC_BIT is -- Id: A.9 function "-" (L, R : UNSIGNED) return UNSIGNED is - constant L_LEFT : INTEGER := L'length-1; - constant R_LEFT : INTEGER := R'length-1; constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then return NAU; @@ -444,8 +441,6 @@ package body NUMERIC_BIT is -- Id: A.10 function "-" (L, R : SIGNED) return SIGNED is - constant L_LEFT : INTEGER := L'length-1; - constant R_LEFT : INTEGER := R'length-1; constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then return NAS; @@ -955,7 +950,7 @@ package body NUMERIC_BIT is -- Id: C.1 function ">" (L, R : UNSIGNED) return BOOLEAN is - variable SIZE : NATURAL := MAXIMUM(L'length, R'length); + constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then assert NO_WARNING @@ -968,7 +963,7 @@ package body NUMERIC_BIT is -- Id: C.2 function ">" (L, R : SIGNED) return BOOLEAN is - variable SIZE : NATURAL := MAXIMUM(L'length, R'length); + constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then assert NO_WARNING @@ -1039,7 +1034,7 @@ package body NUMERIC_BIT is -- Id: C.7 function "<" (L, R : UNSIGNED) return BOOLEAN is - variable SIZE : NATURAL := MAXIMUM(L'length, R'length); + constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then assert NO_WARNING @@ -1052,7 +1047,7 @@ package body NUMERIC_BIT is -- Id: C.8 function "<" (L, R : SIGNED) return BOOLEAN is - variable SIZE : NATURAL := MAXIMUM(L'length, R'length); + constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then assert NO_WARNING @@ -1123,7 +1118,7 @@ package body NUMERIC_BIT is -- Id: C.13 function "<=" (L, R : UNSIGNED) return BOOLEAN is - variable SIZE : NATURAL := MAXIMUM(L'length, R'length); + constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then assert NO_WARNING @@ -1136,7 +1131,7 @@ package body NUMERIC_BIT is -- Id: C.14 function "<=" (L, R : SIGNED) return BOOLEAN is - variable SIZE : NATURAL := MAXIMUM(L'length, R'length); + constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then assert NO_WARNING @@ -1207,7 +1202,7 @@ package body NUMERIC_BIT is -- Id: C.19 function ">=" (L, R : UNSIGNED) return BOOLEAN is - variable SIZE : NATURAL := MAXIMUM(L'length, R'length); + constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then assert NO_WARNING @@ -1220,7 +1215,7 @@ package body NUMERIC_BIT is -- Id: C.20 function ">=" (L, R : SIGNED) return BOOLEAN is - variable SIZE : NATURAL := MAXIMUM(L'length, R'length); + constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then assert NO_WARNING @@ -1291,7 +1286,7 @@ package body NUMERIC_BIT is -- Id: C.25 function "=" (L, R : UNSIGNED) return BOOLEAN is - variable SIZE : NATURAL := MAXIMUM(L'length, R'length); + constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then assert NO_WARNING @@ -1304,7 +1299,7 @@ package body NUMERIC_BIT is -- Id: C.26 function "=" (L, R : SIGNED) return BOOLEAN is - variable SIZE : NATURAL := MAXIMUM(L'length, R'length); + constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then assert NO_WARNING @@ -1375,7 +1370,7 @@ package body NUMERIC_BIT is -- Id: C.31 function "/=" (L, R : UNSIGNED) return BOOLEAN is - variable SIZE : NATURAL := MAXIMUM(L'length, R'length); + constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then assert NO_WARNING @@ -1388,7 +1383,7 @@ package body NUMERIC_BIT is -- Id: C.32 function "/=" (L, R : SIGNED) return BOOLEAN is - variable SIZE : NATURAL := MAXIMUM(L'length, R'length); + constant SIZE : NATURAL := MAXIMUM(L'length, R'length); begin if ((L'length < 1) or (R'length < 1)) then assert NO_WARNING @@ -2447,61 +2442,61 @@ package body NUMERIC_BIT is return RESULT; end function "xnor"; - -- Id: L.15 + -- Id: L.15 function "and" (L : BIT; R : UNSIGNED) return UNSIGNED is begin return UNSIGNED (L and BIT_VECTOR(R)); end function "and"; - -- Id: L.16 + -- Id: L.16 function "and" (L : UNSIGNED; R : BIT) return UNSIGNED is begin return UNSIGNED (BIT_VECTOR(L) and R); end function "and"; - -- Id: L.17 + -- Id: L.17 function "or" (L : BIT; R : UNSIGNED) return UNSIGNED is begin return UNSIGNED (L or BIT_VECTOR(R)); end function "or"; - -- Id: L.18 + -- Id: L.18 function "or" (L : UNSIGNED; R : BIT) return UNSIGNED is begin return UNSIGNED (BIT_VECTOR(L) or R); end function "or"; - -- Id: L.19 + -- Id: L.19 function "nand" (L : BIT; R : UNSIGNED) return UNSIGNED is begin return UNSIGNED (L nand BIT_VECTOR(R)); end function "nand"; - -- Id: L.20 + -- Id: L.20 function "nand" (L : UNSIGNED; R : BIT) return UNSIGNED is begin return UNSIGNED (BIT_VECTOR(L) nand R); end function "nand"; - -- Id: L.21 + -- Id: L.21 function "nor" (L : BIT; R : UNSIGNED) return UNSIGNED is begin return UNSIGNED (L nor BIT_VECTOR(R)); end function "nor"; - -- Id: L.22 + -- Id: L.22 function "nor" (L : UNSIGNED; R : BIT) return UNSIGNED is begin return UNSIGNED (BIT_VECTOR(L) nor R); end function "nor"; - -- Id: L.23 + -- Id: L.23 function "xor" (L : BIT; R : UNSIGNED) return UNSIGNED is begin return UNSIGNED (L xor BIT_VECTOR(R)); end function "xor"; - -- Id: L.24 + -- Id: L.24 function "xor" (L : UNSIGNED; R : BIT) return UNSIGNED is begin return UNSIGNED (BIT_VECTOR(L) xor R); @@ -2511,7 +2506,7 @@ package body NUMERIC_BIT is -- Note: Function L.25 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.25 + -- Id: L.25 function "xnor" (L : BIT; R : UNSIGNED) return UNSIGNED is begin return UNSIGNED (L xnor BIT_VECTOR(R)); @@ -2521,67 +2516,67 @@ package body NUMERIC_BIT is -- Note: Function L.26 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.26 + -- Id: L.26 function "xnor" (L : UNSIGNED; R : BIT) return UNSIGNED is begin return UNSIGNED (BIT_VECTOR(L) xnor R); end function "xnor"; - -- Id: L.27 + -- Id: L.27 function "and" (L : BIT; R : SIGNED) return SIGNED is begin return SIGNED (L and BIT_VECTOR(R)); end function "and"; - -- Id: L.28 + -- Id: L.28 function "and" (L : SIGNED; R : BIT) return SIGNED is begin return SIGNED (BIT_VECTOR(L) and R); end function "and"; - -- Id: L.29 + -- Id: L.29 function "or" (L : BIT; R : SIGNED) return SIGNED is begin return SIGNED (L or BIT_VECTOR(R)); end function "or"; - -- Id: L.30 + -- Id: L.30 function "or" (L : SIGNED; R : BIT) return SIGNED is begin return SIGNED (BIT_VECTOR(L) or R); end function "or"; - -- Id: L.31 + -- Id: L.31 function "nand" (L : BIT; R : SIGNED) return SIGNED is begin return SIGNED (L nand BIT_VECTOR(R)); end function "nand"; - -- Id: L.32 + -- Id: L.32 function "nand" (L : SIGNED; R : BIT) return SIGNED is begin return SIGNED (BIT_VECTOR(L) nand R); end function "nand"; - -- Id: L.33 + -- Id: L.33 function "nor" (L : BIT; R : SIGNED) return SIGNED is begin return SIGNED (L nor BIT_VECTOR(R)); end function "nor"; - -- Id: L.34 + -- Id: L.34 function "nor" (L : SIGNED; R : BIT) return SIGNED is begin return SIGNED (BIT_VECTOR(L) nor R); end function "nor"; - -- Id: L.35 + -- Id: L.35 function "xor" (L : BIT; R : SIGNED) return SIGNED is begin return SIGNED (L xor BIT_VECTOR(R)); end function "xor"; - -- Id: L.36 + -- Id: L.36 function "xor" (L : SIGNED; R : BIT) return SIGNED is begin return SIGNED (BIT_VECTOR(L) xor R); @@ -2591,7 +2586,7 @@ package body NUMERIC_BIT is -- Note: Function L.37 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.37 + -- Id: L.37 function "xnor" (L : BIT; R : SIGNED) return SIGNED is begin return SIGNED (L xnor BIT_VECTOR(R)); @@ -2601,7 +2596,7 @@ package body NUMERIC_BIT is -- Note: Function L.38 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.38 + -- Id: L.38 function "xnor" (L : SIGNED; R : BIT) return SIGNED is begin return SIGNED (BIT_VECTOR(L) xnor R); @@ -2742,18 +2737,18 @@ package body NUMERIC_BIT is -- ============================================================================ -- string conversion and write operations -- ============================================================================ - function to_ostring (value : UNSIGNED) return STRING is + function TO_OSTRING (value : UNSIGNED) return STRING is begin - return to_ostring(BIT_VECTOR (value)); - end function to_ostring; + return TO_OSTRING(BIT_VECTOR (value)); + end function TO_OSTRING; - function to_ostring (value : SIGNED) return STRING is + function TO_OSTRING (value : SIGNED) return STRING is constant result_length : INTEGER := (value'length+2)/3; constant pad : BIT_VECTOR(1 to (result_length*3 - value'length)) := (others => value (value'left)); -- Extend sign bit begin - return to_ostring(pad & BIT_VECTOR (value)); - end function to_ostring; + return TO_OSTRING(pad & BIT_VECTOR (value)); + end function TO_OSTRING; function to_hstring (value : UNSIGNED) return STRING is begin @@ -2769,7 +2764,7 @@ package body NUMERIC_BIT is end function to_hstring; procedure READ(L : inout LINE; VALUE : out UNSIGNED; GOOD : out BOOLEAN) is - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin READ (L => L, VALUE => ivalue, @@ -2778,7 +2773,7 @@ package body NUMERIC_BIT is end procedure READ; procedure READ(L : inout LINE; VALUE : out UNSIGNED) is - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin READ (L => L, VALUE => ivalue); @@ -2786,7 +2781,7 @@ package body NUMERIC_BIT is end procedure READ; procedure READ(L : inout LINE; VALUE : out SIGNED; GOOD : out BOOLEAN) is - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin READ (L => L, VALUE => ivalue, @@ -2795,7 +2790,7 @@ package body NUMERIC_BIT is end procedure READ; procedure READ(L : inout LINE; VALUE : out SIGNED) is - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin READ (L => L, VALUE => ivalue); @@ -2804,7 +2799,7 @@ package body NUMERIC_BIT is procedure WRITE (L : inout LINE; VALUE : in UNSIGNED; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin ivalue := BIT_VECTOR (VALUE); WRITE (L => L, @@ -2815,7 +2810,7 @@ package body NUMERIC_BIT is procedure WRITE (L : inout LINE; VALUE : in SIGNED; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin ivalue := BIT_VECTOR (VALUE); WRITE (L => L, @@ -2825,7 +2820,7 @@ package body NUMERIC_BIT is end procedure WRITE; procedure OREAD (L : inout LINE; VALUE : out UNSIGNED; GOOD : out BOOLEAN) is - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin OREAD (L => L, VALUE => ivalue, @@ -2834,8 +2829,8 @@ package body NUMERIC_BIT is end procedure OREAD; procedure OREAD (L : inout LINE; VALUE : out SIGNED; GOOD : out BOOLEAN) is - constant ne : INTEGER := (value'length+2)/3; - constant pad : INTEGER := ne*3 - value'length; + constant ne : INTEGER := (VALUE'length+2)/3; + constant pad : INTEGER := ne*3 - VALUE'length; variable ivalue : BIT_VECTOR(0 to ne*3-1); variable ok : BOOLEAN; begin @@ -2844,33 +2839,33 @@ package body NUMERIC_BIT is good => ok); -- Bail out if there was a bad read if not ok then - good := false; + GOOD := false; return; end if; if (pad > 0) then if (ivalue(0) = '0') then -- positive if ivalue(0) = or (ivalue(0 to pad)) then VALUE := SIGNED (ivalue (pad to ivalue'high)); - good := true; + GOOD := true; else - good := false; + GOOD := false; end if; else -- negative if ivalue(0) = and (ivalue(0 to pad)) then VALUE := SIGNED (ivalue (pad to ivalue'high)); - good := true; + GOOD := true; else - good := false; + GOOD := false; end if; end if; else - good := true; + GOOD := true; VALUE := SIGNED (ivalue); end if; end procedure OREAD; procedure OREAD (L : inout LINE; VALUE : out UNSIGNED) is - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin OREAD (L => L, VALUE => ivalue); @@ -2878,8 +2873,8 @@ package body NUMERIC_BIT is end procedure OREAD; procedure OREAD (L : inout LINE; VALUE : out SIGNED) is - constant ne : INTEGER := (value'length+2)/3; - constant pad : INTEGER := ne*3 - value'length; + constant ne : INTEGER := (VALUE'length+2)/3; + constant pad : INTEGER := ne*3 - VALUE'length; variable ivalue : BIT_VECTOR(0 to ne*3-1); begin OREAD (L => L, @@ -2908,7 +2903,7 @@ package body NUMERIC_BIT is end procedure OREAD; procedure HREAD (L : inout LINE; VALUE : out UNSIGNED; GOOD : out BOOLEAN) is - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin HREAD (L => L, VALUE => ivalue, @@ -2917,8 +2912,8 @@ package body NUMERIC_BIT is end procedure HREAD; procedure HREAD (L : inout LINE; VALUE : out SIGNED; GOOD : out BOOLEAN) is - constant ne : INTEGER := (value'length+3)/4; - constant pad : INTEGER := ne*4 - value'length; + constant ne : INTEGER := (VALUE'length+3)/4; + constant pad : INTEGER := ne*4 - VALUE'length; variable ivalue : BIT_VECTOR(0 to ne*4-1); variable ok : BOOLEAN; begin @@ -2926,7 +2921,7 @@ package body NUMERIC_BIT is VALUE => ivalue, -- Read padded STRING good => ok); if not ok then - good := false; + GOOD := false; return; end if; if (pad > 0) then @@ -2952,7 +2947,7 @@ package body NUMERIC_BIT is end procedure HREAD; procedure HREAD (L : inout LINE; VALUE : out UNSIGNED) is - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin HREAD (L => L, VALUE => ivalue); @@ -2960,8 +2955,8 @@ package body NUMERIC_BIT is end procedure HREAD; procedure HREAD (L : inout LINE; VALUE : out SIGNED) is - constant ne : INTEGER := (value'length+3)/4; - constant pad : INTEGER := ne*4 - value'length; + constant ne : INTEGER := (VALUE'length+3)/4; + constant pad : INTEGER := ne*4 - VALUE'length; variable ivalue : BIT_VECTOR(0 to ne*4-1); begin HREAD (L => L, @@ -2991,7 +2986,7 @@ package body NUMERIC_BIT is procedure OWRITE (L : inout LINE; VALUE : in UNSIGNED; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin ivalue := BIT_VECTOR (VALUE); OWRITE (L => L, @@ -3005,7 +3000,7 @@ package body NUMERIC_BIT is constant ne : INTEGER := (VALUE'length+2)/3; constant pad : BIT_VECTOR(0 to (ne*3 - VALUE'length) - 1) := (others => VALUE (VALUE'left)); - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin ivalue := BIT_VECTOR (VALUE); OWRITE (L => L, @@ -3016,7 +3011,7 @@ package body NUMERIC_BIT is procedure HWRITE (L : inout LINE; VALUE : in UNSIGNED; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is - variable ivalue : BIT_VECTOR(value'range); + variable ivalue : BIT_VECTOR(VALUE'range); begin ivalue := BIT_VECTOR (VALUE); HWRITE (L => L, @@ -3027,9 +3022,9 @@ package body NUMERIC_BIT is procedure HWRITE (L : inout LINE; VALUE : in SIGNED; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is - variable ivalue : BIT_VECTOR(value'range); - constant ne : INTEGER := (value'length+3)/4; - constant pad : BIT_VECTOR(0 to (ne*4 - value'length) - 1) + variable ivalue : BIT_VECTOR(VALUE'range); + constant ne : INTEGER := (VALUE'length+3)/4; + constant pad : BIT_VECTOR(0 to (ne*4 - VALUE'length) - 1) := (others => VALUE(VALUE'left)); begin ivalue := BIT_VECTOR (VALUE); diff --git a/libraries/ieee2008/numeric_bit.vhdl b/libraries/ieee2008/numeric_bit.vhdl index fa28d6385..5ef4554ea 100644 --- a/libraries/ieee2008/numeric_bit.vhdl +++ b/libraries/ieee2008/numeric_bit.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Standard VHDL Synthesis Packages -- : (NUMERIC_BIT package declaration) @@ -1213,52 +1216,52 @@ package NUMERIC_BIT is -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector XNOR operation - -- Id: L.15 + -- Id: L.15 function "and" (L : BIT; R : UNSIGNED) return UNSIGNED; -- Result subtype: SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector AND operation - -- Id: L.16 + -- Id: L.16 function "and" (L : UNSIGNED; R : BIT) return UNSIGNED; -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar AND operation - -- Id: L.17 + -- Id: L.17 function "or" (L : BIT; R : UNSIGNED) return UNSIGNED; -- Result subtype: SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector OR operation - -- Id: L.18 + -- Id: L.18 function "or" (L : UNSIGNED; R : BIT) return UNSIGNED; -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar OR operation - -- Id: L.19 + -- Id: L.19 function "nand" (L : BIT; R : UNSIGNED) return UNSIGNED; -- Result subtype: SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector NAND operation - -- Id: L.20 + -- Id: L.20 function "nand" (L : UNSIGNED; R : BIT) return UNSIGNED; -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar NAND operation - -- Id: L.21 + -- Id: L.21 function "nor" (L : BIT; R : UNSIGNED) return UNSIGNED; -- Result subtype: SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector NOR operation - -- Id: L.22 + -- Id: L.22 function "nor" (L : UNSIGNED; R : BIT) return UNSIGNED; -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar NOR operation - -- Id: L.23 + -- Id: L.23 function "xor" (L : BIT; R : UNSIGNED) return UNSIGNED; -- Result subtype: SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector XOR operation - -- Id: L.24 + -- Id: L.24 function "xor" (L : UNSIGNED; R : BIT) return UNSIGNED; -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar XOR operation @@ -1267,7 +1270,7 @@ package NUMERIC_BIT is -- Note: Function L.25 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.25 + -- Id: L.25 function "xnor" (L : BIT; R : UNSIGNED) return UNSIGNED; -- Result subtype: SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector XNOR operation @@ -1276,57 +1279,57 @@ package NUMERIC_BIT is -- Note: Function L.26 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.26 + -- Id: L.26 function "xnor" (L : UNSIGNED; R : BIT) return UNSIGNED; -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar XNOR operation - -- Id: L.27 + -- Id: L.27 function "and" (L : BIT; R : SIGNED) return SIGNED; -- Result subtype: SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector AND operation - -- Id: L.28 + -- Id: L.28 function "and" (L : SIGNED; R : BIT) return SIGNED; -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar AND operation - -- Id: L.29 + -- Id: L.29 function "or" (L : BIT; R : SIGNED) return SIGNED; -- Result subtype: SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector OR operation - -- Id: L.30 + -- Id: L.30 function "or" (L : SIGNED; R : BIT) return SIGNED; -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar OR operation - -- Id: L.31 + -- Id: L.31 function "nand" (L : BIT; R : SIGNED) return SIGNED; -- Result subtype: SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector NAND operation - -- Id: L.32 + -- Id: L.32 function "nand" (L : SIGNED; R : BIT) return SIGNED; -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar NAND operation - -- Id: L.33 + -- Id: L.33 function "nor" (L : BIT; R : SIGNED) return SIGNED; -- Result subtype: SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector NOR operation - -- Id: L.34 + -- Id: L.34 function "nor" (L : SIGNED; R : BIT) return SIGNED; -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar NOR operation - -- Id: L.35 + -- Id: L.35 function "xor" (L : BIT; R : SIGNED) return SIGNED; -- Result subtype: SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector XOR operation - -- Id: L.36 + -- Id: L.36 function "xor" (L : SIGNED; R : BIT) return SIGNED; -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar XOR operation @@ -1335,7 +1338,7 @@ package NUMERIC_BIT is -- Note: Function L.37 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.37 + -- Id: L.37 function "xnor" (L : BIT; R : SIGNED) return SIGNED; -- Result subtype: SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector XNOR operation @@ -1344,7 +1347,7 @@ package NUMERIC_BIT is -- Note: Function L.38 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.38 + -- Id: L.38 function "xnor" (L : SIGNED; R : BIT) return SIGNED; -- Result subtype: SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar XNOR operation @@ -1356,8 +1359,8 @@ package NUMERIC_BIT is ------------------------------------------------------------------------------ -- Id: L.39 function "and" (L : SIGNED) return BIT; - -- Result subtype: BIT. - -- Result: Result of and'ing all of the bits of the vector. + -- Result subtype: BIT. + -- Result: Result of and'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.40 is not compatible with editions of IEEE Std 1076 from @@ -1366,8 +1369,8 @@ package NUMERIC_BIT is ------------------------------------------------------------------------------ -- Id: L.40 function "nand" (L : SIGNED) return BIT; - -- Result subtype: BIT. - -- Result: Result of nand'ing all of the bits of the vector. + -- Result subtype: BIT. + -- Result: Result of nand'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.41 is not compatible with editions of IEEE Std 1076 from @@ -1376,8 +1379,8 @@ package NUMERIC_BIT is ------------------------------------------------------------------------------ -- Id: L.41 function "or" (L : SIGNED) return BIT; - -- Result subtype: BIT. - -- Result: Result of or'ing all of the bits of the vector. + -- Result subtype: BIT. + -- Result: Result of or'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.42 is not compatible with editions of IEEE Std 1076 from @@ -1386,8 +1389,8 @@ package NUMERIC_BIT is ------------------------------------------------------------------------------ -- Id: L.42 function "nor" (L : SIGNED) return BIT; - -- Result subtype: BIT. - -- Result: Result of nor'ing all of the bits of the vector. + -- Result subtype: BIT. + -- Result: Result of nor'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.43 is not compatible with editions of IEEE Std 1076 from @@ -1396,8 +1399,8 @@ package NUMERIC_BIT is ------------------------------------------------------------------------------ -- Id: L.43 function "xor" (L : SIGNED) return BIT; - -- Result subtype: BIT. - -- Result: Result of xor'ing all of the bits of the vector. + -- Result subtype: BIT. + -- Result: Result of xor'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.44 is not compatible with editions of IEEE Std 1076 from @@ -1406,8 +1409,8 @@ package NUMERIC_BIT is ------------------------------------------------------------------------------ -- Id: L.44 function "xnor" (L : SIGNED) return BIT; - -- Result subtype: BIT. - -- Result: Result of xnor'ing all of the bits of the vector. + -- Result subtype: BIT. + -- Result: Result of xnor'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.45 is not compatible with editions of IEEE Std 1076 from @@ -1416,8 +1419,8 @@ package NUMERIC_BIT is ------------------------------------------------------------------------------ -- Id: L.45 function "and" (L : UNSIGNED) return BIT; - -- Result subtype: BIT. - -- Result: Result of and'ing all of the bits of the vector. + -- Result subtype: BIT. + -- Result: Result of and'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.46 is not compatible with editions of IEEE Std 1076 from @@ -1426,8 +1429,8 @@ package NUMERIC_BIT is ------------------------------------------------------------------------------ -- Id: L.46 function "nand" (L : UNSIGNED) return BIT; - -- Result subtype: BIT. - -- Result: Result of nand'ing all of the bits of the vector. + -- Result subtype: BIT. + -- Result: Result of nand'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.47 is not compatible with editions of IEEE Std 1076 from @@ -1436,8 +1439,8 @@ package NUMERIC_BIT is ------------------------------------------------------------------------------ -- Id: L.47 function "or" (L : UNSIGNED) return BIT; - -- Result subtype: BIT. - -- Result: Result of or'ing all of the bits of the vector. + -- Result subtype: BIT. + -- Result: Result of or'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.48 is not compatible with editions of IEEE Std 1076 from @@ -1446,8 +1449,8 @@ package NUMERIC_BIT is ------------------------------------------------------------------------------ -- Id: L.48 function "nor" (L : UNSIGNED) return BIT; - -- Result subtype: BIT. - -- Result: Result of nor'ing all of the bits of the vector. + -- Result subtype: BIT. + -- Result: Result of nor'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.49 is not compatible with editions of IEEE Std 1076 from @@ -1456,8 +1459,8 @@ package NUMERIC_BIT is ------------------------------------------------------------------------------ -- Id: L.49 function "xor" (L : UNSIGNED) return BIT; - -- Result subtype: BIT. - -- Result: Result of xor'ing all of the bits of the vector. + -- Result subtype: BIT. + -- Result: Result of xor'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.50 is not compatible with editions of IEEE Std 1076 from @@ -1466,7 +1469,7 @@ package NUMERIC_BIT is ------------------------------------------------------------------------------ -- Id: L.50 function "xnor" (L : UNSIGNED) return BIT; - -- Result subtype: BIT. + -- Result subtype: BIT. -- Result: Result of xnor'ing all of the bits of the vector. --============================================================================ @@ -1492,20 +1495,20 @@ package NUMERIC_BIT is --============================================================================ -- the following operations are predefined - -- FUNCTION to_string ( value : UNSIGNED ) RETURN string; - -- FUNCTION to_string ( value : SIGNED ) RETURN string; + -- FUNCTION TO_STRING ( value : UNSIGNED ) RETURN string; + -- FUNCTION TO_STRING ( value : SIGNED ) RETURN string; -- explicitly defined operations - alias to_bstring is to_string [UNSIGNED return STRING]; - alias to_bstring is to_string [SIGNED return STRING]; - alias to_binary_string is to_string [UNSIGNED return STRING]; - alias to_binary_string is to_string [SIGNED return STRING]; + alias TO_BSTRING is TO_STRING [UNSIGNED return STRING]; + alias TO_BSTRING is TO_STRING [SIGNED return STRING]; + alias to_binary_string is TO_STRING [UNSIGNED return STRING]; + alias to_binary_string is TO_STRING [SIGNED return STRING]; - function to_ostring (value : UNSIGNED) return STRING; - function to_ostring (value : SIGNED) return STRING; - alias to_octal_string is to_ostring [UNSIGNED return STRING]; - alias to_octal_string is to_ostring [SIGNED return STRING]; + function TO_OSTRING (value : UNSIGNED) return STRING; + function TO_OSTRING (value : SIGNED) return STRING; + alias to_octal_string is TO_OSTRING [UNSIGNED return STRING]; + alias to_octal_string is TO_OSTRING [SIGNED return STRING]; function to_hstring (value : UNSIGNED) return STRING; function to_hstring (value : SIGNED) return STRING; diff --git a/libraries/ieee2008/numeric_bit_unsigned-body.vhdl b/libraries/ieee2008/numeric_bit_unsigned-body.vhdl index bf9978235..3120de69e 100644 --- a/libraries/ieee2008/numeric_bit_unsigned-body.vhdl +++ b/libraries/ieee2008/numeric_bit_unsigned-body.vhdl @@ -1,589 +1,592 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. --- --- Title : Standard VHDL Synthesis Packages --- : (NUMERIC_BIT_UNSIGNED package body) --- : --- Library : This package shall be compiled into a library --- : symbolically named IEEE. --- : --- Developers: Accellera VHDL-TC, and IEEE P1076 Working Group --- : --- Purpose : This package defines numeric types and arithmetic functions --- : for use with synthesis tools. Values of type BIT_VECTOR --- : are interpreted as unsigned numbers in vector form. --- : The leftmost bit is treated as the most significant bit. --- : This package contains overloaded arithmetic operators on --- : the BIT_VECTOR type. The package also contains --- : useful type conversions functions, clock detection --- : functions, and other utility functions. --- : --- : If any argument to a function is a null array, a null array --- : is returned (exceptions, if any, are noted individually). --- --- Note : This package may be modified to include additional data --- : required by tools, but it must in no way change the --- : external interfaces or simulation behavior of the --- : description. It is permissible to add comments and/or --- : attributes to the package declarations, but not to change --- : or delete any original lines of the package declaration. --- : The package body may be changed only in accordance with --- : the terms of Clause 16 of this standard. --- : --- -------------------------------------------------------------------- --- $Revision: 1220 $ --- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ --- -------------------------------------------------------------------- - -library ieee; -use ieee.numeric_bit.all; - -package body NUMERIC_BIT_UNSIGNED is - - -- Id: A.3 - function "+" (L, R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) + UNSIGNED(R)); - end function "+"; - - -- Id: A.3R - function "+"(L : BIT_VECTOR; R : BIT) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) + R); - end function "+"; - - -- Id: A.3L - function "+"(L : BIT; R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (L + UNSIGNED(R)); - end function "+"; - - -- Id: A.5 - function "+" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) + R); - end function "+"; - - -- Id: A.6 - function "+" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (L + UNSIGNED(R)); - end function "+"; - - --============================================================================ - - -- Id: A.9 - function "-" (L, R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) - UNSIGNED(R)); - end function "-"; - - -- Id: A.9R - function "-"(L : BIT_VECTOR; R : BIT) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) - R); - end function "-"; - - -- Id: A.9L - function "-"(L : BIT; R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (L - UNSIGNED(R)); - end function "-"; - - -- Id: A.11 - function "-" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) - R); - end function "-"; - - -- Id: A.12 - function "-" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (L - UNSIGNED(R)); - end function "-"; - - --============================================================================ - - -- Id: A.15 - function "*" (L, R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) * UNSIGNED(R)); - end function "*"; - - -- Id: A.17 - function "*" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) * R); - end function "*"; - - -- Id: A.18 - function "*" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (L * UNSIGNED(R)); - end function "*"; - - --============================================================================ - - -- Id: A.21 - function "/" (L, R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) / UNSIGNED(R)); - end function "/"; - - -- Id: A.23 - function "/" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) / R); - end function "/"; - - -- Id: A.24 - function "/" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (L / UNSIGNED(R)); - end function "/"; - - --============================================================================ - - -- Id: A.27 - function "rem" (L, R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) rem UNSIGNED(R)); - end function "rem"; - - -- Id: A.29 - function "rem" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) rem R); - end function "rem"; - - -- Id: A.30 - function "rem" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (L rem UNSIGNED(R)); - end function "rem"; - - --============================================================================ - - -- Id: A.33 - function "mod" (L, R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) mod UNSIGNED(R)); - end function "mod"; - - -- Id: A.35 - function "mod" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(L) mod R); - end function "mod"; - - -- Id: A.36 - function "mod" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (L mod UNSIGNED(R)); - end function "mod"; - - --============================================================================ - -- Id: A.39 - function find_leftmost (ARG: BIT_VECTOR; Y: BIT) return INTEGER is - begin - return find_leftmost(UNSIGNED(ARG), Y); - end function find_leftmost; - - -- Id: A.41 - function find_rightmost (ARG: BIT_VECTOR; Y: BIT) return INTEGER is - begin - return find_rightmost(UNSIGNED(ARG), Y); - end function find_rightmost; - - --============================================================================ - -- Id: C.1 - function ">" (L, R : BIT_VECTOR) return BOOLEAN is - begin - return UNSIGNED(L) > UNSIGNED(R); - end function ">"; - - -- Id: C.3 - function ">" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN is - begin - return L > UNSIGNED(R); - end function ">"; - - -- Id: C.5 - function ">" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN is - begin - return UNSIGNED(L) > R; - end function ">"; - - --============================================================================ - -- Id: C.7 - function "<" (L, R : BIT_VECTOR) return BOOLEAN is - begin - return UNSIGNED(L) < UNSIGNED(R); - end function "<"; - - -- Id: C.9 - function "<" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN is - begin - return L < UNSIGNED(R); - end function "<"; - - -- Id: C.11 - function "<" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN is - begin - return UNSIGNED(L) < R; - end function "<"; - - --============================================================================ - -- Id: C.13 - function "<=" (L, R : BIT_VECTOR) return BOOLEAN is - begin - return UNSIGNED(L) <= UNSIGNED(R); - end function "<="; - - -- Id: C.15 - function "<=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN is - begin - return L <= UNSIGNED(R); - end function "<="; - - -- Id: C.17 - function "<=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN is - begin - return UNSIGNED(L) <= R; - end function "<="; - - --============================================================================ - -- Id: C.19 - function ">=" (L, R : BIT_VECTOR) return BOOLEAN is - begin - return UNSIGNED(L) >= UNSIGNED(R); - end function ">="; - - -- Id: C.21 - function ">=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN is - begin - return L >= UNSIGNED(R); - end function ">="; - - -- Id: C.23 - function ">=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN is - begin - return UNSIGNED(L) >= R; - end function ">="; - - --============================================================================ - -- Id: C.25 - function "=" (L, R : BIT_VECTOR) return BOOLEAN is - begin - return UNSIGNED(L) = UNSIGNED(R); - end function "="; - - -- Id: C.27 - function "=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN is - begin - return L = UNSIGNED(R); - end function "="; - - -- Id: C.29 - function "=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN is - begin - return UNSIGNED(L) = R; - end function "="; - - --============================================================================ - -- Id: C.31 - function "/=" (L, R : BIT_VECTOR) return BOOLEAN is - begin - return UNSIGNED(L) /= UNSIGNED(R); - end function "/="; - - -- Id: C.33 - function "/=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN is - begin - return L /= UNSIGNED(R); - end function "/="; - - -- Id: C.35 - function "/=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN is - begin - return UNSIGNED(L) /= R; - end function "/="; - - --============================================================================ - -- Id: C.37 - function MINIMUM (L, R: BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (MINIMUM(UNSIGNED(L), UNSIGNED(R))); - end function MINIMUM; - - -- Id: C.39 - function MINIMUM (L: NATURAL; R: BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (MINIMUM(L, UNSIGNED(R))); - end function MINIMUM; - - -- Id: C.41 - function MINIMUM (L: BIT_VECTOR; R: NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (MINIMUM(UNSIGNED(L), R)); - end function MINIMUM; - - --============================================================================ - -- Id: C.43 - function MAXIMUM (L, R: BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (MAXIMUM(UNSIGNED(L), UNSIGNED(R))); - end function MAXIMUM; - - -- Id: C.45 - function MAXIMUM (L: NATURAL; R: BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR (MAXIMUM(L, UNSIGNED(R))); - end function MAXIMUM; - - -- Id: C.47 - function MAXIMUM (L: BIT_VECTOR; R: NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (MAXIMUM(UNSIGNED(L), R)); - end function MAXIMUM; - - --============================================================================ - - -- Id: C.49 - function "?>" (L, R: BIT_VECTOR) return BIT is - begin - return UNSIGNED(L) ?> UNSIGNED(R); - end function "?>"; - - -- Id: C.51 - function "?>" (L: NATURAL; R: BIT_VECTOR) return BIT is - begin - return L ?> UNSIGNED(R); - end function "?>"; - - -- Id: C.53 - function "?>" (L: BIT_VECTOR; R: NATURAL) return BIT is - begin - return UNSIGNED(L) ?> R; - end function "?>"; - - --============================================================================ - - -- Id: C.55 - function "?<" (L, R: BIT_VECTOR) return BIT is - begin - return UNSIGNED(L) ?< UNSIGNED(R); - end function "?<"; - - -- Id: C.57 - function "?<" (L: NATURAL; R: BIT_VECTOR) return BIT is - begin - return L ?< UNSIGNED(R); - end function "?<"; - - -- Id: C.59 - function "?<" (L: BIT_VECTOR; R: NATURAL) return BIT is - begin - return UNSIGNED(L) ?< R; - end function "?<"; - - --============================================================================ - - -- Id: C.61 - function "?<=" (L, R: BIT_VECTOR) return BIT is - begin - return UNSIGNED(L) ?<= UNSIGNED(R); - end function "?<="; - - -- Id: C.63 - function "?<=" (L: NATURAL; R: BIT_VECTOR) return BIT is - begin - return L ?<= UNSIGNED(R); - end function "?<="; - - -- Id: C.65 - function "?<=" (L: BIT_VECTOR; R: NATURAL) return BIT is - begin - return UNSIGNED(L) ?<= R; - end function "?<="; - - --============================================================================ - - -- Id: C.67 - function "?>=" (L, R: BIT_VECTOR) return BIT is - begin - return UNSIGNED(L) ?>= UNSIGNED(R); - end function "?>="; - - -- Id: C.69 - function "?>=" (L: NATURAL; R: BIT_VECTOR) return BIT is - begin - return L ?>= UNSIGNED(R); - end function "?>="; - - -- Id: C.71 - function "?>=" (L: BIT_VECTOR; R: NATURAL) return BIT is - begin - return UNSIGNED(L) ?>= R; - end function "?>="; - - --============================================================================ - - -- Id: C.73 - function "?=" (L, R: BIT_VECTOR) return BIT is - begin - return UNSIGNED(L) ?= UNSIGNED(R); - end function "?="; - - -- Id: C.75 - function "?=" (L: NATURAL; R: BIT_VECTOR) return BIT is - begin - return L ?= UNSIGNED(R); - end function "?="; - - -- Id: C.77 - function "?=" (L: BIT_VECTOR; R: NATURAL) return BIT is - begin - return UNSIGNED(L) ?= R; - end function "?="; - - --============================================================================ - - -- Id: C.79 - function "?/=" (L, R: BIT_VECTOR) return BIT is - begin - return UNSIGNED(L) ?/= UNSIGNED(R); - end function "?/="; - - -- Id: C.81 - function "?/=" (L: NATURAL; R: BIT_VECTOR) return BIT is - begin - return L ?/= UNSIGNED(R); - end function "?/="; - - -- Id: C.83 - function "?/=" (L: BIT_VECTOR; R: NATURAL) return BIT is - begin - return UNSIGNED(L) ?/= R; - end function "?/="; - - --============================================================================ - - -- Id: S.1 - function SHIFT_LEFT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (shift_left (ARG => UNSIGNED(ARG), - COUNT => COUNT)); - end function SHIFT_LEFT; - - -- Id: S.2 - function SHIFT_RIGHT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (shift_right (ARG => UNSIGNED(ARG), - COUNT => COUNT)); - end function SHIFT_RIGHT; - - --============================================================================ - - -- Id: S.5 - function ROTATE_LEFT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (rotate_left (ARG => UNSIGNED(ARG), - COUNT => COUNT)); - end function ROTATE_LEFT; - - -- Id: S.6 - function ROTATE_RIGHT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (rotate_right (ARG => UNSIGNED(ARG), - COUNT => COUNT)); - end function ROTATE_RIGHT; - - --============================================================================ - - -- Id: S.9 - function "sll" (ARG: BIT_VECTOR; COUNT: INTEGER) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(ARG) sll COUNT); - end function "sll"; - - -- Id: S.11 - function "srl" (ARG: BIT_VECTOR; COUNT: INTEGER) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(ARG) srl COUNT); - end function "srl"; - - -- Id: S.13 - function "rol" (ARG: BIT_VECTOR; COUNT: INTEGER) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(ARG) rol COUNT); - end function "rol"; - - -- Id: S.15 - function "ror" (ARG: BIT_VECTOR; COUNT: INTEGER) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(ARG) ror COUNT); - end function "ror"; - - -- Id: S.17 - function "sla" (ARG: BIT_VECTOR; COUNT: INTEGER) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(ARG) sla COUNT); - end function "sla"; - - -- Id: S.19 - function "sra" (ARG: BIT_VECTOR; COUNT: INTEGER) return BIT_VECTOR is - begin - return BIT_VECTOR (UNSIGNED(ARG) sra COUNT); - end function "sra"; - - --============================================================================ - - -- Id: R.2 - function RESIZE (ARG : BIT_VECTOR; NEW_SIZE : NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR ( - resize (arg => UNSIGNED(ARG), - NEW_SIZE => NEW_SIZE)); - end function RESIZE; - - function RESIZE (ARG, SIZE_RES : BIT_VECTOR) return BIT_VECTOR is - begin - return BIT_VECTOR ( - RESIZE (ARG => UNSIGNED(ARG), - NEW_SIZE => SIZE_RES'length)); - end function RESIZE; - - --============================================================================ - - -- Id: D.1 - function TO_INTEGER (ARG : BIT_VECTOR) return NATURAL is - begin - return TO_INTEGER (UNSIGNED(ARG)); - end function TO_INTEGER; - - -- Id: D.3 - function To_BitVector (ARG, SIZE : NATURAL) return BIT_VECTOR is - begin - return BIT_VECTOR (TO_UNSIGNED(ARG, SIZE)); - end function To_BitVector; - - function To_BitVector (ARG : NATURAL; SIZE_RES : BIT_VECTOR) - return BIT_VECTOR is - begin - return BIT_VECTOR (TO_UNSIGNED(ARG, SIZE_RES'length)); - end function To_BitVector; - -end package body NUMERIC_BIT_UNSIGNED; +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. +-- +-- Title : Standard VHDL Synthesis Packages +-- : (NUMERIC_BIT_UNSIGNED package body) +-- : +-- Library : This package shall be compiled into a library +-- : symbolically named IEEE. +-- : +-- Developers: Accellera VHDL-TC, and IEEE P1076 Working Group +-- : +-- Purpose : This package defines numeric types and arithmetic functions +-- : for use with synthesis tools. Values of type BIT_VECTOR +-- : are interpreted as unsigned numbers in vector form. +-- : The leftmost bit is treated as the most significant bit. +-- : This package contains overloaded arithmetic operators on +-- : the BIT_VECTOR type. The package also contains +-- : useful type conversions functions, clock detection +-- : functions, and other utility functions. +-- : +-- : If any argument to a function is a null array, a null array +-- : is returned (exceptions, if any, are noted individually). +-- +-- Note : This package may be modified to include additional data +-- : required by tools, but it must in no way change the +-- : external interfaces or simulation behavior of the +-- : description. It is permissible to add comments and/or +-- : attributes to the package declarations, but not to change +-- : or delete any original lines of the package declaration. +-- : The package body may be changed only in accordance with +-- : the terms of Clause 16 of this standard. +-- : +-- -------------------------------------------------------------------- +-- $Revision: 1220 $ +-- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ +-- -------------------------------------------------------------------- + +library ieee; +use ieee.numeric_bit.all; + +package body NUMERIC_BIT_UNSIGNED is + + -- Id: A.3 + function "+" (L, R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) + UNSIGNED(R)); + end function "+"; + + -- Id: A.3R + function "+"(L : BIT_VECTOR; R : BIT) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) + R); + end function "+"; + + -- Id: A.3L + function "+"(L : BIT; R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (L + UNSIGNED(R)); + end function "+"; + + -- Id: A.5 + function "+" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) + R); + end function "+"; + + -- Id: A.6 + function "+" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (L + UNSIGNED(R)); + end function "+"; + + --============================================================================ + + -- Id: A.9 + function "-" (L, R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) - UNSIGNED(R)); + end function "-"; + + -- Id: A.9R + function "-"(L : BIT_VECTOR; R : BIT) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) - R); + end function "-"; + + -- Id: A.9L + function "-"(L : BIT; R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (L - UNSIGNED(R)); + end function "-"; + + -- Id: A.11 + function "-" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) - R); + end function "-"; + + -- Id: A.12 + function "-" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (L - UNSIGNED(R)); + end function "-"; + + --============================================================================ + + -- Id: A.15 + function "*" (L, R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) * UNSIGNED(R)); + end function "*"; + + -- Id: A.17 + function "*" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) * R); + end function "*"; + + -- Id: A.18 + function "*" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (L * UNSIGNED(R)); + end function "*"; + + --============================================================================ + + -- Id: A.21 + function "/" (L, R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) / UNSIGNED(R)); + end function "/"; + + -- Id: A.23 + function "/" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) / R); + end function "/"; + + -- Id: A.24 + function "/" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (L / UNSIGNED(R)); + end function "/"; + + --============================================================================ + + -- Id: A.27 + function "rem" (L, R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) rem UNSIGNED(R)); + end function "rem"; + + -- Id: A.29 + function "rem" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) rem R); + end function "rem"; + + -- Id: A.30 + function "rem" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (L rem UNSIGNED(R)); + end function "rem"; + + --============================================================================ + + -- Id: A.33 + function "mod" (L, R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) mod UNSIGNED(R)); + end function "mod"; + + -- Id: A.35 + function "mod" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(L) mod R); + end function "mod"; + + -- Id: A.36 + function "mod" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (L mod UNSIGNED(R)); + end function "mod"; + + --============================================================================ + -- Id: A.39 + function find_leftmost (ARG: BIT_VECTOR; Y: BIT) return INTEGER is + begin + return find_leftmost(UNSIGNED(ARG), Y); + end function find_leftmost; + + -- Id: A.41 + function find_rightmost (ARG: BIT_VECTOR; Y: BIT) return INTEGER is + begin + return find_rightmost(UNSIGNED(ARG), Y); + end function find_rightmost; + + --============================================================================ + -- Id: C.1 + function ">" (L, R : BIT_VECTOR) return BOOLEAN is + begin + return UNSIGNED(L) > UNSIGNED(R); + end function ">"; + + -- Id: C.3 + function ">" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN is + begin + return L > UNSIGNED(R); + end function ">"; + + -- Id: C.5 + function ">" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN is + begin + return UNSIGNED(L) > R; + end function ">"; + + --============================================================================ + -- Id: C.7 + function "<" (L, R : BIT_VECTOR) return BOOLEAN is + begin + return UNSIGNED(L) < UNSIGNED(R); + end function "<"; + + -- Id: C.9 + function "<" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN is + begin + return L < UNSIGNED(R); + end function "<"; + + -- Id: C.11 + function "<" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN is + begin + return UNSIGNED(L) < R; + end function "<"; + + --============================================================================ + -- Id: C.13 + function "<=" (L, R : BIT_VECTOR) return BOOLEAN is + begin + return UNSIGNED(L) <= UNSIGNED(R); + end function "<="; + + -- Id: C.15 + function "<=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN is + begin + return L <= UNSIGNED(R); + end function "<="; + + -- Id: C.17 + function "<=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN is + begin + return UNSIGNED(L) <= R; + end function "<="; + + --============================================================================ + -- Id: C.19 + function ">=" (L, R : BIT_VECTOR) return BOOLEAN is + begin + return UNSIGNED(L) >= UNSIGNED(R); + end function ">="; + + -- Id: C.21 + function ">=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN is + begin + return L >= UNSIGNED(R); + end function ">="; + + -- Id: C.23 + function ">=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN is + begin + return UNSIGNED(L) >= R; + end function ">="; + + --============================================================================ + -- Id: C.25 + function "=" (L, R : BIT_VECTOR) return BOOLEAN is + begin + return UNSIGNED(L) = UNSIGNED(R); + end function "="; + + -- Id: C.27 + function "=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN is + begin + return L = UNSIGNED(R); + end function "="; + + -- Id: C.29 + function "=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN is + begin + return UNSIGNED(L) = R; + end function "="; + + --============================================================================ + -- Id: C.31 + function "/=" (L, R : BIT_VECTOR) return BOOLEAN is + begin + return UNSIGNED(L) /= UNSIGNED(R); + end function "/="; + + -- Id: C.33 + function "/=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN is + begin + return L /= UNSIGNED(R); + end function "/="; + + -- Id: C.35 + function "/=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN is + begin + return UNSIGNED(L) /= R; + end function "/="; + + --============================================================================ + -- Id: C.37 + function MINIMUM (L, R: BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (MINIMUM(UNSIGNED(L), UNSIGNED(R))); + end function MINIMUM; + + -- Id: C.39 + function MINIMUM (L: NATURAL; R: BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (MINIMUM(L, UNSIGNED(R))); + end function MINIMUM; + + -- Id: C.41 + function MINIMUM (L: BIT_VECTOR; R: NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (MINIMUM(UNSIGNED(L), R)); + end function MINIMUM; + + --============================================================================ + -- Id: C.43 + function MAXIMUM (L, R: BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (MAXIMUM(UNSIGNED(L), UNSIGNED(R))); + end function MAXIMUM; + + -- Id: C.45 + function MAXIMUM (L: NATURAL; R: BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR (MAXIMUM(L, UNSIGNED(R))); + end function MAXIMUM; + + -- Id: C.47 + function MAXIMUM (L: BIT_VECTOR; R: NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (MAXIMUM(UNSIGNED(L), R)); + end function MAXIMUM; + + --============================================================================ + + -- Id: C.49 + function "?>" (L, R: BIT_VECTOR) return BIT is + begin + return UNSIGNED(L) ?> UNSIGNED(R); + end function "?>"; + + -- Id: C.51 + function "?>" (L: NATURAL; R: BIT_VECTOR) return BIT is + begin + return L ?> UNSIGNED(R); + end function "?>"; + + -- Id: C.53 + function "?>" (L: BIT_VECTOR; R: NATURAL) return BIT is + begin + return UNSIGNED(L) ?> R; + end function "?>"; + + --============================================================================ + + -- Id: C.55 + function "?<" (L, R: BIT_VECTOR) return BIT is + begin + return UNSIGNED(L) ?< UNSIGNED(R); + end function "?<"; + + -- Id: C.57 + function "?<" (L: NATURAL; R: BIT_VECTOR) return BIT is + begin + return L ?< UNSIGNED(R); + end function "?<"; + + -- Id: C.59 + function "?<" (L: BIT_VECTOR; R: NATURAL) return BIT is + begin + return UNSIGNED(L) ?< R; + end function "?<"; + + --============================================================================ + + -- Id: C.61 + function "?<=" (L, R: BIT_VECTOR) return BIT is + begin + return UNSIGNED(L) ?<= UNSIGNED(R); + end function "?<="; + + -- Id: C.63 + function "?<=" (L: NATURAL; R: BIT_VECTOR) return BIT is + begin + return L ?<= UNSIGNED(R); + end function "?<="; + + -- Id: C.65 + function "?<=" (L: BIT_VECTOR; R: NATURAL) return BIT is + begin + return UNSIGNED(L) ?<= R; + end function "?<="; + + --============================================================================ + + -- Id: C.67 + function "?>=" (L, R: BIT_VECTOR) return BIT is + begin + return UNSIGNED(L) ?>= UNSIGNED(R); + end function "?>="; + + -- Id: C.69 + function "?>=" (L: NATURAL; R: BIT_VECTOR) return BIT is + begin + return L ?>= UNSIGNED(R); + end function "?>="; + + -- Id: C.71 + function "?>=" (L: BIT_VECTOR; R: NATURAL) return BIT is + begin + return UNSIGNED(L) ?>= R; + end function "?>="; + + --============================================================================ + + -- Id: C.73 + function "?=" (L, R: BIT_VECTOR) return BIT is + begin + return UNSIGNED(L) ?= UNSIGNED(R); + end function "?="; + + -- Id: C.75 + function "?=" (L: NATURAL; R: BIT_VECTOR) return BIT is + begin + return L ?= UNSIGNED(R); + end function "?="; + + -- Id: C.77 + function "?=" (L: BIT_VECTOR; R: NATURAL) return BIT is + begin + return UNSIGNED(L) ?= R; + end function "?="; + + --============================================================================ + + -- Id: C.79 + function "?/=" (L, R: BIT_VECTOR) return BIT is + begin + return UNSIGNED(L) ?/= UNSIGNED(R); + end function "?/="; + + -- Id: C.81 + function "?/=" (L: NATURAL; R: BIT_VECTOR) return BIT is + begin + return L ?/= UNSIGNED(R); + end function "?/="; + + -- Id: C.83 + function "?/=" (L: BIT_VECTOR; R: NATURAL) return BIT is + begin + return UNSIGNED(L) ?/= R; + end function "?/="; + + --============================================================================ + + -- Id: S.1 + function SHIFT_LEFT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (shift_left (ARG => UNSIGNED(ARG), + COUNT => COUNT)); + end function SHIFT_LEFT; + + -- Id: S.2 + function SHIFT_RIGHT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (shift_right (ARG => UNSIGNED(ARG), + COUNT => COUNT)); + end function SHIFT_RIGHT; + + --============================================================================ + + -- Id: S.5 + function ROTATE_LEFT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (rotate_left (ARG => UNSIGNED(ARG), + COUNT => COUNT)); + end function ROTATE_LEFT; + + -- Id: S.6 + function ROTATE_RIGHT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (rotate_right (ARG => UNSIGNED(ARG), + COUNT => COUNT)); + end function ROTATE_RIGHT; + + --============================================================================ + + -- Id: S.9 + function "sll" (ARG: BIT_VECTOR; COUNT: INTEGER) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(ARG) sll COUNT); + end function "sll"; + + -- Id: S.11 + function "srl" (ARG: BIT_VECTOR; COUNT: INTEGER) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(ARG) srl COUNT); + end function "srl"; + + -- Id: S.13 + function "rol" (ARG: BIT_VECTOR; COUNT: INTEGER) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(ARG) rol COUNT); + end function "rol"; + + -- Id: S.15 + function "ror" (ARG: BIT_VECTOR; COUNT: INTEGER) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(ARG) ror COUNT); + end function "ror"; + + -- Id: S.17 + function "sla" (ARG: BIT_VECTOR; COUNT: INTEGER) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(ARG) sla COUNT); + end function "sla"; + + -- Id: S.19 + function "sra" (ARG: BIT_VECTOR; COUNT: INTEGER) return BIT_VECTOR is + begin + return BIT_VECTOR (UNSIGNED(ARG) sra COUNT); + end function "sra"; + + --============================================================================ + + -- Id: R.2 + function RESIZE (ARG : BIT_VECTOR; NEW_SIZE : NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR ( + resize (arg => UNSIGNED(ARG), + NEW_SIZE => NEW_SIZE)); + end function RESIZE; + + function RESIZE (ARG, SIZE_RES : BIT_VECTOR) return BIT_VECTOR is + begin + return BIT_VECTOR ( + RESIZE (ARG => UNSIGNED(ARG), + NEW_SIZE => SIZE_RES'length)); + end function RESIZE; + + --============================================================================ + + -- Id: D.1 + function TO_INTEGER (ARG : BIT_VECTOR) return NATURAL is + begin + return TO_INTEGER (UNSIGNED(ARG)); + end function TO_INTEGER; + + -- Id: D.3 + function To_BitVector (ARG, SIZE : NATURAL) return BIT_VECTOR is + begin + return BIT_VECTOR (TO_UNSIGNED(ARG, SIZE)); + end function To_BitVector; + + function To_BitVector (ARG : NATURAL; SIZE_RES : BIT_VECTOR) + return BIT_VECTOR is + begin + return BIT_VECTOR (TO_UNSIGNED(ARG, SIZE_RES'length)); + end function To_BitVector; + +end package body NUMERIC_BIT_UNSIGNED; diff --git a/libraries/ieee2008/numeric_bit_unsigned.vhdl b/libraries/ieee2008/numeric_bit_unsigned.vhdl index 1d76ed477..71188cb4b 100644 --- a/libraries/ieee2008/numeric_bit_unsigned.vhdl +++ b/libraries/ieee2008/numeric_bit_unsigned.vhdl @@ -1,620 +1,623 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. --- --- Title : Standard VHDL Synthesis Packages --- : (NUMERIC_BIT_UNSIGNED package declaration) --- : --- Library : This package shall be compiled into a library --- : symbolically named IEEE. --- : --- Developers: Accellera VHDL-TC, and IEEE P1076 Working Group --- : --- Purpose : This package defines numeric types and arithmetic functions --- : for use with synthesis tools. Values of type BIT_VECTOR --- : are interpreted as unsigned numbers in vector form. --- : The leftmost bit is treated as the most significant bit. --- : This package contains overloaded arithmetic operators on --- : the BIT_VECTOR type. The package also contains --- : useful type conversions functions, clock detection --- : functions, and other utility functions. --- : --- : If any argument to a function is a null array, a null array --- : is returned (exceptions, if any, are noted individually). --- --- Note : This package may be modified to include additional data --- : required by tools, but it must in no way change the --- : external interfaces or simulation behavior of the --- : description. It is permissible to add comments and/or --- : attributes to the package declarations, but not to change --- : or delete any original lines of the package declaration. --- : The package body may be changed only in accordance with --- : the terms of Clause 16 of this standard. --- : --- -------------------------------------------------------------------- --- $Revision: 1220 $ --- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ --- -------------------------------------------------------------------- - -package NUMERIC_BIT_UNSIGNED is - constant CopyRightNotice : STRING := - "Copyright 2008 IEEE. All rights reserved."; - - -- Id: A.3 - function "+" (L, R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector(MAXIMUM(L'LENGTH, R'LENGTH)-1 downto 0). - -- Result: Adds two UNSIGNED vectors that may be of different lengths. - - -- Id: A.3R - function "+"(L : BIT_VECTOR; R : BIT) return BIT_VECTOR; - -- Result subtype: bit_vector(L'LENGTH-1 downto 0) - -- Result: Similar to A.3 where R is a one bit bit_vector - - -- Id: A.3L - function "+"(L : BIT; R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector(R'LENGTH-1 downto 0) - -- Result: Similar to A.3 where L is a one bit UNSIGNED - - -- Id: A.5 - function "+" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; - -- Result subtype: bit_vector(L'LENGTH-1 downto 0). - -- Result: Adds an UNSIGNED vector, L, with a non-negative INTEGER, R. - - -- Id: A.6 - function "+" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector(R'LENGTH-1 downto 0). - -- Result: Adds a non-negative INTEGER, L, with an UNSIGNED vector, R. - - --============================================================================ - - -- Id: A.9 - function "-" (L, R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: UNSIGNED(MAXIMUM(L'LENGTH, R'LENGTH)-1 downto 0). - -- Result: Subtracts two UNSIGNED vectors that may be of different lengths. - - -- Id: A.9R - function "-"(L : BIT_VECTOR; R : BIT) return BIT_VECTOR; - -- Result subtype: bit_vector(L'LENGTH-1 downto 0) - -- Result: Similar to A.9 where R is a one bit UNSIGNED - - -- Id: A.9L - function "-"(L : BIT; R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector(R'LENGTH-1 downto 0) - -- Result: Similar to A.9 where L is a one bit UNSIGNED - - -- Id: A.11 - function "-" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; - -- Result subtype: bit_vector(L'LENGTH-1 downto 0). - -- Result: Subtracts a non-negative INTEGER, R, from an UNSIGNED vector, L. - - -- Id: A.12 - function "-" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector(R'LENGTH-1 downto 0). - -- Result: Subtracts an UNSIGNED vector, R, from a non-negative INTEGER, L. - - --============================================================================ - - -- Id: A.15 - function "*" (L, R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector((L'LENGTH+R'LENGTH-1) downto 0). - -- Result: Performs the multiplication operation on two UNSIGNED vectors - -- that may possibly be of different lengths. - - -- Id: A.17 - function "*" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; - -- Result subtype: bit_vector((L'LENGTH+L'LENGTH-1) downto 0). - -- Result: Multiplies an UNSIGNED vector, L, with a non-negative - -- INTEGER, R. R is converted to an UNSIGNED vector of - -- SIZE L'LENGTH before multiplication. - - -- Id: A.18 - function "*" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector((R'LENGTH+R'LENGTH-1) downto 0). - -- Result: Multiplies an UNSIGNED vector, R, with a non-negative - -- INTEGER, L. L is converted to an UNSIGNED vector of - -- SIZE R'LENGTH before multiplication. - - --============================================================================ - -- - -- NOTE: If second argument is zero for "/" operator, a severity level - -- of ERROR is issued. - - -- Id: A.21 - function "/" (L, R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector(L'LENGTH-1 downto 0) - -- Result: Divides an UNSIGNED vector, L, by another UNSIGNED vector, R. - - -- Id: A.23 - function "/" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; - -- Result subtype: bit_vector(L'LENGTH-1 downto 0) - -- Result: Divides an UNSIGNED vector, L, by a non-negative INTEGER, R. - -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. - - -- Id: A.24 - function "/" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector(R'LENGTH-1 downto 0) - -- Result: Divides a non-negative INTEGER, L, by an UNSIGNED vector, R. - -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. - - --============================================================================ - -- - -- NOTE: If second argument is zero for "rem" operator, a severity level - -- of ERROR is issued. - - -- Id: A.27 - function "rem" (L, R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector(R'LENGTH-1 downto 0) - -- Result: Computes "L rem R" where L and R are UNSIGNED vectors. - - -- Id: A.29 - function "rem" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; - -- Result subtype: bit_vector(L'LENGTH-1 downto 0) - -- Result: Computes "L rem R" where L is an UNSIGNED vector and R is a - -- non-negative INTEGER. - -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. - - -- Id: A.30 - function "rem" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector(R'LENGTH-1 downto 0) - -- Result: Computes "L rem R" where R is an UNSIGNED vector and L is a - -- non-negative INTEGER. - -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. - - --============================================================================ - -- - -- NOTE: If second argument is zero for "mod" operator, a severity level - -- of ERROR is issued. - - -- Id: A.33 - function "mod" (L, R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector(R'LENGTH-1 downto 0) - -- Result: Computes "L mod R" where L and R are UNSIGNED vectors. - - -- Id: A.35 - function "mod" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; - -- Result subtype: bit_vector(L'LENGTH-1 downto 0) - -- Result: Computes "L mod R" where L is an UNSIGNED vector and R - -- is a non-negative INTEGER. - -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. - - -- Id: A.36 - function "mod" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: bit_vector(R'LENGTH-1 downto 0) - -- Result: Computes "L mod R" where R is an UNSIGNED vector and L - -- is a non-negative INTEGER. - -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. - - --============================================================================ - -- Id: A.39 - function find_leftmost (ARG : BIT_VECTOR; Y : BIT) return INTEGER; - -- Result subtype: INTEGER - -- Result: Finds the leftmost occurrence of the value of Y in ARG. - -- Returns the index of the occurrence if it exists, or -1 otherwise. - - -- Id: A.41 - function find_rightmost (ARG : BIT_VECTOR; Y : BIT) return INTEGER; - -- Result subtype: INTEGER - -- Result: Finds the leftmost occurrence of the value of Y in ARG. - -- Returns the index of the occurrence if it exists, or -1 otherwise. - - --============================================================================ - -- Comparison Operators - --============================================================================ - -- Id: C.1 - function ">" (L, R : BIT_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L > R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.3 - function ">" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L > R" where L is a non-negative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.5 - function ">" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L > R" where L is an UNSIGNED vector and - -- R is a non-negative INTEGER. - - --============================================================================ - -- Id: C.7 - function "<" (L, R : BIT_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L < R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.9 - function "<" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L < R" where L is a non-negative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.11 - function "<" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L < R" where L is an UNSIGNED vector and - -- R is a non-negative INTEGER. - - --============================================================================ - -- Id: C.13 - function "<=" (L, R : BIT_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L <= R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.15 - function "<=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L <= R" where L is a non-negative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.17 - function "<=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L <= R" where L is an UNSIGNED vector and - -- R is a non-negative INTEGER. - - --============================================================================ - -- Id: C.19 - function ">=" (L, R : BIT_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L >= R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.21 - function ">=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L >= R" where L is a non-negative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.23 - function ">=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L >= R" where L is an UNSIGNED vector and - -- R is a non-negative INTEGER. - - --============================================================================ - -- Id: C.25 - function "=" (L, R : BIT_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L = R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.27 - function "=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L = R" where L is a non-negative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.29 - function "=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L = R" where L is an UNSIGNED vector and - -- R is a non-negative INTEGER. - - --============================================================================ - - -- Id: C.31 - function "/=" (L, R : BIT_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L /= R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.33 - function "/=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L /= R" where L is a non-negative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.35 - function "/=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L /= R" where L is an UNSIGNED vector and - -- R is a non-negative INTEGER. - - --============================================================================ - - -- Id: C.37 - function MINIMUM (L, R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR - -- Result: Returns the lesser of two UNSIGNED vectors that may be - -- of different lengths. - - -- Id: C.39 - function MINIMUM (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR - -- Result: Returns the lesser of a nonnegative INTEGER, L, and - -- an UNSIGNED vector, R. - - -- Id: C.41 - function MINIMUM (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR - -- Result: Returns the lesser of an UNSIGNED vector, L, and - -- a nonnegative INTEGER, R. - - --============================================================================ - - -- Id: C.43 - function MAXIMUM (L, R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR - -- Result: Returns the greater of two UNSIGNED vectors that may be - -- of different lengths. - - -- Id: C.45 - function MAXIMUM (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR - -- Result: Returns the greater of a nonnegative INTEGER, L, and - -- an UNSIGNED vector, R. - - -- Id: C.47 - function MAXIMUM (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR - -- Result: Returns the greater of an UNSIGNED vector, L, and - -- a nonnegative INTEGER, R. - - --============================================================================ - -- Id: C.49 - function "?>" (L, R : BIT_VECTOR) return BIT; - -- Result subtype: BIT - -- Result: Computes "L > R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.51 - function "?>" (L : NATURAL; R : BIT_VECTOR) return BIT; - -- Result subtype: BIT - -- Result: Computes "L > R" where L is a nonnegative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.53 - function "?>" (L : BIT_VECTOR; R : NATURAL) return BIT; - -- Result subtype: BIT - -- Result: Computes "L > R" where L is an UNSIGNED vector and - -- R is a nonnegative INTEGER. - - --============================================================================ - - -- Id: C.55 - function "?<" (L, R : BIT_VECTOR) return BIT; - -- Result subtype: BIT - -- Result: Computes "L < R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.57 - function "?<" (L : NATURAL; R : BIT_VECTOR) return BIT; - -- Result subtype: BIT - -- Result: Computes "L < R" where L is a nonnegative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.59 - function "?<" (L : BIT_VECTOR; R : NATURAL) return BIT; - -- Result subtype: BIT - -- Result: Computes "L < R" where L is an UNSIGNED vector and - -- R is a nonnegative INTEGER. - - --============================================================================ - - -- Id: C.61 - function "?<=" (L, R : BIT_VECTOR) return BIT; - -- Result subtype: BIT - -- Result: Computes "L <= R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.63 - function "?<=" (L : NATURAL; R : BIT_VECTOR) return BIT; - -- Result subtype: BIT - -- Result: Computes "L <= R" where L is a nonnegative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.65 - function "?<=" (L : BIT_VECTOR; R : NATURAL) return BIT; - -- Result subtype: BIT - -- Result: Computes "L <= R" where L is an UNSIGNED vector and - -- R is a nonnegative INTEGER. - - --============================================================================ - - -- Id: C.67 - function "?>=" (L, R : BIT_VECTOR) return BIT; - -- Result subtype: BIT - -- Result: Computes "L >= R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.69 - function "?>=" (L : NATURAL; R : BIT_VECTOR) return BIT; - -- Result subtype: BIT - -- Result: Computes "L >= R" where L is a nonnegative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.71 - function "?>=" (L : BIT_VECTOR; R : NATURAL) return BIT; - -- Result subtype: BIT - -- Result: Computes "L >= R" where L is an UNSIGNED vector and - -- R is a nonnegative INTEGER. - - --============================================================================ - - -- Id: C.73 - function "?=" (L, R : BIT_VECTOR) return BIT; - -- Result subtype: BIT - -- Result: Computes "L = R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.75 - function "?=" (L : NATURAL; R : BIT_VECTOR) return BIT; - -- Result subtype: BIT - -- Result: Computes "L = R" where L is a nonnegative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.77 - function "?=" (L : BIT_VECTOR; R : NATURAL) return BIT; - -- Result subtype: BIT - -- Result: Computes "L = R" where L is an UNSIGNED vector and - -- R is a nonnegative INTEGER. - - --============================================================================ - - -- Id: C.79 - function "?/=" (L, R : BIT_VECTOR) return BIT; - -- Result subtype: BIT - -- Result: Computes "L /= R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.81 - function "?/=" (L : NATURAL; R : BIT_VECTOR) return BIT; - -- Result subtype: BIT - -- Result: Computes "L /= R" where L is a nonnegative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.83 - function "?/=" (L : BIT_VECTOR; R : NATURAL) return BIT; - -- Result subtype: BIT - -- Result: Computes "L /= R" where L is an UNSIGNED vector and - -- R is a nonnegative INTEGER. - - --============================================================================ - -- Shift and Rotate Functions - --============================================================================ - - -- Id: S.1 - function SHIFT_LEFT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR; - -- Result subtype: bit_vector(ARG'LENGTH-1 downto 0) - -- Result: Performs a shift-left on an UNSIGNED vector COUNT times. - -- The vacated positions are filled with '0'. - -- The COUNT leftmost elements are lost. - - -- Id: S.2 - function SHIFT_RIGHT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR; - -- Result subtype: UNSIGNED(ARG'LENGTH-1 downto 0) - -- Result: Performs a shift-right on an UNSIGNED vector COUNT times. - -- The vacated positions are filled with '0'. - -- The COUNT rightmost elements are lost. - --============================================================================ - - -- Id: S.5 - function ROTATE_LEFT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR; - -- Result subtype: bit_vector(ARG'LENGTH-1 downto 0) - -- Result: Performs a rotate-left of an UNSIGNED vector COUNT times. - - -- Id: S.6 - function ROTATE_RIGHT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR; - -- Result subtype: bit_vector(ARG'LENGTH-1 downto 0) - -- Result: Performs a rotate-right of an UNSIGNED vector COUNT times. - - - --============================================================================ - - ------------------------------------------------------------------------------ - -- Note: Function S.9 is not compatible with IEEE Std 1076-1987. Comment - -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. - ------------------------------------------------------------------------------ - -- Id: S.9 - function "sll" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) - -- Result: SHIFT_LEFT(ARG, COUNT) - - ------------------------------------------------------------------------------ - -- Note: Function S.11 is not compatible with IEEE Std 1076-1987. Comment - -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. - ------------------------------------------------------------------------------ - -- Id: S.11 - function "srl" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) - -- Result: SHIFT_RIGHT(ARG, COUNT) - - ------------------------------------------------------------------------------ - -- Note: Function S.13 is not compatible with IEEE Std 1076-1987. Comment - -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. - ------------------------------------------------------------------------------ - -- Id: S.13 - function "rol" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) - -- Result: ROTATE_LEFT(ARG, COUNT) - - ------------------------------------------------------------------------------ - -- Note: Function S.15 is not compatible with IEEE Std 1076-1987. Comment - -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. - ------------------------------------------------------------------------------ - -- Id: S.15 - function "ror" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) - -- Result: ROTATE_RIGHT(ARG, COUNT) - - ------------------------------------------------------------------------------ - -- Note: Function S.17 is not compatible with IEEE Std 1076-1987. Comment - -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. - ------------------------------------------------------------------------------ - -- Id: S.17 - function "sla" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) - -- Result: SHIFT_LEFT(ARG, COUNT) - - ------------------------------------------------------------------------------ - -- Note: Function S.19 is not compatible with IEEE Std 1076-1987. Comment - -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. - ------------------------------------------------------------------------------ - -- Id: S.19 - function "sra" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) - -- Result: SHIFT_RIGHT(ARG, COUNT) - - - --============================================================================ - -- RESIZE Functions - --============================================================================ - - -- Id: R.2 - function RESIZE (ARG : BIT_VECTOR; NEW_SIZE : NATURAL) return BIT_VECTOR; - -- Result subtype: bit_vector(NEW_SIZE-1 downto 0) - -- Result: Resizes the UNSIGNED vector ARG to the specified size. - -- To create a larger vector, the new [leftmost] bit positions - -- are filled with '0'. When truncating, the leftmost bits - -- are dropped. - - function RESIZE (ARG, SIZE_RES : BIT_VECTOR) return BIT_VECTOR; - -- Result subtype: BIT_VECTOR (SIZE_RES'length-1 downto 0) - - --============================================================================ - -- Conversion Functions - --============================================================================ - - -- Id: D.1 - function TO_INTEGER (ARG : BIT_VECTOR) return NATURAL; - -- Result subtype: NATURAL. Value cannot be negative since parameter is an - -- UNSIGNED vector. - -- Result: Converts the UNSIGNED vector to an INTEGER. - - -- Id: D.3 - function To_BitVector (ARG, SIZE : NATURAL) return BIT_VECTOR; - -- Result subtype: bit_vector(SIZE-1 downto 0) - -- Result: Converts a non-negative INTEGER to an UNSIGNED vector with - -- the specified size. - - function To_BitVector (ARG : NATURAL; SIZE_RES : BIT_VECTOR) - return BIT_VECTOR; - -- Result subtype: STD_LOGIC_VECTOR(SIZE_RES'length-1 downto 0) - --- begin LCS-2006-130 - alias To_Bit_Vector is - To_BitVector[NATURAL, NATURAL return BIT_VECTOR]; - alias To_BV is - To_BitVector[NATURAL, NATURAL return BIT_VECTOR]; - - alias To_Bit_Vector is - To_BitVector[NATURAL, BIT_VECTOR return BIT_VECTOR]; - alias To_BV is - To_BitVector[NATURAL, BIT_VECTOR return BIT_VECTOR]; - -end package NUMERIC_BIT_UNSIGNED; +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. +-- +-- Title : Standard VHDL Synthesis Packages +-- : (NUMERIC_BIT_UNSIGNED package declaration) +-- : +-- Library : This package shall be compiled into a library +-- : symbolically named IEEE. +-- : +-- Developers: Accellera VHDL-TC, and IEEE P1076 Working Group +-- : +-- Purpose : This package defines numeric types and arithmetic functions +-- : for use with synthesis tools. Values of type BIT_VECTOR +-- : are interpreted as unsigned numbers in vector form. +-- : The leftmost bit is treated as the most significant bit. +-- : This package contains overloaded arithmetic operators on +-- : the BIT_VECTOR type. The package also contains +-- : useful type conversions functions, clock detection +-- : functions, and other utility functions. +-- : +-- : If any argument to a function is a null array, a null array +-- : is returned (exceptions, if any, are noted individually). +-- +-- Note : This package may be modified to include additional data +-- : required by tools, but it must in no way change the +-- : external interfaces or simulation behavior of the +-- : description. It is permissible to add comments and/or +-- : attributes to the package declarations, but not to change +-- : or delete any original lines of the package declaration. +-- : The package body may be changed only in accordance with +-- : the terms of Clause 16 of this standard. +-- : +-- -------------------------------------------------------------------- +-- $Revision: 1220 $ +-- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ +-- -------------------------------------------------------------------- + +package NUMERIC_BIT_UNSIGNED is + constant CopyRightNotice : STRING := + "Copyright IEEE P1076 WG. Licensed Apache 2.0"; + + -- Id: A.3 + function "+" (L, R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector(MAXIMUM(L'LENGTH, R'LENGTH)-1 downto 0). + -- Result: Adds two UNSIGNED vectors that may be of different lengths. + + -- Id: A.3R + function "+"(L : BIT_VECTOR; R : BIT) return BIT_VECTOR; + -- Result subtype: bit_vector(L'LENGTH-1 downto 0) + -- Result: Similar to A.3 where R is a one bit bit_vector + + -- Id: A.3L + function "+"(L : BIT; R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector(R'LENGTH-1 downto 0) + -- Result: Similar to A.3 where L is a one bit UNSIGNED + + -- Id: A.5 + function "+" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; + -- Result subtype: bit_vector(L'LENGTH-1 downto 0). + -- Result: Adds an UNSIGNED vector, L, with a non-negative INTEGER, R. + + -- Id: A.6 + function "+" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector(R'LENGTH-1 downto 0). + -- Result: Adds a non-negative INTEGER, L, with an UNSIGNED vector, R. + + --============================================================================ + + -- Id: A.9 + function "-" (L, R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: UNSIGNED(MAXIMUM(L'LENGTH, R'LENGTH)-1 downto 0). + -- Result: Subtracts two UNSIGNED vectors that may be of different lengths. + + -- Id: A.9R + function "-"(L : BIT_VECTOR; R : BIT) return BIT_VECTOR; + -- Result subtype: bit_vector(L'LENGTH-1 downto 0) + -- Result: Similar to A.9 where R is a one bit UNSIGNED + + -- Id: A.9L + function "-"(L : BIT; R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector(R'LENGTH-1 downto 0) + -- Result: Similar to A.9 where L is a one bit UNSIGNED + + -- Id: A.11 + function "-" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; + -- Result subtype: bit_vector(L'LENGTH-1 downto 0). + -- Result: Subtracts a non-negative INTEGER, R, from an UNSIGNED vector, L. + + -- Id: A.12 + function "-" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector(R'LENGTH-1 downto 0). + -- Result: Subtracts an UNSIGNED vector, R, from a non-negative INTEGER, L. + + --============================================================================ + + -- Id: A.15 + function "*" (L, R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector((L'LENGTH+R'LENGTH-1) downto 0). + -- Result: Performs the multiplication operation on two UNSIGNED vectors + -- that may possibly be of different lengths. + + -- Id: A.17 + function "*" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; + -- Result subtype: bit_vector((L'LENGTH+L'LENGTH-1) downto 0). + -- Result: Multiplies an UNSIGNED vector, L, with a non-negative + -- INTEGER, R. R is converted to an UNSIGNED vector of + -- SIZE L'LENGTH before multiplication. + + -- Id: A.18 + function "*" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector((R'LENGTH+R'LENGTH-1) downto 0). + -- Result: Multiplies an UNSIGNED vector, R, with a non-negative + -- INTEGER, L. L is converted to an UNSIGNED vector of + -- SIZE R'LENGTH before multiplication. + + --============================================================================ + -- + -- NOTE: If second argument is zero for "/" operator, a severity level + -- of ERROR is issued. + + -- Id: A.21 + function "/" (L, R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector(L'LENGTH-1 downto 0) + -- Result: Divides an UNSIGNED vector, L, by another UNSIGNED vector, R. + + -- Id: A.23 + function "/" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; + -- Result subtype: bit_vector(L'LENGTH-1 downto 0) + -- Result: Divides an UNSIGNED vector, L, by a non-negative INTEGER, R. + -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. + + -- Id: A.24 + function "/" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector(R'LENGTH-1 downto 0) + -- Result: Divides a non-negative INTEGER, L, by an UNSIGNED vector, R. + -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. + + --============================================================================ + -- + -- NOTE: If second argument is zero for "rem" operator, a severity level + -- of ERROR is issued. + + -- Id: A.27 + function "rem" (L, R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector(R'LENGTH-1 downto 0) + -- Result: Computes "L rem R" where L and R are UNSIGNED vectors. + + -- Id: A.29 + function "rem" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; + -- Result subtype: bit_vector(L'LENGTH-1 downto 0) + -- Result: Computes "L rem R" where L is an UNSIGNED vector and R is a + -- non-negative INTEGER. + -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. + + -- Id: A.30 + function "rem" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector(R'LENGTH-1 downto 0) + -- Result: Computes "L rem R" where R is an UNSIGNED vector and L is a + -- non-negative INTEGER. + -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. + + --============================================================================ + -- + -- NOTE: If second argument is zero for "mod" operator, a severity level + -- of ERROR is issued. + + -- Id: A.33 + function "mod" (L, R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector(R'LENGTH-1 downto 0) + -- Result: Computes "L mod R" where L and R are UNSIGNED vectors. + + -- Id: A.35 + function "mod" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; + -- Result subtype: bit_vector(L'LENGTH-1 downto 0) + -- Result: Computes "L mod R" where L is an UNSIGNED vector and R + -- is a non-negative INTEGER. + -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. + + -- Id: A.36 + function "mod" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: bit_vector(R'LENGTH-1 downto 0) + -- Result: Computes "L mod R" where R is an UNSIGNED vector and L + -- is a non-negative INTEGER. + -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. + + --============================================================================ + -- Id: A.39 + function find_leftmost (ARG : BIT_VECTOR; Y : BIT) return INTEGER; + -- Result subtype: INTEGER + -- Result: Finds the leftmost occurrence of the value of Y in ARG. + -- Returns the index of the occurrence if it exists, or -1 otherwise. + + -- Id: A.41 + function find_rightmost (ARG : BIT_VECTOR; Y : BIT) return INTEGER; + -- Result subtype: INTEGER + -- Result: Finds the leftmost occurrence of the value of Y in ARG. + -- Returns the index of the occurrence if it exists, or -1 otherwise. + + --============================================================================ + -- Comparison Operators + --============================================================================ + -- Id: C.1 + function ">" (L, R : BIT_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L > R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.3 + function ">" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L > R" where L is a non-negative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.5 + function ">" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L > R" where L is an UNSIGNED vector and + -- R is a non-negative INTEGER. + + --============================================================================ + -- Id: C.7 + function "<" (L, R : BIT_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L < R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.9 + function "<" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L < R" where L is a non-negative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.11 + function "<" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L < R" where L is an UNSIGNED vector and + -- R is a non-negative INTEGER. + + --============================================================================ + -- Id: C.13 + function "<=" (L, R : BIT_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L <= R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.15 + function "<=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L <= R" where L is a non-negative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.17 + function "<=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L <= R" where L is an UNSIGNED vector and + -- R is a non-negative INTEGER. + + --============================================================================ + -- Id: C.19 + function ">=" (L, R : BIT_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L >= R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.21 + function ">=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L >= R" where L is a non-negative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.23 + function ">=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L >= R" where L is an UNSIGNED vector and + -- R is a non-negative INTEGER. + + --============================================================================ + -- Id: C.25 + function "=" (L, R : BIT_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L = R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.27 + function "=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L = R" where L is a non-negative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.29 + function "=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L = R" where L is an UNSIGNED vector and + -- R is a non-negative INTEGER. + + --============================================================================ + + -- Id: C.31 + function "/=" (L, R : BIT_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L /= R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.33 + function "/=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L /= R" where L is a non-negative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.35 + function "/=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L /= R" where L is an UNSIGNED vector and + -- R is a non-negative INTEGER. + + --============================================================================ + + -- Id: C.37 + function MINIMUM (L, R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR + -- Result: Returns the lesser of two UNSIGNED vectors that may be + -- of different lengths. + + -- Id: C.39 + function MINIMUM (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR + -- Result: Returns the lesser of a nonnegative INTEGER, L, and + -- an UNSIGNED vector, R. + + -- Id: C.41 + function MINIMUM (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR + -- Result: Returns the lesser of an UNSIGNED vector, L, and + -- a nonnegative INTEGER, R. + + --============================================================================ + + -- Id: C.43 + function MAXIMUM (L, R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR + -- Result: Returns the greater of two UNSIGNED vectors that may be + -- of different lengths. + + -- Id: C.45 + function MAXIMUM (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR + -- Result: Returns the greater of a nonnegative INTEGER, L, and + -- an UNSIGNED vector, R. + + -- Id: C.47 + function MAXIMUM (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR + -- Result: Returns the greater of an UNSIGNED vector, L, and + -- a nonnegative INTEGER, R. + + --============================================================================ + -- Id: C.49 + function "?>" (L, R : BIT_VECTOR) return BIT; + -- Result subtype: BIT + -- Result: Computes "L > R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.51 + function "?>" (L : NATURAL; R : BIT_VECTOR) return BIT; + -- Result subtype: BIT + -- Result: Computes "L > R" where L is a nonnegative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.53 + function "?>" (L : BIT_VECTOR; R : NATURAL) return BIT; + -- Result subtype: BIT + -- Result: Computes "L > R" where L is an UNSIGNED vector and + -- R is a nonnegative INTEGER. + + --============================================================================ + + -- Id: C.55 + function "?<" (L, R : BIT_VECTOR) return BIT; + -- Result subtype: BIT + -- Result: Computes "L < R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.57 + function "?<" (L : NATURAL; R : BIT_VECTOR) return BIT; + -- Result subtype: BIT + -- Result: Computes "L < R" where L is a nonnegative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.59 + function "?<" (L : BIT_VECTOR; R : NATURAL) return BIT; + -- Result subtype: BIT + -- Result: Computes "L < R" where L is an UNSIGNED vector and + -- R is a nonnegative INTEGER. + + --============================================================================ + + -- Id: C.61 + function "?<=" (L, R : BIT_VECTOR) return BIT; + -- Result subtype: BIT + -- Result: Computes "L <= R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.63 + function "?<=" (L : NATURAL; R : BIT_VECTOR) return BIT; + -- Result subtype: BIT + -- Result: Computes "L <= R" where L is a nonnegative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.65 + function "?<=" (L : BIT_VECTOR; R : NATURAL) return BIT; + -- Result subtype: BIT + -- Result: Computes "L <= R" where L is an UNSIGNED vector and + -- R is a nonnegative INTEGER. + + --============================================================================ + + -- Id: C.67 + function "?>=" (L, R : BIT_VECTOR) return BIT; + -- Result subtype: BIT + -- Result: Computes "L >= R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.69 + function "?>=" (L : NATURAL; R : BIT_VECTOR) return BIT; + -- Result subtype: BIT + -- Result: Computes "L >= R" where L is a nonnegative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.71 + function "?>=" (L : BIT_VECTOR; R : NATURAL) return BIT; + -- Result subtype: BIT + -- Result: Computes "L >= R" where L is an UNSIGNED vector and + -- R is a nonnegative INTEGER. + + --============================================================================ + + -- Id: C.73 + function "?=" (L, R : BIT_VECTOR) return BIT; + -- Result subtype: BIT + -- Result: Computes "L = R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.75 + function "?=" (L : NATURAL; R : BIT_VECTOR) return BIT; + -- Result subtype: BIT + -- Result: Computes "L = R" where L is a nonnegative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.77 + function "?=" (L : BIT_VECTOR; R : NATURAL) return BIT; + -- Result subtype: BIT + -- Result: Computes "L = R" where L is an UNSIGNED vector and + -- R is a nonnegative INTEGER. + + --============================================================================ + + -- Id: C.79 + function "?/=" (L, R : BIT_VECTOR) return BIT; + -- Result subtype: BIT + -- Result: Computes "L /= R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.81 + function "?/=" (L : NATURAL; R : BIT_VECTOR) return BIT; + -- Result subtype: BIT + -- Result: Computes "L /= R" where L is a nonnegative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.83 + function "?/=" (L : BIT_VECTOR; R : NATURAL) return BIT; + -- Result subtype: BIT + -- Result: Computes "L /= R" where L is an UNSIGNED vector and + -- R is a nonnegative INTEGER. + + --============================================================================ + -- Shift and Rotate Functions + --============================================================================ + + -- Id: S.1 + function SHIFT_LEFT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR; + -- Result subtype: bit_vector(ARG'LENGTH-1 downto 0) + -- Result: Performs a shift-left on an UNSIGNED vector COUNT times. + -- The vacated positions are filled with '0'. + -- The COUNT leftmost elements are lost. + + -- Id: S.2 + function SHIFT_RIGHT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR; + -- Result subtype: UNSIGNED(ARG'LENGTH-1 downto 0) + -- Result: Performs a shift-right on an UNSIGNED vector COUNT times. + -- The vacated positions are filled with '0'. + -- The COUNT rightmost elements are lost. + --============================================================================ + + -- Id: S.5 + function ROTATE_LEFT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR; + -- Result subtype: bit_vector(ARG'LENGTH-1 downto 0) + -- Result: Performs a rotate-left of an UNSIGNED vector COUNT times. + + -- Id: S.6 + function ROTATE_RIGHT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR; + -- Result subtype: bit_vector(ARG'LENGTH-1 downto 0) + -- Result: Performs a rotate-right of an UNSIGNED vector COUNT times. + + + --============================================================================ + + ------------------------------------------------------------------------------ + -- Note: Function S.9 is not compatible with IEEE Std 1076-1987. Comment + -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. + ------------------------------------------------------------------------------ + -- Id: S.9 + function "sll" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) + -- Result: SHIFT_LEFT(ARG, COUNT) + + ------------------------------------------------------------------------------ + -- Note: Function S.11 is not compatible with IEEE Std 1076-1987. Comment + -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. + ------------------------------------------------------------------------------ + -- Id: S.11 + function "srl" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) + -- Result: SHIFT_RIGHT(ARG, COUNT) + + ------------------------------------------------------------------------------ + -- Note: Function S.13 is not compatible with IEEE Std 1076-1987. Comment + -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. + ------------------------------------------------------------------------------ + -- Id: S.13 + function "rol" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) + -- Result: ROTATE_LEFT(ARG, COUNT) + + ------------------------------------------------------------------------------ + -- Note: Function S.15 is not compatible with IEEE Std 1076-1987. Comment + -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. + ------------------------------------------------------------------------------ + -- Id: S.15 + function "ror" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) + -- Result: ROTATE_RIGHT(ARG, COUNT) + + ------------------------------------------------------------------------------ + -- Note: Function S.17 is not compatible with IEEE Std 1076-1987. Comment + -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. + ------------------------------------------------------------------------------ + -- Id: S.17 + function "sla" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) + -- Result: SHIFT_LEFT(ARG, COUNT) + + ------------------------------------------------------------------------------ + -- Note: Function S.19 is not compatible with IEEE Std 1076-1987. Comment + -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. + ------------------------------------------------------------------------------ + -- Id: S.19 + function "sra" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) + -- Result: SHIFT_RIGHT(ARG, COUNT) + + + --============================================================================ + -- RESIZE Functions + --============================================================================ + + -- Id: R.2 + function RESIZE (ARG : BIT_VECTOR; NEW_SIZE : NATURAL) return BIT_VECTOR; + -- Result subtype: bit_vector(NEW_SIZE-1 downto 0) + -- Result: Resizes the UNSIGNED vector ARG to the specified size. + -- To create a larger vector, the new [leftmost] bit positions + -- are filled with '0'. When truncating, the leftmost bits + -- are dropped. + + function RESIZE (ARG, SIZE_RES : BIT_VECTOR) return BIT_VECTOR; + -- Result subtype: BIT_VECTOR (SIZE_RES'length-1 downto 0) + + --============================================================================ + -- Conversion Functions + --============================================================================ + + -- Id: D.1 + function TO_INTEGER (ARG : BIT_VECTOR) return NATURAL; + -- Result subtype: NATURAL. Value cannot be negative since parameter is an + -- UNSIGNED vector. + -- Result: Converts the UNSIGNED vector to an INTEGER. + + -- Id: D.3 + function To_BitVector (ARG, SIZE : NATURAL) return BIT_VECTOR; + -- Result subtype: bit_vector(SIZE-1 downto 0) + -- Result: Converts a non-negative INTEGER to an UNSIGNED vector with + -- the specified size. + + function To_BitVector (ARG : NATURAL; SIZE_RES : BIT_VECTOR) + return BIT_VECTOR; + -- Result subtype: STD_LOGIC_VECTOR(SIZE_RES'length-1 downto 0) + +-- begin LCS-2006-130 + alias To_Bit_Vector is + To_BitVector[NATURAL, NATURAL return BIT_VECTOR]; + alias To_BV is + To_BitVector[NATURAL, NATURAL return BIT_VECTOR]; + + alias To_Bit_Vector is + To_BitVector[NATURAL, BIT_VECTOR return BIT_VECTOR]; + alias To_BV is + To_BitVector[NATURAL, BIT_VECTOR return BIT_VECTOR]; + +end package NUMERIC_BIT_UNSIGNED; diff --git a/libraries/ieee2008/numeric_std-body.vhdl b/libraries/ieee2008/numeric_std-body.vhdl index 9fe0db6a8..a876a1fad 100644 --- a/libraries/ieee2008/numeric_std-body.vhdl +++ b/libraries/ieee2008/numeric_std-body.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Standard VHDL Synthesis Packages -- : (NUMERIC_STD package body) @@ -346,7 +349,6 @@ package body NUMERIC_STD is -- Id: A.2 function "-" (ARG : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED is constant ARG_LEFT : INTEGER := ARG'length-1; - alias XARG : UNRESOLVED_SIGNED(ARG_LEFT downto 0) is ARG; variable RESULT, XARG01 : UNRESOLVED_SIGNED(ARG_LEFT downto 0); variable CBIT : STD_LOGIC := '1'; begin @@ -2223,7 +2225,7 @@ package body NUMERIC_STD is return 'X'; end if; end loop; - if Is_X(L) or Is_X(R) then + if IS_X(L) or IS_X(R) then return 'X'; elsif L > R then return '1'; @@ -2256,7 +2258,7 @@ package body NUMERIC_STD is return 'X'; end if; end loop; - if Is_X(L) or Is_X(R) then + if IS_X(L) or IS_X(R) then return 'X'; elsif L > R then return '1'; @@ -2315,7 +2317,7 @@ package body NUMERIC_STD is return 'X'; end if; end loop; - if Is_X(L) or Is_X(R) then + if IS_X(L) or IS_X(R) then return 'X'; elsif L < R then return '1'; @@ -2348,7 +2350,7 @@ package body NUMERIC_STD is return 'X'; end if; end loop; - if Is_X(L) or Is_X(R) then + if IS_X(L) or IS_X(R) then return 'X'; elsif L < R then return '1'; @@ -2407,7 +2409,7 @@ package body NUMERIC_STD is return 'X'; end if; end loop; - if Is_X(L) or Is_X(R) then + if IS_X(L) or IS_X(R) then return 'X'; elsif L <= R then return '1'; @@ -2440,7 +2442,7 @@ package body NUMERIC_STD is return 'X'; end if; end loop; - if Is_X(L) or Is_X(R) then + if IS_X(L) or IS_X(R) then return 'X'; elsif L <= R then return '1'; @@ -2499,7 +2501,7 @@ package body NUMERIC_STD is return 'X'; end if; end loop; - if Is_X(L) or Is_X(R) then + if IS_X(L) or IS_X(R) then return 'X'; elsif L >= R then return '1'; @@ -2532,7 +2534,7 @@ package body NUMERIC_STD is return 'X'; end if; end loop; - if Is_X(L) or Is_X(R) then + if IS_X(L) or IS_X(R) then return 'X'; elsif L >= R then return '1'; @@ -3321,70 +3323,70 @@ package body NUMERIC_STD is return RESULT; end function "xnor"; - -- Id: L.15 + -- Id: L.15 function "and" (L : STD_ULOGIC; R : UNRESOLVED_UNSIGNED) return UNRESOLVED_UNSIGNED is begin return UNRESOLVED_UNSIGNED (L and STD_ULOGIC_VECTOR(R)); end function "and"; - -- Id: L.16 + -- Id: L.16 function "and" (L : UNRESOLVED_UNSIGNED; R : STD_ULOGIC) return UNRESOLVED_UNSIGNED is begin return UNRESOLVED_UNSIGNED (STD_ULOGIC_VECTOR(L) and R); end function "and"; - -- Id: L.17 + -- Id: L.17 function "or" (L : STD_ULOGIC; R : UNRESOLVED_UNSIGNED) return UNRESOLVED_UNSIGNED is begin return UNRESOLVED_UNSIGNED (L or STD_ULOGIC_VECTOR(R)); end function "or"; - -- Id: L.18 + -- Id: L.18 function "or" (L : UNRESOLVED_UNSIGNED; R : STD_ULOGIC) return UNRESOLVED_UNSIGNED is begin return UNRESOLVED_UNSIGNED (STD_ULOGIC_VECTOR(L) or R); end function "or"; - -- Id: L.19 + -- Id: L.19 function "nand" (L : STD_ULOGIC; R : UNRESOLVED_UNSIGNED) return UNRESOLVED_UNSIGNED is begin return UNRESOLVED_UNSIGNED (L nand STD_ULOGIC_VECTOR(R)); end function "nand"; - -- Id: L.20 + -- Id: L.20 function "nand" (L : UNRESOLVED_UNSIGNED; R : STD_ULOGIC) return UNRESOLVED_UNSIGNED is begin return UNRESOLVED_UNSIGNED (STD_ULOGIC_VECTOR(L) nand R); end function "nand"; - -- Id: L.21 + -- Id: L.21 function "nor" (L : STD_ULOGIC; R : UNRESOLVED_UNSIGNED) return UNRESOLVED_UNSIGNED is begin return UNRESOLVED_UNSIGNED (L nor STD_ULOGIC_VECTOR(R)); end function "nor"; - -- Id: L.22 + -- Id: L.22 function "nor" (L : UNRESOLVED_UNSIGNED; R : STD_ULOGIC) return UNRESOLVED_UNSIGNED is begin return UNRESOLVED_UNSIGNED (STD_ULOGIC_VECTOR(L) nor R); end function "nor"; - -- Id: L.23 + -- Id: L.23 function "xor" (L : STD_ULOGIC; R : UNRESOLVED_UNSIGNED) return UNRESOLVED_UNSIGNED is begin return UNRESOLVED_UNSIGNED (L xor STD_ULOGIC_VECTOR(R)); end function "xor"; - -- Id: L.24 + -- Id: L.24 function "xor" (L : UNRESOLVED_UNSIGNED; R : STD_ULOGIC) return UNRESOLVED_UNSIGNED is begin @@ -3395,7 +3397,7 @@ package body NUMERIC_STD is -- Note: Function L.25 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.25 + -- Id: L.25 function "xnor" (L : STD_ULOGIC; R : UNRESOLVED_UNSIGNED) return UNRESOLVED_UNSIGNED is begin @@ -3406,77 +3408,77 @@ package body NUMERIC_STD is -- Note: Function L.26 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.26 + -- Id: L.26 function "xnor" (L : UNRESOLVED_UNSIGNED; R : STD_ULOGIC) return UNRESOLVED_UNSIGNED is begin return UNRESOLVED_UNSIGNED (STD_ULOGIC_VECTOR(L) xnor R); end function "xnor"; - -- Id: L.27 + -- Id: L.27 function "and" (L : STD_ULOGIC; R : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED is begin return UNRESOLVED_SIGNED (L and STD_ULOGIC_VECTOR(R)); end function "and"; - -- Id: L.28 + -- Id: L.28 function "and" (L : UNRESOLVED_SIGNED; R : STD_ULOGIC) return UNRESOLVED_SIGNED is begin return UNRESOLVED_SIGNED (STD_ULOGIC_VECTOR(L) and R); end function "and"; - -- Id: L.29 + -- Id: L.29 function "or" (L : STD_ULOGIC; R : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED is begin return UNRESOLVED_SIGNED (L or STD_ULOGIC_VECTOR(R)); end function "or"; - -- Id: L.30 + -- Id: L.30 function "or" (L : UNRESOLVED_SIGNED; R : STD_ULOGIC) return UNRESOLVED_SIGNED is begin return UNRESOLVED_SIGNED (STD_ULOGIC_VECTOR(L) or R); end function "or"; - -- Id: L.31 + -- Id: L.31 function "nand" (L : STD_ULOGIC; R : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED is begin return UNRESOLVED_SIGNED (L nand STD_ULOGIC_VECTOR(R)); end function "nand"; - -- Id: L.32 + -- Id: L.32 function "nand" (L : UNRESOLVED_SIGNED; R : STD_ULOGIC) return UNRESOLVED_SIGNED is begin return UNRESOLVED_SIGNED (STD_ULOGIC_VECTOR(L) nand R); end function "nand"; - -- Id: L.33 + -- Id: L.33 function "nor" (L : STD_ULOGIC; R : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED is begin return UNRESOLVED_SIGNED (L nor STD_ULOGIC_VECTOR(R)); end function "nor"; - -- Id: L.34 + -- Id: L.34 function "nor" (L : UNRESOLVED_SIGNED; R : STD_ULOGIC) return UNRESOLVED_SIGNED is begin return UNRESOLVED_SIGNED (STD_ULOGIC_VECTOR(L) nor R); end function "nor"; - -- Id: L.35 + -- Id: L.35 function "xor" (L : STD_ULOGIC; R : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED is begin return UNRESOLVED_SIGNED (L xor STD_ULOGIC_VECTOR(R)); end function "xor"; - -- Id: L.36 + -- Id: L.36 function "xor" (L : UNRESOLVED_SIGNED; R : STD_ULOGIC) return UNRESOLVED_SIGNED is begin @@ -3487,7 +3489,7 @@ package body NUMERIC_STD is -- Note: Function L.37 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.37 + -- Id: L.37 function "xnor" (L : STD_ULOGIC; R : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED is begin @@ -3498,7 +3500,7 @@ package body NUMERIC_STD is -- Note: Function L.38 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.38 + -- Id: L.38 function "xnor" (L : UNRESOLVED_SIGNED; R : STD_ULOGIC) return UNRESOLVED_SIGNED is begin @@ -3660,7 +3662,6 @@ package body NUMERIC_STD is -- Id: M.1 function STD_MATCH (L, R : STD_ULOGIC) return BOOLEAN is - variable VALUE : STD_ULOGIC; begin return MATCH_TABLE(L, R); end function STD_MATCH; @@ -3827,19 +3828,19 @@ package body NUMERIC_STD is -- ============================================================================ -- string conversion and write operations -- ============================================================================ - function to_ostring (value : UNRESOLVED_UNSIGNED) return STRING is + function TO_OSTRING (value : UNRESOLVED_UNSIGNED) return STRING is begin - return to_ostring(STD_ULOGIC_VECTOR (value)); - end function to_ostring; + return TO_OSTRING(STD_ULOGIC_VECTOR (value)); + end function TO_OSTRING; - function to_ostring (value : UNRESOLVED_SIGNED) return STRING is + function TO_OSTRING (value : UNRESOLVED_SIGNED) return STRING is constant result_length : INTEGER := (value'length+2)/3; constant pad : STD_ULOGIC_VECTOR(1 to (result_length*3 - value'length)) := (others => value (value'left)); -- Extend sign bit begin - return to_ostring(pad & STD_ULOGIC_VECTOR (value)); - end function to_ostring; + return TO_OSTRING(pad & STD_ULOGIC_VECTOR (value)); + end function TO_OSTRING; function to_hstring (value : UNRESOLVED_UNSIGNED) return STRING is begin @@ -3857,7 +3858,7 @@ package body NUMERIC_STD is procedure READ (L : inout LINE; VALUE : out UNRESOLVED_UNSIGNED; GOOD : out BOOLEAN) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin READ (L => L, VALUE => ivalue, @@ -3866,7 +3867,7 @@ package body NUMERIC_STD is end procedure READ; procedure READ (L : inout LINE; VALUE : out UNRESOLVED_UNSIGNED) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin READ (L => L, VALUE => ivalue); @@ -3875,7 +3876,7 @@ package body NUMERIC_STD is procedure READ (L : inout LINE; VALUE : out UNRESOLVED_SIGNED; GOOD : out BOOLEAN) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin READ (L => L, VALUE => ivalue, @@ -3884,7 +3885,7 @@ package body NUMERIC_STD is end procedure READ; procedure READ (L : inout LINE; VALUE : out UNRESOLVED_SIGNED) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin READ (L => L, VALUE => ivalue); @@ -3893,7 +3894,7 @@ package body NUMERIC_STD is procedure WRITE (L : inout LINE; VALUE : in UNRESOLVED_UNSIGNED; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin ivalue := STD_ULOGIC_VECTOR (VALUE); WRITE (L => L, @@ -3904,7 +3905,7 @@ package body NUMERIC_STD is procedure WRITE (L : inout LINE; VALUE : in UNRESOLVED_SIGNED; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin ivalue := STD_ULOGIC_VECTOR (VALUE); WRITE (L => L, @@ -3915,7 +3916,7 @@ package body NUMERIC_STD is procedure OREAD (L : inout LINE; VALUE : out UNRESOLVED_UNSIGNED; GOOD : out BOOLEAN) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin OREAD (L => L, VALUE => ivalue, @@ -3925,8 +3926,8 @@ package body NUMERIC_STD is procedure OREAD (L : inout LINE; VALUE : out UNRESOLVED_SIGNED; GOOD : out BOOLEAN) is - constant ne : INTEGER := (value'length+2)/3; - constant pad : INTEGER := ne*3 - value'length; + constant ne : INTEGER := (VALUE'length+2)/3; + constant pad : INTEGER := ne*3 - VALUE'length; variable ivalue : STD_ULOGIC_VECTOR(0 to ne*3-1); variable ok : BOOLEAN; variable expected_padding : STD_ULOGIC_VECTOR(0 to pad-1); @@ -3949,7 +3950,7 @@ package body NUMERIC_STD is end procedure OREAD; procedure OREAD (L : inout LINE; VALUE : out UNRESOLVED_UNSIGNED) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin OREAD (L => L, VALUE => ivalue); @@ -3957,8 +3958,8 @@ package body NUMERIC_STD is end procedure OREAD; procedure OREAD (L : inout LINE; VALUE : out UNRESOLVED_SIGNED) is - constant ne : INTEGER := (value'length+2)/3; - constant pad : INTEGER := ne*3 - value'length; + constant ne : INTEGER := (VALUE'length+2)/3; + constant pad : INTEGER := ne*3 - VALUE'length; variable ivalue : STD_ULOGIC_VECTOR(0 to ne*3-1); variable expected_padding : STD_ULOGIC_VECTOR(0 to pad-1); begin @@ -3976,7 +3977,7 @@ package body NUMERIC_STD is procedure HREAD (L : inout LINE; VALUE : out UNRESOLVED_UNSIGNED; GOOD : out BOOLEAN) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin HREAD (L => L, VALUE => ivalue, @@ -3986,8 +3987,8 @@ package body NUMERIC_STD is procedure HREAD (L : inout LINE; VALUE : out UNRESOLVED_SIGNED; GOOD : out BOOLEAN) is - constant ne : INTEGER := (value'length+3)/4; - constant pad : INTEGER := ne*4 - value'length; + constant ne : INTEGER := (VALUE'length+3)/4; + constant pad : INTEGER := ne*4 - VALUE'length; variable ivalue : STD_ULOGIC_VECTOR(0 to ne*4-1); variable ok : BOOLEAN; variable expected_padding : STD_ULOGIC_VECTOR(0 to pad-1); @@ -4009,7 +4010,7 @@ package body NUMERIC_STD is end procedure HREAD; procedure HREAD (L : inout LINE; VALUE : out UNRESOLVED_UNSIGNED) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin HREAD (L => L, VALUE => ivalue); @@ -4017,8 +4018,8 @@ package body NUMERIC_STD is end procedure HREAD; procedure HREAD (L : inout LINE; VALUE : out UNRESOLVED_SIGNED) is - constant ne : INTEGER := (value'length+3)/4; - constant pad : INTEGER := ne*4 - value'length; + constant ne : INTEGER := (VALUE'length+3)/4; + constant pad : INTEGER := ne*4 - VALUE'length; variable ivalue : STD_ULOGIC_VECTOR(0 to ne*4-1); variable expected_padding : STD_ULOGIC_VECTOR(0 to pad-1); begin @@ -4036,7 +4037,7 @@ package body NUMERIC_STD is procedure OWRITE (L : inout LINE; VALUE : in UNRESOLVED_UNSIGNED; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin ivalue := STD_ULOGIC_VECTOR (VALUE); OWRITE (L => L, @@ -4050,7 +4051,7 @@ package body NUMERIC_STD is constant ne : INTEGER := (VALUE'length+2)/3; constant pad : STD_ULOGIC_VECTOR(0 to (ne*3 - VALUE'length) - 1) := (others => VALUE (VALUE'left)); - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin ivalue := STD_ULOGIC_VECTOR (VALUE); OWRITE (L => L, @@ -4061,7 +4062,7 @@ package body NUMERIC_STD is procedure HWRITE (L : inout LINE; VALUE : in UNRESOLVED_UNSIGNED; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); begin ivalue := STD_ULOGIC_VECTOR (VALUE); HWRITE (L => L, @@ -4072,9 +4073,9 @@ package body NUMERIC_STD is procedure HWRITE (L : inout LINE; VALUE : in UNRESOLVED_SIGNED; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is - variable ivalue : STD_ULOGIC_VECTOR(value'range); - constant ne : INTEGER := (value'length+3)/4; - constant pad : STD_ULOGIC_VECTOR(0 to (ne*4 - value'length) - 1) + variable ivalue : STD_ULOGIC_VECTOR(VALUE'range); + constant ne : INTEGER := (VALUE'length+3)/4; + constant pad : STD_ULOGIC_VECTOR(0 to (ne*4 - VALUE'length) - 1) := (others => VALUE(VALUE'left)); begin ivalue := STD_ULOGIC_VECTOR (VALUE); diff --git a/libraries/ieee2008/numeric_std.vhdl b/libraries/ieee2008/numeric_std.vhdl index 3ce4357d2..67dca1288 100644 --- a/libraries/ieee2008/numeric_std.vhdl +++ b/libraries/ieee2008/numeric_std.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Standard VHDL Synthesis Packages -- : (NUMERIC_STD package declaration) @@ -75,7 +78,6 @@ package NUMERIC_STD is type UNRESOLVED_UNSIGNED is array (NATURAL range <>) of STD_ULOGIC; type UNRESOLVED_SIGNED is array (NATURAL range <>) of STD_ULOGIC; - -- FIXME: was alias subtype U_UNSIGNED is UNRESOLVED_UNSIGNED; subtype U_SIGNED is UNRESOLVED_SIGNED; @@ -1235,52 +1237,52 @@ package NUMERIC_STD is -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector XNOR operation - -- Id: L.15 + -- Id: L.15 function "and" (L : STD_ULOGIC; R : UNRESOLVED_UNSIGNED) return UNRESOLVED_UNSIGNED; -- Result subtype: UNRESOLVED_SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector AND operation - -- Id: L.16 + -- Id: L.16 function "and" (L : UNRESOLVED_UNSIGNED; R : STD_ULOGIC) return UNRESOLVED_UNSIGNED; -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar AND operation - -- Id: L.17 + -- Id: L.17 function "or" (L : STD_ULOGIC; R : UNRESOLVED_UNSIGNED) return UNRESOLVED_UNSIGNED; -- Result subtype: UNRESOLVED_SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector OR operation - -- Id: L.18 + -- Id: L.18 function "or" (L : UNRESOLVED_UNSIGNED; R : STD_ULOGIC) return UNRESOLVED_UNSIGNED; -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar OR operation - -- Id: L.19 + -- Id: L.19 function "nand" (L : STD_ULOGIC; R : UNRESOLVED_UNSIGNED) return UNRESOLVED_UNSIGNED; -- Result subtype: UNRESOLVED_SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector NAND operation - -- Id: L.20 + -- Id: L.20 function "nand" (L : UNRESOLVED_UNSIGNED; R : STD_ULOGIC) return UNRESOLVED_UNSIGNED; -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar NAND operation - -- Id: L.21 + -- Id: L.21 function "nor" (L : STD_ULOGIC; R : UNRESOLVED_UNSIGNED) return UNRESOLVED_UNSIGNED; -- Result subtype: UNRESOLVED_SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector NOR operation - -- Id: L.22 + -- Id: L.22 function "nor" (L : UNRESOLVED_UNSIGNED; R : STD_ULOGIC) return UNRESOLVED_UNSIGNED; -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar NOR operation - -- Id: L.23 + -- Id: L.23 function "xor" (L : STD_ULOGIC; R : UNRESOLVED_UNSIGNED) return UNRESOLVED_UNSIGNED; -- Result subtype: UNRESOLVED_SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector XOR operation - -- Id: L.24 + -- Id: L.24 function "xor" (L : UNRESOLVED_UNSIGNED; R : STD_ULOGIC) return UNRESOLVED_UNSIGNED; -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar XOR operation @@ -1289,7 +1291,7 @@ package NUMERIC_STD is -- Note: Function L.25 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.25 + -- Id: L.25 function "xnor" (L : STD_ULOGIC; R : UNRESOLVED_UNSIGNED) return UNRESOLVED_UNSIGNED; -- Result subtype: UNRESOLVED_SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector XNOR operation @@ -1298,57 +1300,57 @@ package NUMERIC_STD is -- Note: Function L.26 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.26 + -- Id: L.26 function "xnor" (L : UNRESOLVED_UNSIGNED; R : STD_ULOGIC) return UNRESOLVED_UNSIGNED; -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar XNOR operation - -- Id: L.27 + -- Id: L.27 function "and" (L : STD_ULOGIC; R : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED; -- Result subtype: UNRESOLVED_SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector AND operation - -- Id: L.28 + -- Id: L.28 function "and" (L : UNRESOLVED_SIGNED; R : STD_ULOGIC) return UNRESOLVED_SIGNED; -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar AND operation - -- Id: L.29 + -- Id: L.29 function "or" (L : STD_ULOGIC; R : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED; -- Result subtype: UNRESOLVED_SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector OR operation - -- Id: L.30 + -- Id: L.30 function "or" (L : UNRESOLVED_SIGNED; R : STD_ULOGIC) return UNRESOLVED_SIGNED; -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar OR operation - -- Id: L.31 + -- Id: L.31 function "nand" (L : STD_ULOGIC; R : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED; -- Result subtype: UNRESOLVED_SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector NAND operation - -- Id: L.32 + -- Id: L.32 function "nand" (L : UNRESOLVED_SIGNED; R : STD_ULOGIC) return UNRESOLVED_SIGNED; -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar NAND operation - -- Id: L.33 + -- Id: L.33 function "nor" (L : STD_ULOGIC; R : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED; -- Result subtype: UNRESOLVED_SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector NOR operation - -- Id: L.34 + -- Id: L.34 function "nor" (L : UNRESOLVED_SIGNED; R : STD_ULOGIC) return UNRESOLVED_SIGNED; -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar NOR operation - -- Id: L.35 + -- Id: L.35 function "xor" (L : STD_ULOGIC; R : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED; -- Result subtype: UNRESOLVED_SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector XOR operation - -- Id: L.36 + -- Id: L.36 function "xor" (L : UNRESOLVED_SIGNED; R : STD_ULOGIC) return UNRESOLVED_SIGNED; -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar XOR operation @@ -1357,7 +1359,7 @@ package NUMERIC_STD is -- Note: Function L.37 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.37 + -- Id: L.37 function "xnor" (L : STD_ULOGIC; R : UNRESOLVED_SIGNED) return UNRESOLVED_SIGNED; -- Result subtype: UNRESOLVED_SIGNED(R'LENGTH-1 downto 0) -- Result: Scalar/Vector XNOR operation @@ -1366,7 +1368,7 @@ package NUMERIC_STD is -- Note: Function L.38 is not compatible with IEEE Std 1076-1987. Comment -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. ------------------------------------------------------------------------------ - -- Id: L.38 + -- Id: L.38 function "xnor" (L : UNRESOLVED_SIGNED; R : STD_ULOGIC) return UNRESOLVED_SIGNED; -- Result subtype: UNRESOLVED_SIGNED(L'LENGTH-1 downto 0) -- Result: Vector/Scalar XNOR operation @@ -1378,8 +1380,8 @@ package NUMERIC_STD is ------------------------------------------------------------------------------ -- Id: L.39 function "and" (L : UNRESOLVED_SIGNED) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC. - -- Result: Result of and'ing all of the bits of the vector. + -- Result subtype: STD_ULOGIC. + -- Result: Result of and'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.40 is not compatible with editions of IEEE Std 1076 from @@ -1388,8 +1390,8 @@ package NUMERIC_STD is ------------------------------------------------------------------------------ -- Id: L.40 function "nand" (L : UNRESOLVED_SIGNED) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC. - -- Result: Result of nand'ing all of the bits of the vector. + -- Result subtype: STD_ULOGIC. + -- Result: Result of nand'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.41 is not compatible with editions of IEEE Std 1076 from @@ -1398,8 +1400,8 @@ package NUMERIC_STD is ------------------------------------------------------------------------------ -- Id: L.41 function "or" (L : UNRESOLVED_SIGNED) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC. - -- Result: Result of or'ing all of the bits of the vector. + -- Result subtype: STD_ULOGIC. + -- Result: Result of or'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.42 is not compatible with editions of IEEE Std 1076 from @@ -1408,8 +1410,8 @@ package NUMERIC_STD is ------------------------------------------------------------------------------ -- Id: L.42 function "nor" (L : UNRESOLVED_SIGNED) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC. - -- Result: Result of nor'ing all of the bits of the vector. + -- Result subtype: STD_ULOGIC. + -- Result: Result of nor'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.43 is not compatible with editions of IEEE Std 1076 from @@ -1418,8 +1420,8 @@ package NUMERIC_STD is ------------------------------------------------------------------------------ -- Id: L.43 function "xor" (L : UNRESOLVED_SIGNED) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC. - -- Result: Result of xor'ing all of the bits of the vector. + -- Result subtype: STD_ULOGIC. + -- Result: Result of xor'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.44 is not compatible with editions of IEEE Std 1076 from @@ -1428,8 +1430,8 @@ package NUMERIC_STD is ------------------------------------------------------------------------------ -- Id: L.44 function "xnor" (L : UNRESOLVED_SIGNED) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC. - -- Result: Result of xnor'ing all of the bits of the vector. + -- Result subtype: STD_ULOGIC. + -- Result: Result of xnor'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.45 is not compatible with editions of IEEE Std 1076 from @@ -1438,8 +1440,8 @@ package NUMERIC_STD is ------------------------------------------------------------------------------ -- Id: L.45 function "and" (L : UNRESOLVED_UNSIGNED) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC. - -- Result: Result of and'ing all of the bits of the vector. + -- Result subtype: STD_ULOGIC. + -- Result: Result of and'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.46 is not compatible with editions of IEEE Std 1076 from @@ -1448,8 +1450,8 @@ package NUMERIC_STD is ------------------------------------------------------------------------------ -- Id: L.46 function "nand" (L : UNRESOLVED_UNSIGNED) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC. - -- Result: Result of nand'ing all of the bits of the vector. + -- Result subtype: STD_ULOGIC. + -- Result: Result of nand'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.47 is not compatible with editions of IEEE Std 1076 from @@ -1458,8 +1460,8 @@ package NUMERIC_STD is ------------------------------------------------------------------------------ -- Id: L.47 function "or" (L : UNRESOLVED_UNSIGNED) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC. - -- Result: Result of or'ing all of the bits of the vector. + -- Result subtype: STD_ULOGIC. + -- Result: Result of or'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.48 is not compatible with editions of IEEE Std 1076 from @@ -1468,8 +1470,8 @@ package NUMERIC_STD is ------------------------------------------------------------------------------ -- Id: L.48 function "nor" (L : UNRESOLVED_UNSIGNED) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC. - -- Result: Result of nor'ing all of the bits of the vector. + -- Result subtype: STD_ULOGIC. + -- Result: Result of nor'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.49 is not compatible with editions of IEEE Std 1076 from @@ -1478,8 +1480,8 @@ package NUMERIC_STD is ------------------------------------------------------------------------------ -- Id: L.49 function "xor" (L : UNRESOLVED_UNSIGNED) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC. - -- Result: Result of xor'ing all of the bits of the vector. + -- Result subtype: STD_ULOGIC. + -- Result: Result of xor'ing all of the bits of the vector. ------------------------------------------------------------------------------ -- Note: Function L.50 is not compatible with editions of IEEE Std 1076 from @@ -1488,7 +1490,7 @@ package NUMERIC_STD is ------------------------------------------------------------------------------ -- Id: L.50 function "xnor" (L : UNRESOLVED_UNSIGNED) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC. + -- Result subtype: STD_ULOGIC. -- Result: Result of xnor'ing all of the bits of the vector. --============================================================================ @@ -1586,20 +1588,20 @@ package NUMERIC_STD is --============================================================================ -- the following operations are predefined - -- function to_string (value : UNRESOLVED_UNSIGNED) return STRING; - -- function to_string (value : UNRESOLVED_SIGNED) return STRING; + -- function TO_STRING (value : UNRESOLVED_UNSIGNED) return STRING; + -- function TO_STRING (value : UNRESOLVED_SIGNED) return STRING; -- explicitly defined operations - alias to_bstring is to_string [UNRESOLVED_UNSIGNED return STRING]; - alias to_bstring is to_string [UNRESOLVED_SIGNED return STRING]; - alias to_binary_string is to_string [UNRESOLVED_UNSIGNED return STRING]; - alias to_binary_string is to_string [UNRESOLVED_SIGNED return STRING]; + alias TO_BSTRING is TO_STRING [UNRESOLVED_UNSIGNED return STRING]; + alias TO_BSTRING is TO_STRING [UNRESOLVED_SIGNED return STRING]; + alias to_binary_string is TO_STRING [UNRESOLVED_UNSIGNED return STRING]; + alias to_binary_string is TO_STRING [UNRESOLVED_SIGNED return STRING]; - function to_ostring (value : UNRESOLVED_UNSIGNED) return STRING; - function to_ostring (value : UNRESOLVED_SIGNED) return STRING; - alias to_octal_string is to_ostring [UNRESOLVED_UNSIGNED return STRING]; - alias to_octal_string is to_ostring [UNRESOLVED_SIGNED return STRING]; + function TO_OSTRING (value : UNRESOLVED_UNSIGNED) return STRING; + function TO_OSTRING (value : UNRESOLVED_SIGNED) return STRING; + alias to_octal_string is TO_OSTRING [UNRESOLVED_UNSIGNED return STRING]; + alias to_octal_string is TO_OSTRING [UNRESOLVED_SIGNED return STRING]; function to_hstring (value : UNRESOLVED_UNSIGNED) return STRING; function to_hstring (value : UNRESOLVED_SIGNED) return STRING; diff --git a/libraries/ieee2008/numeric_std_unsigned-body.vhdl b/libraries/ieee2008/numeric_std_unsigned-body.vhdl index cb01bc0f1..32a652920 100644 --- a/libraries/ieee2008/numeric_std_unsigned-body.vhdl +++ b/libraries/ieee2008/numeric_std_unsigned-body.vhdl @@ -1,592 +1,595 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. --- --- Title : Standard VHDL Synthesis Packages --- : (NUMERIC_STD_UNSIGNED package body) --- : --- Library : This package shall be compiled into a library --- : symbolically named IEEE. --- : --- Developers: Accellera VHDL-TC, and IEEE P1076 Working Group --- : --- Purpose : This package defines numeric types and arithmetic functions --- : for use with synthesis tools. Values of type STD_ULOGIC_VECTOR --- : are interpreted as unsigned numbers in vector form. --- : The leftmost bit is treated as the most significant bit. --- : This package contains overloaded arithmetic operators on --- : the STD_ULOGIC_VECTOR type. The package also contains --- : useful type conversions functions, clock detection --- : functions, and other utility functions. --- : --- : If any argument to a function is a null array, a null array --- : is returned (exceptions, if any, are noted individually). --- --- Note : This package may be modified to include additional data --- : required by tools, but it must in no way change the --- : external interfaces or simulation behavior of the --- : description. It is permissible to add comments and/or --- : attributes to the package declarations, but not to change --- : or delete any original lines of the package declaration. --- : The package body may be changed only in accordance with --- : the terms of Clause 16 of this standard. --- : --- -------------------------------------------------------------------- --- $Revision: 1220 $ --- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ --- -------------------------------------------------------------------- - -library ieee; -use ieee.numeric_std.all; - -package body NUMERIC_STD_UNSIGNED is - - -- Id: A.3 - function "+" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) + UNSIGNED(R)); - end function "+"; - - -- Id: A.3R - function "+"(L : STD_ULOGIC_VECTOR; R : STD_ULOGIC) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) + R); - end function "+"; - - -- Id: A.3L - function "+"(L : STD_ULOGIC; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (L + UNSIGNED(R)); - end function "+"; - - -- Id: A.5 - function "+" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) + R); - end function "+"; - - -- Id: A.6 - function "+" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (L + UNSIGNED(R)); - end function "+"; - - --============================================================================ - - -- Id: A.9 - function "-" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) - UNSIGNED(R)); - end function "-"; - - -- Id: A.9R - function "-"(L : STD_ULOGIC_VECTOR; R : STD_ULOGIC) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) - R); - end function "-"; - - -- Id: A.9L - function "-"(L : STD_ULOGIC; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (L - UNSIGNED(R)); - end function "-"; - - -- Id: A.11 - function "-" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) - R); - end function "-"; - - -- Id: A.12 - function "-" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (L - UNSIGNED(R)); - end function "-"; - - --============================================================================ - - -- Id: A.15 - function "*" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) * UNSIGNED(R)); - end function "*"; - - -- Id: A.17 - function "*" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) * R); - end function "*"; - - -- Id: A.18 - function "*" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (L * UNSIGNED(R)); - end function "*"; - - --============================================================================ - - -- Id: A.21 - function "/" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) / UNSIGNED(R)); - end function "/"; - - -- Id: A.23 - function "/" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) / R); - end function "/"; - - -- Id: A.24 - function "/" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (L / UNSIGNED(R)); - end function "/"; - - --============================================================================ - - -- Id: A.27 - function "rem" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) rem UNSIGNED(R)); - end function "rem"; - - -- Id: A.29 - function "rem" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) rem R); - end function "rem"; - - -- Id: A.30 - function "rem" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (L rem UNSIGNED(R)); - end function "rem"; - - --============================================================================ - - -- Id: A.33 - function "mod" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) mod UNSIGNED(R)); - end function "mod"; - - -- Id: A.35 - function "mod" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(L) mod R); - end function "mod"; - - -- Id: A.36 - function "mod" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (L mod UNSIGNED(R)); - end function "mod"; - - --============================================================================ - -- Id: A.39 - function find_leftmost (ARG: STD_ULOGIC_VECTOR; Y: STD_ULOGIC) return INTEGER is - begin - return find_leftmost(UNSIGNED(ARG), Y); - end function find_leftmost; - - -- Id: A.41 - function find_rightmost (ARG: STD_ULOGIC_VECTOR; Y: STD_ULOGIC) return INTEGER is - begin - return find_rightmost(UNSIGNED(ARG), Y); - end function find_rightmost; - - --============================================================================ - - -- Id: C.1 - function ">" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN is - begin - return UNSIGNED(L) > UNSIGNED(R); - end function ">"; - - -- Id: C.3 - function ">" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN is - begin - return L > UNSIGNED(R); - end function ">"; - - -- Id: C.5 - function ">" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN is - begin - return UNSIGNED(L) > R; - end function ">"; - - --============================================================================ - - -- Id: C.7 - function "<" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN is - begin - return UNSIGNED(L) < UNSIGNED(R); - end function "<"; - - -- Id: C.9 - function "<" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN is - begin - return L < UNSIGNED(R); - end function "<"; - - -- Id: C.11 - function "<" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN is - begin - return UNSIGNED(L) < R; - end function "<"; - - --============================================================================ - - -- Id: C.13 - function "<=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN is - begin - return UNSIGNED(L) <= UNSIGNED(R); - end function "<="; - - -- Id: C.15 - function "<=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN is - begin - return L <= UNSIGNED(R); - end function "<="; - - -- Id: C.17 - function "<=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN is - begin - return UNSIGNED(L) <= R; - end function "<="; - - --============================================================================ - - -- Id: C.19 - function ">=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN is - begin - return UNSIGNED(L) >= UNSIGNED(R); - end function ">="; - - -- Id: C.21 - function ">=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN is - begin - return L >= UNSIGNED(R); - end function ">="; - - -- Id: C.23 - function ">=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN is - begin - return UNSIGNED(L) >= R; - end function ">="; - - --============================================================================ - - -- Id: C.25 - function "=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN is - begin - return UNSIGNED(L) = UNSIGNED(R); - end function "="; - - -- Id: C.27 - function "=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN is - begin - return L = UNSIGNED(R); - end function "="; - - -- Id: C.29 - function "=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN is - begin - return UNSIGNED(L) = R; - end function "="; - - --============================================================================ - - -- Id: C.31 - function "/=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN is - begin - return UNSIGNED(L) /= UNSIGNED(R); - end function "/="; - - -- Id: C.33 - function "/=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN is - begin - return L /= UNSIGNED(R); - end function "/="; - - -- Id: C.35 - function "/=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN is - begin - return UNSIGNED(L) /= R; - end function "/="; - - --============================================================================ - - -- Id: C.37 - function MINIMUM (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (MINIMUM(UNSIGNED(L), UNSIGNED(R))); - end function MINIMUM; - - -- Id: C.39 - function MINIMUM (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (MINIMUM(L, UNSIGNED(R))); - end function MINIMUM; - - -- Id: C.41 - function MINIMUM (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (MINIMUM(UNSIGNED(L), R)); - end function MINIMUM; - - --============================================================================ - -- Id: C.43 - function MAXIMUM (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (MAXIMUM(UNSIGNED(L), UNSIGNED(R))); - end function MAXIMUM; - - -- Id: C.45 - function MAXIMUM (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (MAXIMUM(L, UNSIGNED(R))); - end function MAXIMUM; - - -- Id: C.47 - function MAXIMUM (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (MAXIMUM(UNSIGNED(L), R)); - end function MAXIMUM; - - --============================================================================ - - -- Id: C.49 - function "?>" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC is - begin - return UNSIGNED(L) ?> UNSIGNED(R); - end function "?>"; - - -- Id: C.51 - function "?>" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC is - begin - return L ?> UNSIGNED(R); - end function "?>"; - - -- Id: C.53 - function "?>" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC is - begin - return UNSIGNED(L) ?> R; - end function "?>"; - - --============================================================================ - - -- Id: C.55 - function "?<" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC is - begin - return UNSIGNED(L) ?< UNSIGNED(R); - end function "?<"; - - -- Id: C.57 - function "?<" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC is - begin - return L ?< UNSIGNED(R); - end function "?<"; - - -- Id: C.59 - function "?<" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC is - begin - return UNSIGNED(L) ?< R; - end function "?<"; - - --============================================================================ - - -- Id: C.61 - function "?<=" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC is - begin - return UNSIGNED(L) ?<= UNSIGNED(R); - end function "?<="; - - -- Id: C.63 - function "?<=" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC is - begin - return L ?<= UNSIGNED(R); - end function "?<="; - - -- Id: C.65 - function "?<=" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC is - begin - return UNSIGNED(L) ?<= R; - end function "?<="; - - --============================================================================ - - -- Id: C.67 - function "?>=" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC is - begin - return UNSIGNED(L) ?>= UNSIGNED(R); - end function "?>="; - - -- Id: C.69 - function "?>=" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC is - begin - return L ?>= UNSIGNED(R); - end function "?>="; - - -- Id: C.71 - function "?>=" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC is - begin - return UNSIGNED(L) ?>= R; - end function "?>="; - - --============================================================================ - - -- Id: C.73 - function "?=" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC is - begin - return UNSIGNED(L) ?= UNSIGNED(R); - end function "?="; - - -- Id: C.75 - function "?=" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC is - begin - return L ?= UNSIGNED(R); - end function "?="; - - -- Id: C.77 - function "?=" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC is - begin - return UNSIGNED(L) ?= R; - end function "?="; - - --============================================================================ - - -- Id: C.79 - function "?/=" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC is - begin - return UNSIGNED(L) ?/= UNSIGNED(R); - end function "?/="; - - -- Id: C.81 - function "?/=" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC is - begin - return L ?/= UNSIGNED(R); - end function "?/="; - - -- Id: C.83 - function "?/=" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC is - begin - return UNSIGNED(L) ?/= R; - end function "?/="; - - --============================================================================ - - -- Id: S.1 - function SHIFT_LEFT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) - return STD_ULOGIC_VECTOR is - begin - return std_logic_vector (SHIFT_LEFT(unsigned(ARG), COUNT)); - end function SHIFT_LEFT; - - -- Id: S.2 - function SHIFT_RIGHT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) - return STD_ULOGIC_VECTOR is - begin - return std_logic_vector (SHIFT_RIGHT(unsigned(ARG), COUNT)); - end function SHIFT_RIGHT; - - --============================================================================ - - -- Id: S.5 - function ROTATE_LEFT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) - return STD_ULOGIC_VECTOR is - begin - return std_logic_vector (ROTATE_LEFT(unsigned(ARG), COUNT)); - end function ROTATE_LEFT; - - -- Id: S.6 - function ROTATE_RIGHT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) - return STD_ULOGIC_VECTOR is - begin - return std_logic_vector (ROTATE_RIGHT(unsigned(ARG), COUNT)); - end function ROTATE_RIGHT; - - --============================================================================ - - -- Id: S.17 - function "sla" (ARG: STD_ULOGIC_VECTOR; COUNT: INTEGER) - return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(ARG) sla COUNT); - end function "sla"; - - -- Id: S.19 - function "sra" (ARG: STD_ULOGIC_VECTOR; COUNT: INTEGER) - return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (UNSIGNED(ARG) sra COUNT); - end function "sra"; - - --============================================================================ - - -- Id: R.2 - function RESIZE (ARG : STD_ULOGIC_VECTOR; NEW_SIZE : NATURAL) - return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR ( - RESIZE (ARG => UNSIGNED(ARG), - NEW_SIZE => NEW_SIZE)); - end function RESIZE; - - function RESIZE (ARG, SIZE_RES : STD_ULOGIC_VECTOR) - return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR ( - RESIZE (ARG => UNSIGNED(ARG), - NEW_SIZE => SIZE_RES'length)); - end function RESIZE; - - --============================================================================ - - -- Id: D.1 - function TO_INTEGER (ARG : STD_ULOGIC_VECTOR) return NATURAL is - begin - return TO_INTEGER(UNSIGNED(ARG)); - end function TO_INTEGER; - - -- Id: D.3 - function To_StdLogicVector (ARG, SIZE : NATURAL) return STD_LOGIC_VECTOR is - begin - return STD_LOGIC_VECTOR (TO_UNSIGNED(ARG => ARG, - SIZE => SIZE)); - end function To_StdLogicVector; - - -- Id: D.5 - function To_StdULogicVector (ARG, SIZE : NATURAL) return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (TO_UNSIGNED(ARG => ARG, - SIZE => SIZE)); - end function To_StdULogicVector; - - function To_StdLogicVector (ARG : NATURAL; SIZE_RES : STD_ULOGIC_VECTOR) - return STD_LOGIC_VECTOR is - begin - return STD_LOGIC_VECTOR (TO_UNSIGNED (ARG => ARG, - SIZE => SIZE_RES'length)); - end function To_StdLogicVector; - - function To_StdULogicVector (ARG : NATURAL; SIZE_RES : STD_ULOGIC_VECTOR) - return STD_ULOGIC_VECTOR is - begin - return STD_ULOGIC_VECTOR (TO_UNSIGNED (ARG => ARG, - SIZE => SIZE_RES'length)); - end function To_StdULogicVector; - -end package body NUMERIC_STD_UNSIGNED; +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. +-- +-- Title : Standard VHDL Synthesis Packages +-- : (NUMERIC_STD_UNSIGNED package body) +-- : +-- Library : This package shall be compiled into a library +-- : symbolically named IEEE. +-- : +-- Developers: Accellera VHDL-TC, and IEEE P1076 Working Group +-- : +-- Purpose : This package defines numeric types and arithmetic functions +-- : for use with synthesis tools. Values of type STD_ULOGIC_VECTOR +-- : are interpreted as unsigned numbers in vector form. +-- : The leftmost bit is treated as the most significant bit. +-- : This package contains overloaded arithmetic operators on +-- : the STD_ULOGIC_VECTOR type. The package also contains +-- : useful type conversions functions, clock detection +-- : functions, and other utility functions. +-- : +-- : If any argument to a function is a null array, a null array +-- : is returned (exceptions, if any, are noted individually). +-- +-- Note : This package may be modified to include additional data +-- : required by tools, but it must in no way change the +-- : external interfaces or simulation behavior of the +-- : description. It is permissible to add comments and/or +-- : attributes to the package declarations, but not to change +-- : or delete any original lines of the package declaration. +-- : The package body may be changed only in accordance with +-- : the terms of Clause 16 of this standard. +-- : +-- -------------------------------------------------------------------- +-- $Revision: 1220 $ +-- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ +-- -------------------------------------------------------------------- + +library ieee; +use ieee.numeric_std.all; + +package body NUMERIC_STD_UNSIGNED is + + -- Id: A.3 + function "+" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) + UNSIGNED(R)); + end function "+"; + + -- Id: A.3R + function "+"(L : STD_ULOGIC_VECTOR; R : STD_ULOGIC) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) + R); + end function "+"; + + -- Id: A.3L + function "+"(L : STD_ULOGIC; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (L + UNSIGNED(R)); + end function "+"; + + -- Id: A.5 + function "+" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) + R); + end function "+"; + + -- Id: A.6 + function "+" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (L + UNSIGNED(R)); + end function "+"; + + --============================================================================ + + -- Id: A.9 + function "-" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) - UNSIGNED(R)); + end function "-"; + + -- Id: A.9R + function "-"(L : STD_ULOGIC_VECTOR; R : STD_ULOGIC) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) - R); + end function "-"; + + -- Id: A.9L + function "-"(L : STD_ULOGIC; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (L - UNSIGNED(R)); + end function "-"; + + -- Id: A.11 + function "-" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) - R); + end function "-"; + + -- Id: A.12 + function "-" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (L - UNSIGNED(R)); + end function "-"; + + --============================================================================ + + -- Id: A.15 + function "*" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) * UNSIGNED(R)); + end function "*"; + + -- Id: A.17 + function "*" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) * R); + end function "*"; + + -- Id: A.18 + function "*" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (L * UNSIGNED(R)); + end function "*"; + + --============================================================================ + + -- Id: A.21 + function "/" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) / UNSIGNED(R)); + end function "/"; + + -- Id: A.23 + function "/" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) / R); + end function "/"; + + -- Id: A.24 + function "/" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (L / UNSIGNED(R)); + end function "/"; + + --============================================================================ + + -- Id: A.27 + function "rem" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) rem UNSIGNED(R)); + end function "rem"; + + -- Id: A.29 + function "rem" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) rem R); + end function "rem"; + + -- Id: A.30 + function "rem" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (L rem UNSIGNED(R)); + end function "rem"; + + --============================================================================ + + -- Id: A.33 + function "mod" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) mod UNSIGNED(R)); + end function "mod"; + + -- Id: A.35 + function "mod" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(L) mod R); + end function "mod"; + + -- Id: A.36 + function "mod" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (L mod UNSIGNED(R)); + end function "mod"; + + --============================================================================ + -- Id: A.39 + function find_leftmost (ARG: STD_ULOGIC_VECTOR; Y: STD_ULOGIC) return INTEGER is + begin + return find_leftmost(UNSIGNED(ARG), Y); + end function find_leftmost; + + -- Id: A.41 + function find_rightmost (ARG: STD_ULOGIC_VECTOR; Y: STD_ULOGIC) return INTEGER is + begin + return find_rightmost(UNSIGNED(ARG), Y); + end function find_rightmost; + + --============================================================================ + + -- Id: C.1 + function ">" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN is + begin + return UNSIGNED(L) > UNSIGNED(R); + end function ">"; + + -- Id: C.3 + function ">" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN is + begin + return L > UNSIGNED(R); + end function ">"; + + -- Id: C.5 + function ">" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN is + begin + return UNSIGNED(L) > R; + end function ">"; + + --============================================================================ + + -- Id: C.7 + function "<" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN is + begin + return UNSIGNED(L) < UNSIGNED(R); + end function "<"; + + -- Id: C.9 + function "<" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN is + begin + return L < UNSIGNED(R); + end function "<"; + + -- Id: C.11 + function "<" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN is + begin + return UNSIGNED(L) < R; + end function "<"; + + --============================================================================ + + -- Id: C.13 + function "<=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN is + begin + return UNSIGNED(L) <= UNSIGNED(R); + end function "<="; + + -- Id: C.15 + function "<=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN is + begin + return L <= UNSIGNED(R); + end function "<="; + + -- Id: C.17 + function "<=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN is + begin + return UNSIGNED(L) <= R; + end function "<="; + + --============================================================================ + + -- Id: C.19 + function ">=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN is + begin + return UNSIGNED(L) >= UNSIGNED(R); + end function ">="; + + -- Id: C.21 + function ">=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN is + begin + return L >= UNSIGNED(R); + end function ">="; + + -- Id: C.23 + function ">=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN is + begin + return UNSIGNED(L) >= R; + end function ">="; + + --============================================================================ + + -- Id: C.25 + function "=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN is + begin + return UNSIGNED(L) = UNSIGNED(R); + end function "="; + + -- Id: C.27 + function "=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN is + begin + return L = UNSIGNED(R); + end function "="; + + -- Id: C.29 + function "=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN is + begin + return UNSIGNED(L) = R; + end function "="; + + --============================================================================ + + -- Id: C.31 + function "/=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN is + begin + return UNSIGNED(L) /= UNSIGNED(R); + end function "/="; + + -- Id: C.33 + function "/=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN is + begin + return L /= UNSIGNED(R); + end function "/="; + + -- Id: C.35 + function "/=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN is + begin + return UNSIGNED(L) /= R; + end function "/="; + + --============================================================================ + + -- Id: C.37 + function MINIMUM (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (MINIMUM(UNSIGNED(L), UNSIGNED(R))); + end function MINIMUM; + + -- Id: C.39 + function MINIMUM (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (MINIMUM(L, UNSIGNED(R))); + end function MINIMUM; + + -- Id: C.41 + function MINIMUM (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (MINIMUM(UNSIGNED(L), R)); + end function MINIMUM; + + --============================================================================ + -- Id: C.43 + function MAXIMUM (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (MAXIMUM(UNSIGNED(L), UNSIGNED(R))); + end function MAXIMUM; + + -- Id: C.45 + function MAXIMUM (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (MAXIMUM(L, UNSIGNED(R))); + end function MAXIMUM; + + -- Id: C.47 + function MAXIMUM (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (MAXIMUM(UNSIGNED(L), R)); + end function MAXIMUM; + + --============================================================================ + + -- Id: C.49 + function "?>" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC is + begin + return UNSIGNED(L) ?> UNSIGNED(R); + end function "?>"; + + -- Id: C.51 + function "?>" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC is + begin + return L ?> UNSIGNED(R); + end function "?>"; + + -- Id: C.53 + function "?>" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC is + begin + return UNSIGNED(L) ?> R; + end function "?>"; + + --============================================================================ + + -- Id: C.55 + function "?<" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC is + begin + return UNSIGNED(L) ?< UNSIGNED(R); + end function "?<"; + + -- Id: C.57 + function "?<" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC is + begin + return L ?< UNSIGNED(R); + end function "?<"; + + -- Id: C.59 + function "?<" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC is + begin + return UNSIGNED(L) ?< R; + end function "?<"; + + --============================================================================ + + -- Id: C.61 + function "?<=" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC is + begin + return UNSIGNED(L) ?<= UNSIGNED(R); + end function "?<="; + + -- Id: C.63 + function "?<=" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC is + begin + return L ?<= UNSIGNED(R); + end function "?<="; + + -- Id: C.65 + function "?<=" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC is + begin + return UNSIGNED(L) ?<= R; + end function "?<="; + + --============================================================================ + + -- Id: C.67 + function "?>=" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC is + begin + return UNSIGNED(L) ?>= UNSIGNED(R); + end function "?>="; + + -- Id: C.69 + function "?>=" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC is + begin + return L ?>= UNSIGNED(R); + end function "?>="; + + -- Id: C.71 + function "?>=" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC is + begin + return UNSIGNED(L) ?>= R; + end function "?>="; + + --============================================================================ + + -- Id: C.73 + function "?=" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC is + begin + return UNSIGNED(L) ?= UNSIGNED(R); + end function "?="; + + -- Id: C.75 + function "?=" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC is + begin + return L ?= UNSIGNED(R); + end function "?="; + + -- Id: C.77 + function "?=" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC is + begin + return UNSIGNED(L) ?= R; + end function "?="; + + --============================================================================ + + -- Id: C.79 + function "?/=" (L, R: STD_ULOGIC_VECTOR) return STD_ULOGIC is + begin + return UNSIGNED(L) ?/= UNSIGNED(R); + end function "?/="; + + -- Id: C.81 + function "?/=" (L: NATURAL; R: STD_ULOGIC_VECTOR) return STD_ULOGIC is + begin + return L ?/= UNSIGNED(R); + end function "?/="; + + -- Id: C.83 + function "?/=" (L: STD_ULOGIC_VECTOR; R: NATURAL) return STD_ULOGIC is + begin + return UNSIGNED(L) ?/= R; + end function "?/="; + + --============================================================================ + + -- Id: S.1 + function SHIFT_LEFT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) + return STD_ULOGIC_VECTOR is + begin + return std_logic_vector (SHIFT_LEFT(unsigned(ARG), COUNT)); + end function SHIFT_LEFT; + + -- Id: S.2 + function SHIFT_RIGHT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) + return STD_ULOGIC_VECTOR is + begin + return std_logic_vector (SHIFT_RIGHT(unsigned(ARG), COUNT)); + end function SHIFT_RIGHT; + + --============================================================================ + + -- Id: S.5 + function ROTATE_LEFT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) + return STD_ULOGIC_VECTOR is + begin + return std_logic_vector (ROTATE_LEFT(unsigned(ARG), COUNT)); + end function ROTATE_LEFT; + + -- Id: S.6 + function ROTATE_RIGHT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) + return STD_ULOGIC_VECTOR is + begin + return std_logic_vector (ROTATE_RIGHT(unsigned(ARG), COUNT)); + end function ROTATE_RIGHT; + + --============================================================================ + + -- Id: S.17 + function "sla" (ARG: STD_ULOGIC_VECTOR; COUNT: INTEGER) + return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(ARG) sla COUNT); + end function "sla"; + + -- Id: S.19 + function "sra" (ARG: STD_ULOGIC_VECTOR; COUNT: INTEGER) + return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (UNSIGNED(ARG) sra COUNT); + end function "sra"; + + --============================================================================ + + -- Id: R.2 + function RESIZE (ARG : STD_ULOGIC_VECTOR; NEW_SIZE : NATURAL) + return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR ( + RESIZE (ARG => UNSIGNED(ARG), + NEW_SIZE => NEW_SIZE)); + end function RESIZE; + + function RESIZE (ARG, SIZE_RES : STD_ULOGIC_VECTOR) + return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR ( + RESIZE (ARG => UNSIGNED(ARG), + NEW_SIZE => SIZE_RES'length)); + end function RESIZE; + + --============================================================================ + + -- Id: D.1 + function TO_INTEGER (ARG : STD_ULOGIC_VECTOR) return NATURAL is + begin + return TO_INTEGER(UNSIGNED(ARG)); + end function TO_INTEGER; + + -- Id: D.3 + function To_StdLogicVector (ARG, SIZE : NATURAL) return STD_LOGIC_VECTOR is + begin + return STD_LOGIC_VECTOR (TO_UNSIGNED(ARG => ARG, + SIZE => SIZE)); + end function To_StdLogicVector; + + -- Id: D.5 + function To_StdULogicVector (ARG, SIZE : NATURAL) return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (TO_UNSIGNED(ARG => ARG, + SIZE => SIZE)); + end function To_StdULogicVector; + + function To_StdLogicVector (ARG : NATURAL; SIZE_RES : STD_ULOGIC_VECTOR) + return STD_LOGIC_VECTOR is + begin + return STD_LOGIC_VECTOR (TO_UNSIGNED (ARG => ARG, + SIZE => SIZE_RES'length)); + end function To_StdLogicVector; + + function To_StdULogicVector (ARG : NATURAL; SIZE_RES : STD_ULOGIC_VECTOR) + return STD_ULOGIC_VECTOR is + begin + return STD_ULOGIC_VECTOR (TO_UNSIGNED (ARG => ARG, + SIZE => SIZE_RES'length)); + end function To_StdULogicVector; + +end package body NUMERIC_STD_UNSIGNED; diff --git a/libraries/ieee2008/numeric_std_unsigned.vhdl b/libraries/ieee2008/numeric_std_unsigned.vhdl index b9359e0eb..eb6589834 100644 --- a/libraries/ieee2008/numeric_std_unsigned.vhdl +++ b/libraries/ieee2008/numeric_std_unsigned.vhdl @@ -1,613 +1,616 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. --- --- Title : Standard VHDL Synthesis Packages --- : (NUMERIC_STD_UNSIGNED package declaration) --- : --- Library : This package shall be compiled into a library --- : symbolically named IEEE. --- : --- Developers: Accellera VHDL-TC, and IEEE P1076 Working Group --- : --- Purpose : This package defines numeric types and arithmetic functions --- : for use with synthesis tools. Values of type STD_ULOGIC_VECTOR --- : are interpreted as unsigned numbers in vector form. --- : The leftmost bit is treated as the most significant bit. --- : This package contains overloaded arithmetic operators on --- : the STD_ULOGIC_VECTOR type. The package also contains --- : useful type conversions functions, clock detection --- : functions, and other utility functions. --- : --- : If any argument to a function is a null array, a null array --- : is returned (exceptions, if any, are noted individually). --- --- Note : This package may be modified to include additional data --- : required by tools, but it must in no way change the --- : external interfaces or simulation behavior of the --- : description. It is permissible to add comments and/or --- : attributes to the package declarations, but not to change --- : or delete any original lines of the package declaration. --- : The package body may be changed only in accordance with --- : the terms of Clause 16 of this standard. --- : --- -------------------------------------------------------------------- --- $Revision: 1220 $ --- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ --- -------------------------------------------------------------------- - -library IEEE; -use IEEE.STD_LOGIC_1164.all; -package NUMERIC_STD_UNSIGNED is - constant CopyRightNotice : STRING := - "Copyright 2008 IEEE. All rights reserved."; - - -- Id: A.3 - function "+" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(MAXIMUM(L'LENGTH, R'LENGTH)-1 downto 0). - -- Result: Adds two UNSIGNED vectors that may be of different lengths. - - -- Id: A.3R - function "+"(L : STD_ULOGIC_VECTOR; R : STD_ULOGIC) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0) - -- Result: Similar to A.3 where R is a one bit STD_ULOGIC_VECTOR - - -- Id: A.3L - function "+"(L : STD_ULOGIC; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) - -- Result: Similar to A.3 where L is a one bit UNSIGNED - - -- Id: A.5 - function "+" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0). - -- Result: Adds an UNSIGNED vector, L, with a non-negative INTEGER, R. - - -- Id: A.6 - function "+" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0). - -- Result: Adds a non-negative INTEGER, L, with an UNSIGNED vector, R. - - --============================================================================ - - -- Id: A.9 - function "-" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: UNSIGNED(MAXIMUM(L'LENGTH, R'LENGTH)-1 downto 0). - -- Result: Subtracts two UNSIGNED vectors that may be of different lengths. - - -- Id: A.9R - function "-"(L : STD_ULOGIC_VECTOR; R : STD_ULOGIC) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0) - -- Result: Similar to A.9 where R is a one bit UNSIGNED - - -- Id: A.9L - function "-"(L : STD_ULOGIC; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) - -- Result: Similar to A.9 where L is a one bit UNSIGNED - - -- Id: A.11 - function "-" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0). - -- Result: Subtracts a non-negative INTEGER, R, from an UNSIGNED vector, L. - - -- Id: A.12 - function "-" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0). - -- Result: Subtracts an UNSIGNED vector, R, from a non-negative INTEGER, L. - - --============================================================================ - - -- Id: A.15 - function "*" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR((L'LENGTH+R'LENGTH-1) downto 0). - -- Result: Performs the multiplication operation on two UNSIGNED vectors - -- that may possibly be of different lengths. - - -- Id: A.17 - function "*" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR((L'LENGTH+L'LENGTH-1) downto 0). - -- Result: Multiplies an UNSIGNED vector, L, with a non-negative - -- INTEGER, R. R is converted to an UNSIGNED vector of - -- SIZE L'LENGTH before multiplication. - - -- Id: A.18 - function "*" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR((R'LENGTH+R'LENGTH-1) downto 0). - -- Result: Multiplies an UNSIGNED vector, R, with a non-negative - -- INTEGER, L. L is converted to an UNSIGNED vector of - -- SIZE R'LENGTH before multiplication. - - --============================================================================ - -- - -- NOTE: If second argument is zero for "/" operator, a severity level - -- of ERROR is issued. - - -- Id: A.21 - function "/" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0) - -- Result: Divides an UNSIGNED vector, L, by another UNSIGNED vector, R. - - -- Id: A.23 - function "/" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0) - -- Result: Divides an UNSIGNED vector, L, by a non-negative INTEGER, R. - -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. - - -- Id: A.24 - function "/" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) - -- Result: Divides a non-negative INTEGER, L, by an UNSIGNED vector, R. - -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. - - --============================================================================ - -- - -- NOTE: If second argument is zero for "rem" operator, a severity level - -- of ERROR is issued. - - -- Id: A.27 - function "rem" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) - -- Result: Computes "L rem R" where L and R are UNSIGNED vectors. - - -- Id: A.29 - function "rem" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0) - -- Result: Computes "L rem R" where L is an UNSIGNED vector and R is a - -- non-negative INTEGER. - -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. - - -- Id: A.30 - function "rem" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) - -- Result: Computes "L rem R" where R is an UNSIGNED vector and L is a - -- non-negative INTEGER. - -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. - - --============================================================================ - -- - -- NOTE: If second argument is zero for "mod" operator, a severity level - -- of ERROR is issued. - - -- Id: A.33 - function "mod" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) - -- Result: Computes "L mod R" where L and R are UNSIGNED vectors. - - -- Id: A.35 - function "mod" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0) - -- Result: Computes "L mod R" where L is an UNSIGNED vector and R - -- is a non-negative INTEGER. - -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. - - -- Id: A.36 - function "mod" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) - -- Result: Computes "L mod R" where R is an UNSIGNED vector and L - -- is a non-negative INTEGER. - -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. - - --============================================================================ - -- Id: A.39 - function find_leftmost (ARG : STD_ULOGIC_VECTOR; Y : STD_ULOGIC) return INTEGER; - -- Result subtype: INTEGER - -- Result: Finds the leftmost occurrence of the value of Y in ARG. - -- Returns the index of the occurrence if it exists, or -1 otherwise. - - -- Id: A.41 - function find_rightmost (ARG : STD_ULOGIC_VECTOR; Y : STD_ULOGIC) return INTEGER; - -- Result subtype: INTEGER - -- Result: Finds the leftmost occurrence of the value of Y in ARG. - -- Returns the index of the occurrence if it exists, or -1 otherwise. - - --============================================================================ - -- Comparison Operators - --============================================================================ - - -- Id: C.1 - function ">" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L > R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.3 - function ">" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L > R" where L is a non-negative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.5 - function ">" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L > R" where L is an UNSIGNED vector and - -- R is a non-negative INTEGER. - - --============================================================================ - - -- Id: C.7 - function "<" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L < R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.9 - function "<" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L < R" where L is a non-negative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.11 - function "<" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L < R" where L is an UNSIGNED vector and - -- R is a non-negative INTEGER. - - --============================================================================ - - -- Id: C.13 - function "<=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L <= R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.15 - function "<=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L <= R" where L is a non-negative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.17 - function "<=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L <= R" where L is an UNSIGNED vector and - -- R is a non-negative INTEGER. - - --============================================================================ - - -- Id: C.19 - function ">=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L >= R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.21 - function ">=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L >= R" where L is a non-negative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.23 - function ">=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L >= R" where L is an UNSIGNED vector and - -- R is a non-negative INTEGER. - - --============================================================================ - - -- Id: C.25 - function "=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L = R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.27 - function "=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L = R" where L is a non-negative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.29 - function "=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L = R" where L is an UNSIGNED vector and - -- R is a non-negative INTEGER. - - --============================================================================ - - -- Id: C.31 - function "/=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L /= R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.33 - function "/=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L /= R" where L is a non-negative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.35 - function "/=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN; - -- Result subtype: BOOLEAN - -- Result: Computes "L /= R" where L is an UNSIGNED vector and - -- R is a non-negative INTEGER. - - --============================================================================ - - -- Id: C.37 - function MINIMUM (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR - -- Result: Returns the lesser of two UNSIGNED vectors that may be - -- of different lengths. - - -- Id: C.39 - function MINIMUM (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR - -- Result: Returns the lesser of a nonnegative INTEGER, L, and - -- an UNSIGNED vector, R. - - -- Id: C.41 - function MINIMUM (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR - -- Result: Returns the lesser of an UNSIGNED vector, L, and - -- a nonnegative INTEGER, R. - - --============================================================================ - - -- Id: C.43 - function MAXIMUM (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR - -- Result: Returns the greater of two UNSIGNED vectors that may be - -- of different lengths. - - -- Id: C.45 - function MAXIMUM (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR - -- Result: Returns the greater of a nonnegative INTEGER, L, and - -- an UNSIGNED vector, R. - - -- Id: C.47 - function MAXIMUM (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR - -- Result: Returns the greater of an UNSIGNED vector, L, and - -- a nonnegative INTEGER, R. - - --============================================================================ - -- Id: C.49 - function "?>" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L > R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.51 - function "?>" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L > R" where L is a nonnegative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.53 - function "?>" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L > R" where L is an UNSIGNED vector and - -- R is a nonnegative INTEGER. - - --============================================================================ - - -- Id: C.55 - function "?<" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L < R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.57 - function "?<" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L < R" where L is a nonnegative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.59 - function "?<" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L < R" where L is an UNSIGNED vector and - -- R is a nonnegative INTEGER. - - --============================================================================ - - -- Id: C.61 - function "?<=" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L <= R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.63 - function "?<=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L <= R" where L is a nonnegative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.65 - function "?<=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L <= R" where L is an UNSIGNED vector and - -- R is a nonnegative INTEGER. - - --============================================================================ - - -- Id: C.67 - function "?>=" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L >= R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.69 - function "?>=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L >= R" where L is a nonnegative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.71 - function "?>=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L >= R" where L is an UNSIGNED vector and - -- R is a nonnegative INTEGER. - - --============================================================================ - - -- Id: C.73 - function "?=" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L = R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.75 - function "?=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L = R" where L is a nonnegative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.77 - function "?=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L = R" where L is an UNSIGNED vector and - -- R is a nonnegative INTEGER. - - --============================================================================ - - -- Id: C.79 - function "?/=" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L /= R" where L and R are UNSIGNED vectors possibly - -- of different lengths. - - -- Id: C.81 - function "?/=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L /= R" where L is a nonnegative INTEGER and - -- R is an UNSIGNED vector. - - -- Id: C.83 - function "?/=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC; - -- Result subtype: STD_ULOGIC - -- Result: Computes "L /= R" where L is an UNSIGNED vector and - -- R is a nonnegative INTEGER. - - --============================================================================ - -- Shift and Rotate Functions - --============================================================================ - - -- Id: S.1 - function SHIFT_LEFT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) - return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(ARG'LENGTH-1 downto 0) - -- Result: Performs a shift-left on an UNSIGNED vector COUNT times. - -- The vacated positions are filled with '0'. - -- The COUNT leftmost elements are lost. - - -- Id: S.2 - function SHIFT_RIGHT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) - return STD_ULOGIC_VECTOR; - -- Result subtype: UNSIGNED(ARG'LENGTH-1 downto 0) - -- Result: Performs a shift-right on an UNSIGNED vector COUNT times. - -- The vacated positions are filled with '0'. - -- The COUNT rightmost elements are lost. - --============================================================================ - - -- Id: S.5 - function ROTATE_LEFT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) - return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(ARG'LENGTH-1 downto 0) - -- Result: Performs a rotate-left of an UNSIGNED vector COUNT times. - - -- Id: S.6 - function ROTATE_RIGHT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) - return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(ARG'LENGTH-1 downto 0) - -- Result: Performs a rotate-right of an UNSIGNED vector COUNT times. - - - --============================================================================ - - ------------------------------------------------------------------------------ - -- Note: Function S.17 is not compatible with IEEE Std 1076-1987. Comment - -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. - ------------------------------------------------------------------------------ - -- Id: S.17 - function "sla" (ARG : STD_ULOGIC_VECTOR; COUNT : INTEGER) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(ARG'LENGTH-1 downto 0) - -- Result: SHIFT_LEFT(ARG, COUNT) - - ------------------------------------------------------------------------------ - -- Note: Function S.19 is not compatible with IEEE Std 1076-1987. Comment - -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. - ------------------------------------------------------------------------------ - -- Id: S.19 - function "sra" (ARG : STD_ULOGIC_VECTOR; COUNT : INTEGER) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(ARG'LENGTH-1 downto 0) - -- Result: SHIFT_RIGHT(ARG, COUNT) - - - --============================================================================ - -- RESIZE Functions - --============================================================================ - - -- Id: R.2 - function RESIZE (ARG : STD_ULOGIC_VECTOR; NEW_SIZE : NATURAL) - return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(NEW_SIZE-1 downto 0) - -- Result: Resizes the UNSIGNED vector ARG to the specified size. - -- To create a larger vector, the new [leftmost] bit positions - -- are filled with '0'. When truncating, the leftmost bits - -- are dropped. - - function RESIZE (ARG, SIZE_RES : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR (SIZE_RES'length-1 downto 0) - - --============================================================================ - -- Conversion Functions - --============================================================================ - - -- Id: D.1 - function TO_INTEGER (ARG : STD_ULOGIC_VECTOR) return NATURAL; - -- Result subtype: NATURAL. Value cannot be negative since parameter is an - -- UNSIGNED vector. - -- Result: Converts the UNSIGNED vector to an INTEGER. - - -- Id: D.3 - function To_StdLogicVector (ARG, SIZE : NATURAL) return STD_LOGIC_VECTOR; - -- Result subtype: STD_LOGIC_VECTOR(SIZE-1 downto 0) - -- Result: Converts a non-negative INTEGER to an UNSIGNED vector with - -- the specified SIZE. - - function To_StdLogicVector (ARG : NATURAL; SIZE_RES : STD_ULOGIC_VECTOR) - return STD_LOGIC_VECTOR; - -- Result subtype: STD_LOGIC_VECTOR(SIZE_RES'length-1 downto 0) - - alias To_Std_Logic_Vector is - To_StdLogicVector[NATURAL, NATURAL return STD_LOGIC_VECTOR]; - alias To_SLV is - To_StdLogicVector[NATURAL, NATURAL return STD_LOGIC_VECTOR]; - alias To_Std_Logic_Vector is - To_StdLogicVector[NATURAL, STD_ULOGIC_VECTOR return STD_LOGIC_VECTOR]; - alias To_SLV is - To_StdLogicVector[NATURAL, STD_ULOGIC_VECTOR return STD_LOGIC_VECTOR]; - - -- Id: D.5 - function To_StdULogicVector (ARG, SIZE : NATURAL) return STD_ULOGIC_VECTOR; - -- Result subtype: STD_ULOGIC_VECTOR(SIZE-1 downto 0) - -- Result: Converts a non-negative INTEGER to an UNSIGNED vector with - -- the specified SIZE. - - function To_StdULogicVector (ARG : NATURAL; SIZE_RES : STD_ULOGIC_VECTOR) - return STD_ULOGIC_VECTOR; - -- Result subtype: STD_LOGIC_VECTOR(SIZE_RES'length-1 downto 0) - - alias To_Std_ULogic_Vector is - To_StdULogicVector[NATURAL, NATURAL return STD_ULOGIC_VECTOR]; - alias To_SULV is - To_StdULogicVector[NATURAL, NATURAL return STD_ULOGIC_VECTOR]; - alias To_Std_ULogic_Vector is - To_StdULogicVector[NATURAL, STD_ULOGIC_VECTOR return STD_ULOGIC_VECTOR]; - alias To_SULV is - To_StdULogicVector[NATURAL, STD_ULOGIC_VECTOR return STD_ULOGIC_VECTOR]; - -end package NUMERIC_STD_UNSIGNED; +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. +-- +-- Title : Standard VHDL Synthesis Packages +-- : (NUMERIC_STD_UNSIGNED package declaration) +-- : +-- Library : This package shall be compiled into a library +-- : symbolically named IEEE. +-- : +-- Developers: Accellera VHDL-TC, and IEEE P1076 Working Group +-- : +-- Purpose : This package defines numeric types and arithmetic functions +-- : for use with synthesis tools. Values of type STD_ULOGIC_VECTOR +-- : are interpreted as unsigned numbers in vector form. +-- : The leftmost bit is treated as the most significant bit. +-- : This package contains overloaded arithmetic operators on +-- : the STD_ULOGIC_VECTOR type. The package also contains +-- : useful type conversions functions, clock detection +-- : functions, and other utility functions. +-- : +-- : If any argument to a function is a null array, a null array +-- : is returned (exceptions, if any, are noted individually). +-- +-- Note : This package may be modified to include additional data +-- : required by tools, but it must in no way change the +-- : external interfaces or simulation behavior of the +-- : description. It is permissible to add comments and/or +-- : attributes to the package declarations, but not to change +-- : or delete any original lines of the package declaration. +-- : The package body may be changed only in accordance with +-- : the terms of Clause 16 of this standard. +-- : +-- -------------------------------------------------------------------- +-- $Revision: 1220 $ +-- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ +-- -------------------------------------------------------------------- + +library IEEE; +use IEEE.STD_LOGIC_1164.all; +package NUMERIC_STD_UNSIGNED is + constant CopyRightNotice : STRING := + "Copyright IEEE P1076 WG. Licensed Apache 2.0"; + + -- Id: A.3 + function "+" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(MAXIMUM(L'LENGTH, R'LENGTH)-1 downto 0). + -- Result: Adds two UNSIGNED vectors that may be of different lengths. + + -- Id: A.3R + function "+"(L : STD_ULOGIC_VECTOR; R : STD_ULOGIC) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0) + -- Result: Similar to A.3 where R is a one bit STD_ULOGIC_VECTOR + + -- Id: A.3L + function "+"(L : STD_ULOGIC; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) + -- Result: Similar to A.3 where L is a one bit UNSIGNED + + -- Id: A.5 + function "+" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0). + -- Result: Adds an UNSIGNED vector, L, with a non-negative INTEGER, R. + + -- Id: A.6 + function "+" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0). + -- Result: Adds a non-negative INTEGER, L, with an UNSIGNED vector, R. + + --============================================================================ + + -- Id: A.9 + function "-" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: UNSIGNED(MAXIMUM(L'LENGTH, R'LENGTH)-1 downto 0). + -- Result: Subtracts two UNSIGNED vectors that may be of different lengths. + + -- Id: A.9R + function "-"(L : STD_ULOGIC_VECTOR; R : STD_ULOGIC) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0) + -- Result: Similar to A.9 where R is a one bit UNSIGNED + + -- Id: A.9L + function "-"(L : STD_ULOGIC; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) + -- Result: Similar to A.9 where L is a one bit UNSIGNED + + -- Id: A.11 + function "-" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0). + -- Result: Subtracts a non-negative INTEGER, R, from an UNSIGNED vector, L. + + -- Id: A.12 + function "-" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0). + -- Result: Subtracts an UNSIGNED vector, R, from a non-negative INTEGER, L. + + --============================================================================ + + -- Id: A.15 + function "*" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR((L'LENGTH+R'LENGTH-1) downto 0). + -- Result: Performs the multiplication operation on two UNSIGNED vectors + -- that may possibly be of different lengths. + + -- Id: A.17 + function "*" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR((L'LENGTH+L'LENGTH-1) downto 0). + -- Result: Multiplies an UNSIGNED vector, L, with a non-negative + -- INTEGER, R. R is converted to an UNSIGNED vector of + -- SIZE L'LENGTH before multiplication. + + -- Id: A.18 + function "*" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR((R'LENGTH+R'LENGTH-1) downto 0). + -- Result: Multiplies an UNSIGNED vector, R, with a non-negative + -- INTEGER, L. L is converted to an UNSIGNED vector of + -- SIZE R'LENGTH before multiplication. + + --============================================================================ + -- + -- NOTE: If second argument is zero for "/" operator, a severity level + -- of ERROR is issued. + + -- Id: A.21 + function "/" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0) + -- Result: Divides an UNSIGNED vector, L, by another UNSIGNED vector, R. + + -- Id: A.23 + function "/" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0) + -- Result: Divides an UNSIGNED vector, L, by a non-negative INTEGER, R. + -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. + + -- Id: A.24 + function "/" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) + -- Result: Divides a non-negative INTEGER, L, by an UNSIGNED vector, R. + -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. + + --============================================================================ + -- + -- NOTE: If second argument is zero for "rem" operator, a severity level + -- of ERROR is issued. + + -- Id: A.27 + function "rem" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) + -- Result: Computes "L rem R" where L and R are UNSIGNED vectors. + + -- Id: A.29 + function "rem" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0) + -- Result: Computes "L rem R" where L is an UNSIGNED vector and R is a + -- non-negative INTEGER. + -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. + + -- Id: A.30 + function "rem" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) + -- Result: Computes "L rem R" where R is an UNSIGNED vector and L is a + -- non-negative INTEGER. + -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. + + --============================================================================ + -- + -- NOTE: If second argument is zero for "mod" operator, a severity level + -- of ERROR is issued. + + -- Id: A.33 + function "mod" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) + -- Result: Computes "L mod R" where L and R are UNSIGNED vectors. + + -- Id: A.35 + function "mod" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(L'LENGTH-1 downto 0) + -- Result: Computes "L mod R" where L is an UNSIGNED vector and R + -- is a non-negative INTEGER. + -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. + + -- Id: A.36 + function "mod" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(R'LENGTH-1 downto 0) + -- Result: Computes "L mod R" where R is an UNSIGNED vector and L + -- is a non-negative INTEGER. + -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. + + --============================================================================ + -- Id: A.39 + function find_leftmost (ARG : STD_ULOGIC_VECTOR; Y : STD_ULOGIC) return INTEGER; + -- Result subtype: INTEGER + -- Result: Finds the leftmost occurrence of the value of Y in ARG. + -- Returns the index of the occurrence if it exists, or -1 otherwise. + + -- Id: A.41 + function find_rightmost (ARG : STD_ULOGIC_VECTOR; Y : STD_ULOGIC) return INTEGER; + -- Result subtype: INTEGER + -- Result: Finds the leftmost occurrence of the value of Y in ARG. + -- Returns the index of the occurrence if it exists, or -1 otherwise. + + --============================================================================ + -- Comparison Operators + --============================================================================ + + -- Id: C.1 + function ">" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L > R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.3 + function ">" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L > R" where L is a non-negative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.5 + function ">" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L > R" where L is an UNSIGNED vector and + -- R is a non-negative INTEGER. + + --============================================================================ + + -- Id: C.7 + function "<" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L < R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.9 + function "<" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L < R" where L is a non-negative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.11 + function "<" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L < R" where L is an UNSIGNED vector and + -- R is a non-negative INTEGER. + + --============================================================================ + + -- Id: C.13 + function "<=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L <= R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.15 + function "<=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L <= R" where L is a non-negative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.17 + function "<=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L <= R" where L is an UNSIGNED vector and + -- R is a non-negative INTEGER. + + --============================================================================ + + -- Id: C.19 + function ">=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L >= R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.21 + function ">=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L >= R" where L is a non-negative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.23 + function ">=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L >= R" where L is an UNSIGNED vector and + -- R is a non-negative INTEGER. + + --============================================================================ + + -- Id: C.25 + function "=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L = R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.27 + function "=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L = R" where L is a non-negative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.29 + function "=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L = R" where L is an UNSIGNED vector and + -- R is a non-negative INTEGER. + + --============================================================================ + + -- Id: C.31 + function "/=" (L, R : STD_ULOGIC_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L /= R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.33 + function "/=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L /= R" where L is a non-negative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.35 + function "/=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return BOOLEAN; + -- Result subtype: BOOLEAN + -- Result: Computes "L /= R" where L is an UNSIGNED vector and + -- R is a non-negative INTEGER. + + --============================================================================ + + -- Id: C.37 + function MINIMUM (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR + -- Result: Returns the lesser of two UNSIGNED vectors that may be + -- of different lengths. + + -- Id: C.39 + function MINIMUM (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR + -- Result: Returns the lesser of a nonnegative INTEGER, L, and + -- an UNSIGNED vector, R. + + -- Id: C.41 + function MINIMUM (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR + -- Result: Returns the lesser of an UNSIGNED vector, L, and + -- a nonnegative INTEGER, R. + + --============================================================================ + + -- Id: C.43 + function MAXIMUM (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR + -- Result: Returns the greater of two UNSIGNED vectors that may be + -- of different lengths. + + -- Id: C.45 + function MAXIMUM (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR + -- Result: Returns the greater of a nonnegative INTEGER, L, and + -- an UNSIGNED vector, R. + + -- Id: C.47 + function MAXIMUM (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR + -- Result: Returns the greater of an UNSIGNED vector, L, and + -- a nonnegative INTEGER, R. + + --============================================================================ + -- Id: C.49 + function "?>" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L > R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.51 + function "?>" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L > R" where L is a nonnegative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.53 + function "?>" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L > R" where L is an UNSIGNED vector and + -- R is a nonnegative INTEGER. + + --============================================================================ + + -- Id: C.55 + function "?<" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L < R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.57 + function "?<" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L < R" where L is a nonnegative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.59 + function "?<" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L < R" where L is an UNSIGNED vector and + -- R is a nonnegative INTEGER. + + --============================================================================ + + -- Id: C.61 + function "?<=" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L <= R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.63 + function "?<=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L <= R" where L is a nonnegative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.65 + function "?<=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L <= R" where L is an UNSIGNED vector and + -- R is a nonnegative INTEGER. + + --============================================================================ + + -- Id: C.67 + function "?>=" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L >= R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.69 + function "?>=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L >= R" where L is a nonnegative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.71 + function "?>=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L >= R" where L is an UNSIGNED vector and + -- R is a nonnegative INTEGER. + + --============================================================================ + + -- Id: C.73 + function "?=" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L = R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.75 + function "?=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L = R" where L is a nonnegative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.77 + function "?=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L = R" where L is an UNSIGNED vector and + -- R is a nonnegative INTEGER. + + --============================================================================ + + -- Id: C.79 + function "?/=" (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L /= R" where L and R are UNSIGNED vectors possibly + -- of different lengths. + + -- Id: C.81 + function "?/=" (L : NATURAL; R : STD_ULOGIC_VECTOR) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L /= R" where L is a nonnegative INTEGER and + -- R is an UNSIGNED vector. + + -- Id: C.83 + function "?/=" (L : STD_ULOGIC_VECTOR; R : NATURAL) return STD_ULOGIC; + -- Result subtype: STD_ULOGIC + -- Result: Computes "L /= R" where L is an UNSIGNED vector and + -- R is a nonnegative INTEGER. + + --============================================================================ + -- Shift and Rotate Functions + --============================================================================ + + -- Id: S.1 + function SHIFT_LEFT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) + return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(ARG'LENGTH-1 downto 0) + -- Result: Performs a shift-left on an UNSIGNED vector COUNT times. + -- The vacated positions are filled with '0'. + -- The COUNT leftmost elements are lost. + + -- Id: S.2 + function SHIFT_RIGHT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) + return STD_ULOGIC_VECTOR; + -- Result subtype: UNSIGNED(ARG'LENGTH-1 downto 0) + -- Result: Performs a shift-right on an UNSIGNED vector COUNT times. + -- The vacated positions are filled with '0'. + -- The COUNT rightmost elements are lost. + --============================================================================ + + -- Id: S.5 + function ROTATE_LEFT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) + return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(ARG'LENGTH-1 downto 0) + -- Result: Performs a rotate-left of an UNSIGNED vector COUNT times. + + -- Id: S.6 + function ROTATE_RIGHT (ARG : STD_ULOGIC_VECTOR; COUNT : NATURAL) + return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(ARG'LENGTH-1 downto 0) + -- Result: Performs a rotate-right of an UNSIGNED vector COUNT times. + + + --============================================================================ + + ------------------------------------------------------------------------------ + -- Note: Function S.17 is not compatible with IEEE Std 1076-1987. Comment + -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. + ------------------------------------------------------------------------------ + -- Id: S.17 + function "sla" (ARG : STD_ULOGIC_VECTOR; COUNT : INTEGER) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(ARG'LENGTH-1 downto 0) + -- Result: SHIFT_LEFT(ARG, COUNT) + + ------------------------------------------------------------------------------ + -- Note: Function S.19 is not compatible with IEEE Std 1076-1987. Comment + -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. + ------------------------------------------------------------------------------ + -- Id: S.19 + function "sra" (ARG : STD_ULOGIC_VECTOR; COUNT : INTEGER) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(ARG'LENGTH-1 downto 0) + -- Result: SHIFT_RIGHT(ARG, COUNT) + + + --============================================================================ + -- RESIZE Functions + --============================================================================ + + -- Id: R.2 + function RESIZE (ARG : STD_ULOGIC_VECTOR; NEW_SIZE : NATURAL) + return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(NEW_SIZE-1 downto 0) + -- Result: Resizes the UNSIGNED vector ARG to the specified size. + -- To create a larger vector, the new [leftmost] bit positions + -- are filled with '0'. When truncating, the leftmost bits + -- are dropped. + + function RESIZE (ARG, SIZE_RES : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR (SIZE_RES'length-1 downto 0) + + --============================================================================ + -- Conversion Functions + --============================================================================ + + -- Id: D.1 + function TO_INTEGER (ARG : STD_ULOGIC_VECTOR) return NATURAL; + -- Result subtype: NATURAL. Value cannot be negative since parameter is an + -- UNSIGNED vector. + -- Result: Converts the UNSIGNED vector to an INTEGER. + + -- Id: D.3 + function To_StdLogicVector (ARG, SIZE : NATURAL) return STD_LOGIC_VECTOR; + -- Result subtype: STD_LOGIC_VECTOR(SIZE-1 downto 0) + -- Result: Converts a non-negative INTEGER to an UNSIGNED vector with + -- the specified SIZE. + + function To_StdLogicVector (ARG : NATURAL; SIZE_RES : STD_ULOGIC_VECTOR) + return STD_LOGIC_VECTOR; + -- Result subtype: STD_LOGIC_VECTOR(SIZE_RES'length-1 downto 0) + + alias To_Std_Logic_Vector is + To_StdLogicVector[NATURAL, NATURAL return STD_LOGIC_VECTOR]; + alias To_SLV is + To_StdLogicVector[NATURAL, NATURAL return STD_LOGIC_VECTOR]; + alias To_Std_Logic_Vector is + To_StdLogicVector[NATURAL, STD_ULOGIC_VECTOR return STD_LOGIC_VECTOR]; + alias To_SLV is + To_StdLogicVector[NATURAL, STD_ULOGIC_VECTOR return STD_LOGIC_VECTOR]; + + -- Id: D.5 + function To_StdULogicVector (ARG, SIZE : NATURAL) return STD_ULOGIC_VECTOR; + -- Result subtype: STD_ULOGIC_VECTOR(SIZE-1 downto 0) + -- Result: Converts a non-negative INTEGER to an UNSIGNED vector with + -- the specified SIZE. + + function To_StdULogicVector (ARG : NATURAL; SIZE_RES : STD_ULOGIC_VECTOR) + return STD_ULOGIC_VECTOR; + -- Result subtype: STD_LOGIC_VECTOR(SIZE_RES'length-1 downto 0) + + alias To_Std_ULogic_Vector is + To_StdULogicVector[NATURAL, NATURAL return STD_ULOGIC_VECTOR]; + alias To_SULV is + To_StdULogicVector[NATURAL, NATURAL return STD_ULOGIC_VECTOR]; + alias To_Std_ULogic_Vector is + To_StdULogicVector[NATURAL, STD_ULOGIC_VECTOR return STD_ULOGIC_VECTOR]; + alias To_SULV is + To_StdULogicVector[NATURAL, STD_ULOGIC_VECTOR return STD_ULOGIC_VECTOR]; + +end package NUMERIC_STD_UNSIGNED; diff --git a/libraries/ieee2008/std_logic_1164-body.vhdl b/libraries/ieee2008/std_logic_1164-body.vhdl index e5c56de74..6884f1f43 100644 --- a/libraries/ieee2008/std_logic_1164-body.vhdl +++ b/libraries/ieee2008/std_logic_1164-body.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Standard multivalue logic package -- : (STD_LOGIC_1164 package body) @@ -49,18 +52,18 @@ -- -------------------------------------------------------------------- package body std_logic_1164 is - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- local types - ------------------------------------------------------------------- + ------------------------------------------------------------------- type stdlogic_1d is array (STD_ULOGIC) of STD_ULOGIC; type stdlogic_table is array(STD_ULOGIC, STD_ULOGIC) of STD_ULOGIC; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- resolution function - ------------------------------------------------------------------- + ------------------------------------------------------------------- constant resolution_table : stdlogic_table := ( -- --------------------------------------------------------- - -- | U X 0 1 Z W L H - | | + -- | U X 0 1 Z W L H - | | -- --------------------------------------------------------- ('U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U'), -- | U | ('U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'), -- | X | @@ -89,14 +92,14 @@ package body std_logic_1164 is return result; end function resolved; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- tables for logical operations - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- truth table for "and" function constant and_table : stdlogic_table := ( -- ---------------------------------------------------- - -- | U X 0 1 Z W L H - | | + -- | U X 0 1 Z W L H - | | -- ---------------------------------------------------- ('U', 'U', '0', 'U', 'U', 'U', '0', 'U', 'U'), -- | U | ('U', 'X', '0', 'X', 'X', 'X', '0', 'X', 'X'), -- | X | @@ -112,7 +115,7 @@ package body std_logic_1164 is -- truth table for "or" function constant or_table : stdlogic_table := ( -- ---------------------------------------------------- - -- | U X 0 1 Z W L H - | | + -- | U X 0 1 Z W L H - | | -- ---------------------------------------------------- ('U', 'U', 'U', '1', 'U', 'U', 'U', '1', 'U'), -- | U | ('U', 'X', 'X', '1', 'X', 'X', 'X', '1', 'X'), -- | X | @@ -128,7 +131,7 @@ package body std_logic_1164 is -- truth table for "xor" function constant xor_table : stdlogic_table := ( -- ---------------------------------------------------- - -- | U X 0 1 Z W L H - | | + -- | U X 0 1 Z W L H - | | -- ---------------------------------------------------- ('U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U'), -- | U | ('U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'), -- | X | @@ -148,9 +151,9 @@ package body std_logic_1164 is -- ------------------------------------------------- ('U', 'X', '1', '0', 'X', 'X', '1', '0', 'X'); - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- overloaded logical operators ( with optimizing hints ) - ------------------------------------------------------------------- + ------------------------------------------------------------------- function "and" (l : STD_ULOGIC; r : STD_ULOGIC) return UX01 is begin @@ -177,7 +180,7 @@ package body std_logic_1164 is return (xor_table(l, r)); end function "xor"; - function "xnor" (l : STD_ULOGIC; r : STD_ULOGIC) return ux01 is + function "xnor" (l : STD_ULOGIC; r : STD_ULOGIC) return UX01 is begin return not_table(xor_table(l, r)); end function "xnor"; @@ -187,9 +190,9 @@ package body std_logic_1164 is return (not_table(l)); end function "not"; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- and - ------------------------------------------------------------------- + ------------------------------------------------------------------- function "and" (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is alias lv : STD_ULOGIC_VECTOR (1 to l'length) is l; alias rv : STD_ULOGIC_VECTOR (1 to r'length) is r; @@ -207,9 +210,9 @@ package body std_logic_1164 is end if; return result; end function "and"; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- nand - ------------------------------------------------------------------- + ------------------------------------------------------------------- function "nand" (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is alias lv : STD_ULOGIC_VECTOR (1 to l'length) is l; alias rv : STD_ULOGIC_VECTOR (1 to r'length) is r; @@ -227,9 +230,9 @@ package body std_logic_1164 is end if; return result; end function "nand"; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- or - ------------------------------------------------------------------- + ------------------------------------------------------------------- function "or" (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is alias lv : STD_ULOGIC_VECTOR (1 to l'length) is l; alias rv : STD_ULOGIC_VECTOR (1 to r'length) is r; @@ -247,9 +250,9 @@ package body std_logic_1164 is end if; return result; end function "or"; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- nor - ------------------------------------------------------------------- + ------------------------------------------------------------------- function "nor" (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is alias lv : STD_ULOGIC_VECTOR (1 to l'length) is l; alias rv : STD_ULOGIC_VECTOR (1 to r'length) is r; @@ -269,7 +272,7 @@ package body std_logic_1164 is end function "nor"; --------------------------------------------------------------------- -- xor - ------------------------------------------------------------------- + ------------------------------------------------------------------- function "xor" (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is alias lv : STD_ULOGIC_VECTOR (1 to l'length) is l; alias rv : STD_ULOGIC_VECTOR (1 to r'length) is r; @@ -287,9 +290,9 @@ package body std_logic_1164 is end if; return result; end function "xor"; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- xnor - ------------------------------------------------------------------- + ------------------------------------------------------------------- function "xnor" (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is alias lv : STD_ULOGIC_VECTOR (1 to l'length) is l; alias rv : STD_ULOGIC_VECTOR (1 to r'length) is r; @@ -307,9 +310,9 @@ package body std_logic_1164 is end if; return result; end function "xnor"; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- not - ------------------------------------------------------------------- + ------------------------------------------------------------------- function "not" (l : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is alias lv : STD_ULOGIC_VECTOR (1 to l'length) is l; variable result : STD_ULOGIC_VECTOR (1 to l'length) := (others => 'X'); @@ -630,9 +633,9 @@ package body std_logic_1164 is return result; end function "ror"; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- conversion tables - ------------------------------------------------------------------- + ------------------------------------------------------------------- type logic_x01_table is array (STD_ULOGIC'low to STD_ULOGIC'high) of X01; type logic_x01z_table is array (STD_ULOGIC'low to STD_ULOGIC'high) of X01Z; type logic_ux01_table is array (STD_ULOGIC'low to STD_ULOGIC'high) of UX01; @@ -643,7 +646,7 @@ package body std_logic_1164 is -- in : std_ulogic -- some logic value -- returns : x01 -- state value of logic value -- purpose : to convert state-strength to state only - -- + -- -- example : if (cvt_to_x01 (input_signal) = '1' ) then ... -- ---------------------------------------------------------- @@ -666,7 +669,7 @@ package body std_logic_1164 is -- in : std_ulogic -- some logic value -- returns : x01z -- state value of logic value -- purpose : to convert state-strength to state only - -- + -- -- example : if (cvt_to_x01z (input_signal) = '1' ) then ... -- ---------------------------------------------------------- @@ -689,7 +692,7 @@ package body std_logic_1164 is -- in : std_ulogic -- some logic value -- returns : ux01 -- state value of logic value -- purpose : to convert state-strength to state only - -- + -- -- example : if (cvt_to_ux01 (input_signal) = '1' ) then ... -- ---------------------------------------------------------- @@ -705,9 +708,9 @@ package body std_logic_1164 is 'X' -- '-' ); - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- conversion functions - ------------------------------------------------------------------- + ------------------------------------------------------------------- function To_bit (s : STD_ULOGIC; xmap : BIT := '0') return BIT is begin case s is @@ -795,11 +798,11 @@ package body std_logic_1164 is return result; end function To_StdULogicVector; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- strength strippers and type convertors - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- to_01 - ------------------------------------------------------------------- + ------------------------------------------------------------------- function TO_01 (s : STD_ULOGIC_VECTOR; xmap : STD_ULOGIC := '0') return STD_ULOGIC_VECTOR is @@ -816,12 +819,12 @@ package body std_logic_1164 is end loop; if BAD_ELEMENT then for I in RESULT'range loop - RESULT(I) := XMAP; -- standard fixup + RESULT(I) := xmap; -- standard fixup end loop; end if; return RESULT; end function TO_01; - ------------------------------------------------------------------- + ------------------------------------------------------------------- function TO_01 (s : STD_ULOGIC; xmap : STD_ULOGIC := '0') return STD_ULOGIC is begin case s is @@ -830,7 +833,7 @@ package body std_logic_1164 is when others => return xmap; end case; end function TO_01; - ------------------------------------------------------------------- + ------------------------------------------------------------------- function TO_01 (s : BIT_VECTOR; xmap : STD_ULOGIC := '0') return STD_ULOGIC_VECTOR is @@ -845,7 +848,7 @@ package body std_logic_1164 is end loop; return RESULT; end function TO_01; - ------------------------------------------------------------------- + ------------------------------------------------------------------- function TO_01 (s : BIT; xmap : STD_ULOGIC := '0') return STD_ULOGIC is begin case s is @@ -853,9 +856,9 @@ package body std_logic_1164 is when '1' => RETURN '1'; end case; end function TO_01; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- to_x01 - ------------------------------------------------------------------- + ------------------------------------------------------------------- function To_X01 (s : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is alias sv : STD_ULOGIC_VECTOR (1 to s'length) is s; variable result : STD_ULOGIC_VECTOR (1 to s'length); @@ -893,7 +896,7 @@ package body std_logic_1164 is end function To_X01; -------------------------------------------------------------------- -- to_x01z - ------------------------------------------------------------------- + ------------------------------------------------------------------- function To_X01Z (s : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is alias sv : STD_ULOGIC_VECTOR (1 to s'length) is s; variable result : STD_ULOGIC_VECTOR (1 to s'length); @@ -931,7 +934,7 @@ package body std_logic_1164 is end function To_X01Z; -------------------------------------------------------------------- -- to_ux01 - ------------------------------------------------------------------- + ------------------------------------------------------------------- function To_UX01 (s : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is alias sv : STD_ULOGIC_VECTOR (1 to s'length) is s; variable result : STD_ULOGIC_VECTOR (1 to s'length); @@ -973,9 +976,9 @@ package body std_logic_1164 is return l = '1' or l = 'H'; end function "??"; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- edge detection - ------------------------------------------------------------------- + ------------------------------------------------------------------- function rising_edge (signal s : STD_ULOGIC) return BOOLEAN is begin return (s'event and (To_X01(s) = '1') and @@ -988,9 +991,9 @@ package body std_logic_1164 is (To_X01(s'last_value) = '1')); end function falling_edge; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- object contains an unknown - ------------------------------------------------------------------- + ------------------------------------------------------------------- function Is_X (s : STD_ULOGIC_VECTOR) return BOOLEAN is begin for i in s'range loop @@ -1015,7 +1018,7 @@ package body std_logic_1164 is -- string conversion and write operations ------------------------------------------------------------------- - function to_ostring (value : STD_ULOGIC_VECTOR) return STRING is + function TO_OSTRING (value : STD_ULOGIC_VECTOR) return STRING is constant result_length : NATURAL := (value'length+2)/3; variable pad : STD_ULOGIC_VECTOR(1 to result_length*3 - value'length); variable padded_value : STD_ULOGIC_VECTOR(1 to result_length*3); @@ -1044,9 +1047,9 @@ package body std_logic_1164 is end case; end loop; return result; - end function to_ostring; + end function TO_OSTRING; - function to_hstring (value : STD_ULOGIC_VECTOR) return STRING is + function TO_HSTRING (value : STD_ULOGIC_VECTOR) return STRING is constant result_length : NATURAL := (value'length+3)/4; variable pad : STD_ULOGIC_VECTOR(1 to result_length*4 - value'length); variable padded_value : STD_ULOGIC_VECTOR(1 to result_length*4); @@ -1083,9 +1086,9 @@ package body std_logic_1164 is end case; end loop; return result; - end function to_hstring; + end function TO_HSTRING; - -- Type and constant definitions used to map STD_ULOGIC values + -- Type and constant definitions used to map STD_ULOGIC values -- into/from character values. type MVL9plus is ('U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-', error); type char_indexed_by_MVL9 is array (STD_ULOGIC) of CHARACTER; @@ -1104,13 +1107,14 @@ package body std_logic_1164 is -- purpose: Skips white space procedure skip_whitespace ( L : inout LINE) is - variable readOk : BOOLEAN; variable c : CHARACTER; + variable left : positive; begin while L /= null and L.all'length /= 0 loop - c := l (l'left); - if c = ' ' or c = NBSP or c = HT then - read (l, c, readOk); + left := L.all'left; + c := L.all(left); + if (c = ' ' or c = NBSP or c = HT) then + read (L, c); else exit; end if; @@ -1123,23 +1127,22 @@ package body std_logic_1164 is variable readOk : BOOLEAN; begin VALUE := 'U'; -- initialize to a "U" - Skip_whitespace (L); - read (l, c, readOk); + skip_whitespace (L); + read (L, c, readOk); if not readOk then - good := false; + GOOD := false; else if char_to_MVL9plus(c) = error then - good := false; + GOOD := false; else VALUE := char_to_MVL9(c); - good := true; + GOOD := true; end if; end if; end procedure READ; procedure READ (L : inout LINE; VALUE : out STD_ULOGIC_VECTOR; GOOD : out BOOLEAN) is - variable m : STD_ULOGIC; variable c : CHARACTER; variable mv : STD_ULOGIC_VECTOR(0 to VALUE'length-1); variable readOk : BOOLEAN; @@ -1147,27 +1150,27 @@ package body std_logic_1164 is variable lastu : BOOLEAN := false; -- last character was an "_" begin VALUE := (VALUE'range => 'U'); -- initialize to a "U" - Skip_whitespace (L); + skip_whitespace (L); if VALUE'length > 0 then - read (l, c, readOk); + read (L, c, readOk); i := 0; - good := true; + GOOD := true; while i < VALUE'length loop if not readOk then -- Bail out if there was a bad read - good := false; + GOOD := false; return; elsif c = '_' then if i = 0 then - good := false; -- Begins with an "_" + GOOD := false; -- Begins with an "_" return; elsif lastu then - good := false; -- "__" detected + GOOD := false; -- "__" detected return; else lastu := true; end if; elsif (char_to_MVL9plus(c) = error) then - good := false; -- Illegal character + GOOD := false; -- Illegal character return; else mv(i) := char_to_MVL9(c); @@ -1181,7 +1184,7 @@ package body std_logic_1164 is read(L, c, readOk); end loop; else - good := true; -- read into a null array + GOOD := true; -- read into a null array end if; end procedure READ; @@ -1190,8 +1193,8 @@ package body std_logic_1164 is variable readOk : BOOLEAN; begin VALUE := 'U'; -- initialize to a "U" - Skip_whitespace (L); - read (l, c, readOk); + skip_whitespace (L); + read (L, c, readOk); if not readOk then report "STD_LOGIC_1164.READ(STD_ULOGIC) " & "End of string encountered" @@ -1208,7 +1211,6 @@ package body std_logic_1164 is end procedure READ; procedure READ (L : inout LINE; VALUE : out STD_ULOGIC_VECTOR) is - variable m : STD_ULOGIC; variable c : CHARACTER; variable readOk : BOOLEAN; variable mv : STD_ULOGIC_VECTOR(0 to VALUE'length-1); @@ -1216,9 +1218,9 @@ package body std_logic_1164 is variable lastu : BOOLEAN := false; -- last character was an "_" begin VALUE := (VALUE'range => 'U'); -- initialize to a "U" - Skip_whitespace (L); + skip_whitespace (L); if VALUE'length > 0 then -- non Null input string - read (l, c, readOk); + read (L, c, readOk); i := 0; while i < VALUE'length loop if readOk = false then -- Bail out if there was a bad read @@ -1262,7 +1264,7 @@ package body std_logic_1164 is procedure WRITE (L : inout LINE; VALUE : in STD_ULOGIC; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is begin - write(l, MVL9_to_char(VALUE), justified, field); + write(L, MVL9_to_char(VALUE), JUSTIFIED, FIELD); end procedure WRITE; procedure WRITE (L : inout LINE; VALUE : in STD_ULOGIC_VECTOR; @@ -1273,7 +1275,7 @@ package body std_logic_1164 is for i in 1 to VALUE'length loop s(i) := MVL9_to_char(m(i)); end loop; - write(l, s, justified, field); + write(L, s, JUSTIFIED, FIELD); end procedure WRITE; procedure Char2TriBits (C : in CHARACTER; @@ -1281,24 +1283,24 @@ package body std_logic_1164 is GOOD : out BOOLEAN; ISSUE_ERROR : in BOOLEAN) is begin - case c is - when '0' => result := o"0"; good := true; - when '1' => result := o"1"; good := true; - when '2' => result := o"2"; good := true; - when '3' => result := o"3"; good := true; - when '4' => result := o"4"; good := true; - when '5' => result := o"5"; good := true; - when '6' => result := o"6"; good := true; - when '7' => result := o"7"; good := true; - when 'Z' => result := "ZZZ"; good := true; - when 'X' => result := "XXX"; good := true; + case C is + when '0' => RESULT := o"0"; GOOD := true; + when '1' => RESULT := o"1"; GOOD := true; + when '2' => RESULT := o"2"; GOOD := true; + when '3' => RESULT := o"3"; GOOD := true; + when '4' => RESULT := o"4"; GOOD := true; + when '5' => RESULT := o"5"; GOOD := true; + when '6' => RESULT := o"6"; GOOD := true; + when '7' => RESULT := o"7"; GOOD := true; + when 'Z' => RESULT := "ZZZ"; GOOD := true; + when 'X' => RESULT := "XXX"; GOOD := true; when others => assert not ISSUE_ERROR report - "STD_LOGIC_1164.OREAD Error: Read a '" & c & + "STD_LOGIC_1164.OREAD Error: Read a '" & C & "', expected an Octal character (0-7)." severity error; - good := false; + GOOD := false; end case; end procedure Char2TriBits; @@ -1313,21 +1315,21 @@ package body std_logic_1164 is variable lastu : BOOLEAN := false; -- last character was an "_" begin VALUE := (VALUE'range => 'U'); -- initialize to a "U" - Skip_whitespace (L); + skip_whitespace (L); if VALUE'length > 0 then - read (l, c, ok); + read (L, c, ok); i := 0; while i < ne loop -- Bail out if there was a bad read if not ok then - good := false; + GOOD := false; return; elsif c = '_' then if i = 0 then - good := false; -- Begins with an "_" + GOOD := false; -- Begins with an "_" return; elsif lastu then - good := false; -- "__" detected + GOOD := false; -- "__" detected return; else lastu := true; @@ -1335,7 +1337,7 @@ package body std_logic_1164 is else Char2TriBits(c, sv(3*i to 3*i+2), ok, false); if not ok then - good := false; + GOOD := false; return; end if; i := i + 1; @@ -1346,13 +1348,13 @@ package body std_logic_1164 is end if; end loop; if or (sv (0 to pad-1)) = '1' then - good := false; -- vector was truncated. + GOOD := false; -- vector was truncated. else - good := true; + GOOD := true; VALUE := sv (pad to sv'high); end if; else - good := true; -- read into a null array + GOOD := true; -- read into a null array end if; end procedure OREAD; @@ -1366,9 +1368,9 @@ package body std_logic_1164 is variable lastu : BOOLEAN := false; -- last character was an "_" begin VALUE := (VALUE'range => 'U'); -- initialize to a "U" - Skip_whitespace (L); + skip_whitespace (L); if VALUE'length > 0 then - read (l, c, ok); + read (L, c, ok); i := 0; while i < ne loop -- Bail out if there was a bad read @@ -1416,32 +1418,32 @@ package body std_logic_1164 is GOOD : out BOOLEAN; ISSUE_ERROR : in BOOLEAN) is begin - case c is - when '0' => result := x"0"; good := true; - when '1' => result := x"1"; good := true; - when '2' => result := x"2"; good := true; - when '3' => result := x"3"; good := true; - when '4' => result := x"4"; good := true; - when '5' => result := x"5"; good := true; - when '6' => result := x"6"; good := true; - when '7' => result := x"7"; good := true; - when '8' => result := x"8"; good := true; - when '9' => result := x"9"; good := true; - when 'A' | 'a' => result := x"A"; good := true; - when 'B' | 'b' => result := x"B"; good := true; - when 'C' | 'c' => result := x"C"; good := true; - when 'D' | 'd' => result := x"D"; good := true; - when 'E' | 'e' => result := x"E"; good := true; - when 'F' | 'f' => result := x"F"; good := true; - when 'Z' => result := "ZZZZ"; good := true; - when 'X' => result := "XXXX"; good := true; + case C is + when '0' => RESULT := x"0"; GOOD := true; + when '1' => RESULT := x"1"; GOOD := true; + when '2' => RESULT := x"2"; GOOD := true; + when '3' => RESULT := x"3"; GOOD := true; + when '4' => RESULT := x"4"; GOOD := true; + when '5' => RESULT := x"5"; GOOD := true; + when '6' => RESULT := x"6"; GOOD := true; + when '7' => RESULT := x"7"; GOOD := true; + when '8' => RESULT := x"8"; GOOD := true; + when '9' => RESULT := x"9"; GOOD := true; + when 'A' | 'a' => RESULT := x"A"; GOOD := true; + when 'B' | 'b' => RESULT := x"B"; GOOD := true; + when 'C' | 'c' => RESULT := x"C"; GOOD := true; + when 'D' | 'd' => RESULT := x"D"; GOOD := true; + when 'E' | 'e' => RESULT := x"E"; GOOD := true; + when 'F' | 'f' => RESULT := x"F"; GOOD := true; + when 'Z' => RESULT := "ZZZZ"; GOOD := true; + when 'X' => RESULT := "XXXX"; GOOD := true; when others => assert not ISSUE_ERROR report - "STD_LOGIC_1164.HREAD Error: Read a '" & c & + "STD_LOGIC_1164.HREAD Error: Read a '" & C & "', expected a Hex character (0-F)." severity error; - good := false; + GOOD := false; end case; end procedure Char2QuadBits; @@ -1456,21 +1458,21 @@ package body std_logic_1164 is variable lastu : BOOLEAN := false; -- last character was an "_" begin VALUE := (VALUE'range => 'U'); -- initialize to a "U" - Skip_whitespace (L); + skip_whitespace (L); if VALUE'length > 0 then - read (l, c, ok); + read (L, c, ok); i := 0; while i < ne loop -- Bail out if there was a bad read if not ok then - good := false; + GOOD := false; return; elsif c = '_' then if i = 0 then - good := false; -- Begins with an "_" + GOOD := false; -- Begins with an "_" return; elsif lastu then - good := false; -- "__" detected + GOOD := false; -- "__" detected return; else lastu := true; @@ -1478,7 +1480,7 @@ package body std_logic_1164 is else Char2QuadBits(c, sv(4*i to 4*i+3), ok, false); if not ok then - good := false; + GOOD := false; return; end if; i := i + 1; @@ -1489,13 +1491,13 @@ package body std_logic_1164 is end if; end loop; if or (sv (0 to pad-1)) = '1' then - good := false; -- vector was truncated. + GOOD := false; -- vector was truncated. else - good := true; + GOOD := true; VALUE := sv (pad to sv'high); end if; else - good := true; -- Null input string, skips whitespace + GOOD := true; -- Null input string, skips whitespace end if; end procedure HREAD; @@ -1509,9 +1511,9 @@ package body std_logic_1164 is variable lastu : BOOLEAN := false; -- last character was an "_" begin VALUE := (VALUE'range => 'U'); -- initialize to a "U" - Skip_whitespace (L); + skip_whitespace (L); if VALUE'length > 0 then -- non Null input string - read (l, c, ok); + read (L, c, ok); i := 0; while i < ne loop -- Bail out if there was a bad read @@ -1558,13 +1560,13 @@ package body std_logic_1164 is procedure OWRITE (L : inout LINE; VALUE : in STD_ULOGIC_VECTOR; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is begin - write (L, to_ostring(VALUE), JUSTIFIED, FIELD); + write (L, TO_OSTRING(VALUE), JUSTIFIED, FIELD); end procedure OWRITE; procedure HWRITE (L : inout LINE; VALUE : in STD_ULOGIC_VECTOR; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is begin - write (L, to_hstring (VALUE), JUSTIFIED, FIELD); + write (L, TO_HSTRING (VALUE), JUSTIFIED, FIELD); end procedure HWRITE; end package body std_logic_1164; diff --git a/libraries/ieee2008/std_logic_1164.vhdl b/libraries/ieee2008/std_logic_1164.vhdl index 1a503e184..054071236 100644 --- a/libraries/ieee2008/std_logic_1164.vhdl +++ b/libraries/ieee2008/std_logic_1164.vhdl @@ -1,17 +1,20 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- -- Title : Standard multivalue logic package -- : (STD_LOGIC_1164 package declaration) @@ -44,73 +47,73 @@ -- : the terms of Clause 16 of this standard. -- : -- -------------------------------------------------------------------- --- $Revision: 1220 $ --- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ +-- $Revision: 1228 $ +-- $Date: 2008-04-30 10:04:53 +0930 (Wed, 30 Apr 2008) $ -- -------------------------------------------------------------------- use STD.TEXTIO.all; package std_logic_1164 is - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- logic state system (unresolved) - ------------------------------------------------------------------- + ------------------------------------------------------------------- type STD_ULOGIC is ( 'U', -- Uninitialized 'X', -- Forcing Unknown '0', -- Forcing 0 '1', -- Forcing 1 - 'Z', -- High Impedance + 'Z', -- High Impedance 'W', -- Weak Unknown - 'L', -- Weak 0 - 'H', -- Weak 1 + 'L', -- Weak 0 + 'H', -- Weak 1 '-' -- Don't care ); - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- unconstrained array of std_ulogic for use with the resolution function -- and for use in declaring signal arrays of unresolved elements - ------------------------------------------------------------------- + ------------------------------------------------------------------- type STD_ULOGIC_VECTOR is array (NATURAL range <>) of STD_ULOGIC; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- resolution function - ------------------------------------------------------------------- + ------------------------------------------------------------------- function resolved (s : STD_ULOGIC_VECTOR) return STD_ULOGIC; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- logic state system (resolved) - ------------------------------------------------------------------- + ------------------------------------------------------------------- subtype STD_LOGIC is resolved STD_ULOGIC; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- unconstrained array of resolved std_ulogic for use in declaring -- signal arrays of resolved elements - ------------------------------------------------------------------- + ------------------------------------------------------------------- subtype STD_LOGIC_VECTOR is (resolved) STD_ULOGIC_VECTOR; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- common subtypes - ------------------------------------------------------------------- - subtype X01 is resolved STD_ULOGIC range 'X' to '1'; -- ('X','0','1') - subtype X01Z is resolved STD_ULOGIC range 'X' to 'Z'; -- ('X','0','1','Z') - subtype UX01 is resolved STD_ULOGIC range 'U' to '1'; -- ('U','X','0','1') - subtype UX01Z is resolved STD_ULOGIC range 'U' to 'Z'; -- ('U','X','0','1','Z') + ------------------------------------------------------------------- + subtype X01 is resolved STD_ULOGIC range 'X' to '1'; -- ('X','0','1') + subtype X01Z is resolved STD_ULOGIC range 'X' to 'Z'; -- ('X','0','1','Z') + subtype UX01 is resolved STD_ULOGIC range 'U' to '1'; -- ('U','X','0','1') + subtype UX01Z is resolved STD_ULOGIC range 'U' to 'Z'; -- ('U','X','0','1','Z') - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- overloaded logical operators - ------------------------------------------------------------------- + ------------------------------------------------------------------- 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 "xnor" (l : STD_ULOGIC; r : STD_ULOGIC) return UX01; function "not" (l : STD_ULOGIC) return UX01; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- vectorized overloaded logical operators - ------------------------------------------------------------------- + ------------------------------------------------------------------- function "and" (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; function "nand" (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; function "or" (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR; @@ -169,7 +172,7 @@ package std_logic_1164 is To_bitvector[STD_ULOGIC_VECTOR, BIT return BIT_VECTOR]; alias To_BV is To_bitvector[STD_ULOGIC_VECTOR, BIT return BIT_VECTOR]; - + alias To_Std_Logic_Vector is To_StdLogicVector[BIT_VECTOR return STD_LOGIC_VECTOR]; alias To_SLV is @@ -190,9 +193,9 @@ package std_logic_1164 is alias To_SULV is To_StdULogicVector[STD_LOGIC_VECTOR return STD_ULOGIC_VECTOR]; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- strength strippers and type convertors - ------------------------------------------------------------------- + ------------------------------------------------------------------- function TO_01 (s : STD_ULOGIC_VECTOR; xmap : STD_ULOGIC := '0') return STD_ULOGIC_VECTOR; @@ -220,15 +223,15 @@ package std_logic_1164 is function "??" (l : STD_ULOGIC) return BOOLEAN; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- edge detection - ------------------------------------------------------------------- + ------------------------------------------------------------------- function rising_edge (signal s : STD_ULOGIC) return BOOLEAN; function falling_edge (signal s : STD_ULOGIC) return BOOLEAN; - ------------------------------------------------------------------- + ------------------------------------------------------------------- -- object contains an unknown - ------------------------------------------------------------------- + ------------------------------------------------------------------- function Is_X (s : STD_ULOGIC_VECTOR) return BOOLEAN; function Is_X (s : STD_ULOGIC) return BOOLEAN; @@ -247,14 +250,14 @@ package std_logic_1164 is -- function "?<=" (l, r : STD_ULOGIC) return STD_ULOGIC; -- function "?>" (l, r : STD_ULOGIC) return STD_ULOGIC; -- function "?>=" (l, r : STD_ULOGIC) return STD_ULOGIC; - + ------------------------------------------------------------------- -- string conversion and write operations ------------------------------------------------------------------- -- the following operations are predefined - -- function to_string (value : STD_ULOGIC) return STRING; - -- function to_string (value : STD_ULOGIC_VECTOR) return STRING; + -- function TO_STRING (value : STD_ULOGIC) return STRING; + -- function TO_STRING (value : STD_ULOGIC_VECTOR) return STRING; -- explicitly defined operations @@ -294,11 +297,11 @@ package std_logic_1164 is alias BWRITE is WRITE [LINE, STD_ULOGIC_VECTOR, SIDE, WIDTH]; alias BINARY_WRITE is WRITE [LINE, STD_ULOGIC_VECTOR, SIDE, WIDTH]; - + procedure OWRITE (L : inout LINE; VALUE : in STD_ULOGIC_VECTOR; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0); alias OCTAL_WRITE is OWRITE [LINE, STD_ULOGIC_VECTOR, SIDE, WIDTH]; - + procedure HWRITE (L : inout LINE; VALUE : in STD_ULOGIC_VECTOR; JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0); alias HEX_WRITE is HWRITE [LINE, STD_ULOGIC_VECTOR, SIDE, WIDTH]; diff --git a/libraries/ieee2008/std_logic_textio.vhdl b/libraries/ieee2008/std_logic_textio.vhdl index 50f20f12e..5cfe77ac0 100644 --- a/libraries/ieee2008/std_logic_textio.vhdl +++ b/libraries/ieee2008/std_logic_textio.vhdl @@ -1,42 +1,3 @@ --- -------------------------------------------------------------------- --- --- Copyright 2008 by IEEE. All rights reserved. --- --- This source file is an essential part of IEEE Std 1076-2008, --- IEEE Standard VHDL Language Reference Manual. This source file may not be --- copied, sold, or included with software that is sold without written --- permission from the IEEE Standards Department. This source file may be --- copied for individual use between licensed users. This source file is --- provided on an AS IS basis. The IEEE disclaims ANY WARRANTY EXPRESS OR --- IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY AND FITNESS FOR USE --- FOR A PARTICULAR PURPOSE. The user of the source file shall indemnify --- and hold IEEE harmless from any damages or liability arising out of the --- use thereof. --- --- Title : Standard multivalue logic package --- : (STD_LOGIC_TEXTIO package declaration) --- : --- Library : This package shall be compiled into a library --- : symbolically named IEEE. --- : --- Developers: Accellera VHDL-TC and IEEE P1076 Working Group --- : --- Purpose : This packages is provided as a replacement for non-standard --- : implementations of the package provided by implementers of --- : previous versions of this standard. The declarations that --- : appeared in those non-standard implementations appear in the --- : package STD_LOGIC_1164 in this standard. --- : --- Note : No declarations or definitions shall be included in, --- : or excluded from this package. --- : --- -------------------------------------------------------------------- --- $Revision: 1220 $ --- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ --- -------------------------------------------------------------------- - -PACKAGE std_logic_textio IS - - -- This package is empty - see notes above. - -END PACKAGE std_logic_textio; +package std_logic_textio is + -- empty. +end std_logic_textio; -- cgit v1.2.3