diff options
Diffstat (limited to 'testsuite/gna/ticket89/x_ieee_proposed')
9 files changed, 4544 insertions, 0 deletions
diff --git a/testsuite/gna/ticket89/x_ieee_proposed/CHANGES.TXT b/testsuite/gna/ticket89/x_ieee_proposed/CHANGES.TXT new file mode 100644 index 0000000..a4cae08 --- /dev/null +++ b/testsuite/gna/ticket89/x_ieee_proposed/CHANGES.TXT @@ -0,0 +1,8 @@ +IEEE Proposed - Overview of Versions and Changes
+==============================================================
+
+NOTE: The source for this library originates from IEEE. We do
+ not have an original version number for this code. The
+ version numbers used are Bitvis-specific.
+
+--------------------------------------------------------------
diff --git a/testsuite/gna/ticket89/x_ieee_proposed/README.TXT b/testsuite/gna/ticket89/x_ieee_proposed/README.TXT new file mode 100644 index 0000000..e7ef7e3 --- /dev/null +++ b/testsuite/gna/ticket89/x_ieee_proposed/README.TXT @@ -0,0 +1,8 @@ + -----------------------------------------------------------
+ -- Directory structure --
+ -----------------------------------------------------------
+
+- x_ieee_proposed : The IEEE Proposed library, used by the VHDL2002 and VHDL93 versions of Bitvis Utility Library.
+ This library allows 2008-functionality to be used in simulators not supporting VHDL2008.
+ - script : Compile script
+ - src : Source code
diff --git a/testsuite/gna/ticket89/x_ieee_proposed/script/compile_src.do b/testsuite/gna/ticket89/x_ieee_proposed/script/compile_src.do new file mode 100644 index 0000000..3343bad --- /dev/null +++ b/testsuite/gna/ticket89/x_ieee_proposed/script/compile_src.do @@ -0,0 +1,50 @@ +#========================================================================================================================
+# Copyright (c) 2015 by Bitvis AS. All rights reserved.
+#
+# BITVIS UTILITY LIBRARY AND ANY PART THEREOF ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH BITVIS UTILITY LIBRARY.
+#========================================================================================================================
+
+# This file may be called with an argument
+# arg 1: Part directory of this library/module
+
+if {[batch_mode]} {
+ onerror {abort all; exit -f -code 1}
+} else {
+ onerror {abort all}
+}
+
+# Set up part_path and lib_name
+#------------------------------------------------------
+quietly set lib_name "ieee_proposed"
+quietly set part_name "x_ieee_proposed"
+# path from mpf-file in sim
+quietly set part_path "../..//$part_name"
+
+if { [info exists 1] } {
+ # path from this part to target part
+ quietly set part_path "$1/..//$part_name"
+ unset 1
+}
+
+
+
+if {[file exists $part_path/sim/$lib_name]} {
+ file delete -force $part_path/sim/$lib_name
+}
+if {![file exists $part_path/sim]} {
+ file mkdir $part_path/sim
+}
+
+vlib $part_path/sim/$lib_name
+vmap $lib_name $part_path/sim/$lib_name
+
+
+echo "\n\n\n=== Compiling $lib_name source\n"
+vcom -93 -work $lib_name $part_path/src/standard_additions_c.vhdl
+vcom -93 -work $lib_name $part_path/src/standard_textio_additions_c.vhdl
+vcom -93 -work $lib_name $part_path/src/std_logic_1164_additions.vhdl
+vcom -93 -work $lib_name $part_path/src/numeric_std_additions.vhdl
+
diff --git a/testsuite/gna/ticket89/x_ieee_proposed/src/README b/testsuite/gna/ticket89/x_ieee_proposed/src/README new file mode 100644 index 0000000..775ff3b --- /dev/null +++ b/testsuite/gna/ticket89/x_ieee_proposed/src/README @@ -0,0 +1,173 @@ +
+ This is the "ieee_proposed" library. This is a compatability library,
+which is designed to provide all of the functionality of the VHDL-200X-FT
+packages in VHDL-93. The "_c" after the package name is used to denote
+that this is a 1993 compliant version of this package. Otherwise, the
+name of the file and the name of the package are the same.
+
+Please compile the following files into a library named "ieee_proposed":
+standard_additions_c.vhdl
+env_c.vhdl
+standard_textio_additions_c.vhdl
+std_logic_1164_additions.vhdl
+numeric_std_additions.vhdl
+numeric_std_unsigned_c.vhdl
+fixed_pkg_c.vhdl
+float_pkg_c.vhdl
+
+
+New/Updated functions
+A) standard_additions -- Additions to the package "std.standard"
+ Use model:
+ use ieee_proposed.standard_additions.all;
+ Dependancies: None.
+ Notes: The functions "rising_edge" and "falling_edge" are defined in
+ this package. If you use "numeric_bit" they are ALSO defined in that
+ package, causing a conflict. The VHDL-2008 version of numeric_bit
+ has these functions commented out, as well as the "sll", "srl", "ror"
+ and "rol" functions which are implicit.
+ New types defined in this package:
+ REAL_VECTOR
+ TIME_VECTOR
+ INTEGER_VECTOR
+ BOOLEAN_VECTOR
+ New constants defined in this package:
+ SIM_RESOLUTION : TIME - returns the simulator's resolution (1 ns default)
+ 1) "maximum" and "minimum" are defined for all default datatypes
+ 2) _reduce functions (and_reduce, nand_reduce, or_reduce ...) are defined
+ These functions reduce a bit_vector to a single bit. Example:
+ or_reduce ("0101") = '1'. In VHDL-2008 syntax these will be "or".
+ 3) "vector" and "bit" operations are defined. These will perform a
+ boolean operation of a vector. Example:
+ "1" xor "1010" = "0101";
+ 5) /??/ function is defined for "bit" ("??" operator is release)
+ if (/??/('1')) then -- will return a "true".
+ 6) rising_edge and falling_edge functions are defined (see Notes).
+ 7) to_string function - Converts any of the base types into a string.
+ Example:
+ assert (bv = "101") report "result was " & to_string(bv) severity note;
+ 8) to_hstring and to_ostring function (bit_vector to hex or octal string)
+B) standard_textio_additions - Additions to the package "std.textio"
+ Use model:
+ use ieee_proposed.standard_textio_additions.all;
+ Dependencies: std.textio, ieee_proposed.standard_additions
+ 1) tee - Echos the string to BOTH the file and the screen
+ 2) SREAD and SWRITE - String read and write routines (so you no longer
+ need to do write (L, string'("ABCEDFG"));
+ 3) HREAD and HWRITE (Hex read and write) for bit_vector
+ 4) OREAD and OWRITE (octal read and write) for bit_vector
+ 5) BREAD and BWRITE (binary read and write, same as "READ" and "WRITE" for
+ bit_vector
+ 6) justify - Justify a string left or right with a width. Example:
+ justify ("ABCD", left, 6); will result in "ABCD "
+C) std_logic_1164_additions - Additions to the package "ieee.std_logic_1164"
+ Usage model:
+ use ieee.std_logic_1164.all;
+ -- use ieee.std_logic_textio.all; -- Comment out, included in "_additions".
+ use ieee_proposed.std_logic_1164_additions.all;
+ Dependencies: ieee.std_logic_1164
+ Note: The contents of the "std_logic_textio" package have now been
+ included in the "std_logic_1164" package, and an EMPTY "std_logic_textio"
+ package is provided in the new release.
+ 1) Short had aliases:
+ a) to_bv - calls "to_BitVector"
+ b) to_slv - calls "to_StdLogicVector"
+ c) to_sulv - calls "to_stdULogicVector"
+ 2) Long hand aliases:
+ a) to_bit_vector - calls "to_BitVector"
+ b) to_std_logic_vector - calls "to_StdLogicVector"
+ c) to_std_ulogic_vector - calls "to_StdULogicVector"
+ 3) _reduce functions (and_reduce, nand_reduce, or_reduce ...) are defined
+ These functions reduce a std_logic_vector (or ulogic) to a single bit.
+ In vhdl-2006 these will be unary "or", example "or "11011" = '1'"
+ 4) "vector" and "std_ulogic" operations are defined. These will perform a
+ boolean operation of a vector. Example:
+ "1" xor "1010" = "0101";
+ 5) "std_ulogic" and "boolean" operations are defined. Thus:
+ if '1' and true then -- returns a "true".
+ 6) "\??\" function is defined for "std_ulogic" ("??" operator is release)
+ if (bool('1')) then -- will return a "true".
+ 7) READ and WRITE procedures for "std_logic_vector", "std_ulogic_vector"
+ and "std_ulogic" are defined.
+ 8) HREAD and HWRITE (Hex read and write) for std_logic_vector
+ and std_ulogic_vector. These are more "forgiving" than the ones
+ originally from "std_logic_textio"
+ 9) OREAD and OWRITE (octal read and write) for std_logic_vector
+ and std_ulogic_vector. These are more "forgiving" than the ones
+ originally from "std_logic_textio"
+ 10) BREAD and BWRITE (binary read and write, same as "READ" and "WRITE" for
+ std_logic_vector and std_ulogic_vector.
+ 11) to_string function - Converts a "std_ulogic", "std_logic_vector" or
+ "std_ulogic_vector" types into a string.
+ Example:
+ assert (slv = "101") report "result was " & to_string(slv) severity note;
+ 12) to_hstring and to_ostring function (std_(u)logic_vector to hex or octal
+ string)
+D) numeric_std_additions - additions the the package "ieee.numeric_std"
+ Usage Model:
+ use ieee.std_logic_1164.all;
+ use ieee.numeric_std.all;
+ use ieee_proposed.numeric_std_additions.all;
+ Dependencies: ieee.std_logic_1164, ieee.numeric_std
+ 1) SIGNED or UNSIGNED + std_ulogic operators
+ 2) SIGNED or UNSIGNED - std_ulogic operators
+ 3) type UNRESOLVED_UNSIGNED (aliased to U_UNSIGNED) is an unresolved
+ verion of UNSIGNED. It is aliased to "UNSIGNED" for compatability.
+ 4) type UNRESOLVED_SIGNED (aliased to U_SIGNED) is an unresolved
+ verion of SIGNED. It is aliased to "SIGNED" for compatability.
+ 5) \?=\, \?/=\ - similar to "std_match", but return std_ulogic values.
+ \?<\, \?<=\, \?>\, \?>=\ - compare functions which retrun std_ulogic.
+ (these will be "?="... operators in the release)
+ 7) To_X01, To_X01Z, To_U01X, Is_X - same as std_logic_1164 functions,
+ but overloaded for SIGNED and UNSIGNED.
+ 8) "sla" and "sra" - Mathmetically correct versions of these functions.
+ 9) minimum and maximum - smaller or larger of two SIGNED or UNSIGNED values.
+ 10) find_rightmost and find_leftmost - finds the first bit in a string.
+ Example:
+ find_leftmost (c12, '1'); -- returns the Log2 of "c12".
+ returns -1 if not found.
+ 11) _reduce functions (and_reduce, nand_reduce, or_reduce ...) are defined
+ These functions reduce a SIGNED or an UNSIGNED to a single bit.
+ (will overload the "or" and "and", ... operators in the release)
+ 12) SIGNED or UNSIGNED and "std_ulogic" operations are defined.
+ These will perform a boolean operation of a vector. Example:
+ "1" xor "1010" = "0101";
+ 13) READ and WRITE procedures for "SIGNED", and "UNSIGNED" are defined.
+ 14) HREAD and HWRITE (Hex read and write) for SIGNED and UNSIGNED.
+ These are more "forgiving" than the ones
+ originally from "std_logic_textio"
+ 15) OREAD and OWRITE (octal read and write) for "SIGNED" and "UNSIGNED.
+ These are more "forgiving" than the ones
+ originally from "std_logic_textio"
+ 16) BREAD and BWRITE (binary read and write, same as "READ" and "WRITE" for
+ SIGNED and UNSIGNED.
+ 17) to_string function - Converts a "SIGNED" or "UNSIGNED" types into a
+ string. Example:
+ assert (UNS = "101") report "result was " & to_string(UNS) severity note;
+ 18) to_hstring and to_ostring function (SIGNED or UNSIGNED to hex or octal
+ string)
+E) numeric_std_unsigned - Simular to the "std_logic_unsigned" packages, but
+ with all of the functionality of the "numeric_std" package.
+ use model:
+ use ieee.std_logic_1164.all;
+ use ieee_proposed.numeric_std_unsigned.all;
+ dependencies: ieee.numeric_std, ieee_proposed.numeric_std_additions
+
+F) For fixed point package:
+use model:
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+use ieee_proposed.math_utility_pkg.all;
+use ieee_proposed.fixed_pkg.all;
+See fixed point package documentation
+http://www.vhdl.org/vhdl-200x/vhdl-200x-ft/packages/Fixed_ug.pdf
+
+G) For floating point package:
+use model:
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+use ieee_proposed.math_utility_pkg.all;
+use ieee_proposed.fixed_pkg.all;
+use ieee_proposed.float_pkg.all;
+See floating point package documentation
+http://www.vhdl.org/vhdl-200x/vhdl-200x-ft/packages/Float_ug.pdf
diff --git a/testsuite/gna/ticket89/x_ieee_proposed/src/compile_additions b/testsuite/gna/ticket89/x_ieee_proposed/src/compile_additions new file mode 100644 index 0000000..d3e9e83 --- /dev/null +++ b/testsuite/gna/ticket89/x_ieee_proposed/src/compile_additions @@ -0,0 +1,24 @@ +#! /bin/csh -f
+#
+# Script to compile MTI
+\rm -rf ieee_proposed.lib
+vlib ieee_proposed.lib
+vmap IEEE_PROPOSED ieee_proposed.lib
+if ($MTI_VERSION == "mti5.7") then
+ set VERSION = "-93"
+else
+ set VERSION = "-2002"
+endif
+#set up some compile options
+set OPTIONS = "$VERSION -nologo"
+if ($1 == "quiet") then
+ set OPTIONS = "$OPTIONS -nowarn 3"
+endif
+vcom $OPTIONS -work IEEE_PROPOSED standard_additions_c.vhdl
+vcom $OPTIONS -work IEEE_PROPOSED standard_textio_additions_c.vhdl
+vcom $OPTIONS -work IEEE_PROPOSED std_logic_1164_additions.vhdl
+vcom $OPTIONS -work IEEE_PROPOSED numeric_std_additions.vhdl
+vcom $OPTIONS -work IEEE_PROPOSED numeric_std_unsigned_c.vhdl
+vcom $OPTIONS -work IEEE_PROPOSED fixed_float_types_c.vhdl
+vcom $OPTIONS -work IEEE_PROPOSED fixed_pkg_c.vhdl
+vcom $OPTIONS -work IEEE_PROPOSED float_pkg_c.vhdl
diff --git a/testsuite/gna/ticket89/x_ieee_proposed/src/env_c.vhdl b/testsuite/gna/ticket89/x_ieee_proposed/src/env_c.vhdl new file mode 100644 index 0000000..a27d4c0 --- /dev/null +++ b/testsuite/gna/ticket89/x_ieee_proposed/src/env_c.vhdl @@ -0,0 +1,48 @@ +package ENV is
+
+ procedure STOP (STATUS : INTEGER);
+ procedure FINISH (STATUS : INTEGER);
+
+ function RESOLUTION_LIMIT return DELAY_LENGTH;
+
+end package ENV;
+library ieee_proposed;
+use ieee_proposed.standard_additions.all;
+package body ENV is
+
+ procedure STOP (STATUS : INTEGER) is
+ begin
+ report "Procedure STOP called with status: " & INTEGER'image(STATUS)
+ severity failure;
+ end procedure STOP;
+ procedure FINISH (STATUS : INTEGER) is
+ begin
+ report "Procedure FINISH called with status: " & INTEGER'image(STATUS)
+ severity failure;
+ end procedure FINISH;
+
+ constant BASE_TIME_ARRAY : time_vector :=
+ (
+ 1 fs, 10 fs, 100 fs,
+ 1 ps, 10 ps, 100 ps,
+ 1 ns, 10 ns, 100 ns,
+ 1 us, 10 us, 100 us,
+ 1 ms, 10 ms, 100 ms,
+ 1 sec, 10 sec, 100 sec,
+ 1 min, 10 min, 100 min,
+ 1 hr, 10 hr, 100 hr
+ ) ;
+
+ function RESOLUTION_LIMIT return DELAY_LENGTH is
+ begin
+ for i in BASE_TIME_ARRAY'range loop
+ if BASE_TIME_ARRAY(i) > 0 hr then
+ return BASE_TIME_ARRAY(i);
+ end if;
+ end loop;
+ report "STANDATD.RESOLUTION_LIMIT: Simulator resolution not less than 100 hr"
+ severity failure;
+ return 1 ns;
+ end function RESOLUTION_LIMIT;
+
+end package body ENV;
diff --git a/testsuite/gna/ticket89/x_ieee_proposed/src/standard_additions_c.vhdl b/testsuite/gna/ticket89/x_ieee_proposed/src/standard_additions_c.vhdl new file mode 100644 index 0000000..83c4881 --- /dev/null +++ b/testsuite/gna/ticket89/x_ieee_proposed/src/standard_additions_c.vhdl @@ -0,0 +1,2073 @@ +------------------------------------------------------------------------------
+-- "standard_additions" package contains the additions to the built in
+-- "standard.std" package. In the final version this package will be implicit.
+-- Created for VHDL-200X par, David Bishop (dbishop@vhdl.org)
+------------------------------------------------------------------------------
+package standard_additions is
+
+ function \?=\ (L, R : BOOLEAN) return BOOLEAN;
+ function \?/=\ (L, R : BOOLEAN) return BOOLEAN;
+ function \?<\ (L, R : BOOLEAN) return BOOLEAN;
+ function \?<=\ (L, R : BOOLEAN) return BOOLEAN;
+ function \?>\ (L, R : BOOLEAN) return BOOLEAN;
+ function \?>=\ (L, R : BOOLEAN) return BOOLEAN;
+
+ function MINIMUM (L, R : BOOLEAN) return BOOLEAN;
+ function MAXIMUM (L, R : BOOLEAN) return BOOLEAN;
+
+ function RISING_EDGE (signal S : BOOLEAN) return BOOLEAN;
+ function FALLING_EDGE (signal S : BOOLEAN) return BOOLEAN;
+
+ function \?=\ (L, R : BIT) return BIT;
+ function \?/=\ (L, R : BIT) return BIT;
+ function \?<\ (L, R : BIT) return BIT;
+ function \?<=\ (L, R : BIT) return BIT;
+ function \?>\ (L, R : BIT) return BIT;
+ function \?>=\ (L, R : BIT) return BIT;
+
+ function MINIMUM (L, R : BIT) return BIT;
+ function MAXIMUM (L, R : BIT) return BIT;
+
+ function \??\ (L : BIT) return BOOLEAN;
+
+ function RISING_EDGE (signal S : BIT) return BOOLEAN;
+ function FALLING_EDGE (signal S : BIT) return BOOLEAN;
+
+ function MINIMUM (L, R : CHARACTER) return CHARACTER;
+ function MAXIMUM (L, R : CHARACTER) return CHARACTER;
+
+ function MINIMUM (L, R : SEVERITY_LEVEL) return SEVERITY_LEVEL;
+ function MAXIMUM (L, R : SEVERITY_LEVEL) return SEVERITY_LEVEL;
+
+ function MINIMUM (L, R : INTEGER) return INTEGER;
+ function MAXIMUM (L, R : INTEGER) return INTEGER;
+
+ function MINIMUM (L, R : REAL) return REAL;
+ function MAXIMUM (L, R : REAL) return REAL;
+
+ function "mod" (L, R : TIME) return TIME;
+ function "rem" (L, R : TIME) return TIME;
+
+ function MINIMUM (L, R : TIME) return TIME;
+ function MAXIMUM (L, R : TIME) return TIME;
+
+ function MINIMUM (L, R : STRING) return STRING;
+ function MAXIMUM (L, R : STRING) return STRING;
+
+ function MINIMUM (L : STRING) return CHARACTER;
+ function MAXIMUM (L : STRING) return CHARACTER;
+
+ type BOOLEAN_VECTOR is array (NATURAL range <>) of BOOLEAN;
+
+ -- The predefined operations for this type are as follows:
+
+ function "and" (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR;
+ function "or" (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR;
+ function "nand" (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR;
+ function "nor" (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR;
+ function "xor" (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR;
+ function "xnor" (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR;
+
+ function "not" (L : BOOLEAN_VECTOR) return BOOLEAN_VECTOR;
+
+ function "and" (L : BOOLEAN_VECTOR; R : BOOLEAN)
+ return BOOLEAN_VECTOR;
+ function "and" (L : BOOLEAN; R : BOOLEAN_VECTOR)
+ return BOOLEAN_VECTOR;
+ function "or" (L : BOOLEAN_VECTOR; R : BOOLEAN)
+ return BOOLEAN_VECTOR;
+ function "or" (L : BOOLEAN; R : BOOLEAN_VECTOR)
+ return BOOLEAN_VECTOR;
+ function "nand" (L : BOOLEAN_VECTOR; R : BOOLEAN)
+ return BOOLEAN_VECTOR;
+ function "nand" (L : BOOLEAN; R : BOOLEAN_VECTOR)
+ return BOOLEAN_VECTOR;
+ function "nor" (L : BOOLEAN_VECTOR; R : BOOLEAN)
+ return BOOLEAN_VECTOR;
+ function "nor" (L : BOOLEAN; R : BOOLEAN_VECTOR)
+ return BOOLEAN_VECTOR;
+ function "xor" (L : BOOLEAN_VECTOR; R : BOOLEAN)
+ return BOOLEAN_VECTOR;
+ function "xor" (L : BOOLEAN; R : BOOLEAN_VECTOR)
+ return BOOLEAN_VECTOR;
+ function "xnor" (L : BOOLEAN_VECTOR; R : BOOLEAN)
+ return BOOLEAN_VECTOR;
+ function "xnor" (L : BOOLEAN; R : BOOLEAN_VECTOR)
+ return BOOLEAN_VECTOR;
+
+ function and_reduce (L : BOOLEAN_VECTOR) return BOOLEAN;
+ function or_reduce (L : BOOLEAN_VECTOR) return BOOLEAN;
+ function nand_reduce (L : BOOLEAN_VECTOR) return BOOLEAN;
+ function nor_reduce (L : BOOLEAN_VECTOR) return BOOLEAN;
+ function xor_reduce (L : BOOLEAN_VECTOR) return BOOLEAN;
+ function xnor_reduce (L : BOOLEAN_VECTOR) return BOOLEAN;
+
+ function "sll" (L : BOOLEAN_VECTOR; R : INTEGER)
+ return BOOLEAN_VECTOR;
+ function "srl" (L : BOOLEAN_VECTOR; R : INTEGER)
+ return BOOLEAN_VECTOR;
+ function "sla" (L : BOOLEAN_VECTOR; R : INTEGER)
+ return BOOLEAN_VECTOR;
+ function "sra" (L : BOOLEAN_VECTOR; R : INTEGER)
+ return BOOLEAN_VECTOR;
+ function "rol" (L : BOOLEAN_VECTOR; R : INTEGER)
+ return BOOLEAN_VECTOR;
+ function "ror" (L : BOOLEAN_VECTOR; R : INTEGER)
+ return BOOLEAN_VECTOR;
+
+-- function "=" (L, R : BOOLEAN_VECTOR) return BOOLEAN;
+-- function "/=" (L, R : BOOLEAN_VECTOR) return BOOLEAN;
+-- function "<" (L, R : BOOLEAN_VECTOR) return BOOLEAN;
+-- function "<=" (L, R : BOOLEAN_VECTOR) return BOOLEAN;
+-- function ">" (L, R : BOOLEAN_VECTOR) return BOOLEAN;
+-- function ">=" (L, R : BOOLEAN_VECTOR) return BOOLEAN;
+
+ function \?=\ (L, R : BOOLEAN_VECTOR) return BOOLEAN;
+ function \?/=\ (L, R : BOOLEAN_VECTOR) return BOOLEAN;
+
+-- function "&" (L : BOOLEAN_VECTOR; R : BOOLEAN_VECTOR)
+ -- return BOOLEAN_VECTOR;
+-- function "&" (L : BOOLEAN_VECTOR; R : BOOLEAN) -- return BOOLEAN_VECTOR;
+-- function "&" (L : BOOLEAN; R : BOOLEAN_VECTOR) -- return BOOLEAN_VECTOR;
+-- function "&" (L : BOOLEAN; R : BOOLEAN) -- return BOOLEAN_VECTOR;
+
+ function MINIMUM (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR;
+ function MAXIMUM (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR;
+
+ function MINIMUM (L : BOOLEAN_VECTOR) return BOOLEAN;
+ function MAXIMUM (L : BOOLEAN_VECTOR) return BOOLEAN;
+
+ function "and" (L : BIT_VECTOR; R : BIT) return BIT_VECTOR;
+ function "and" (L : BIT; R : BIT_VECTOR) return BIT_VECTOR;
+ function "or" (L : BIT_VECTOR; R : BIT) return BIT_VECTOR;
+ function "or" (L : BIT; R : BIT_VECTOR) return BIT_VECTOR;
+ function "nand" (L : BIT_VECTOR; R : BIT) return BIT_VECTOR;
+ function "nand" (L : BIT; R : BIT_VECTOR) return BIT_VECTOR;
+ function "nor" (L : BIT_VECTOR; R : BIT) return BIT_VECTOR;
+ function "nor" (L : BIT; R : BIT_VECTOR) return BIT_VECTOR;
+ function "xor" (L : BIT_VECTOR; R : BIT) return BIT_VECTOR;
+ function "xor" (L : BIT; R : BIT_VECTOR) return BIT_VECTOR;
+ function "xnor" (L : BIT_VECTOR; R : BIT) return BIT_VECTOR;
+ function "xnor" (L : BIT; R : BIT_VECTOR) return BIT_VECTOR;
+
+ function and_reduce (L : BIT_VECTOR) return BIT;
+ function or_reduce (L : BIT_VECTOR) return BIT;
+ function nand_reduce (L : BIT_VECTOR) return BIT;
+ function nor_reduce (L : BIT_VECTOR) return BIT;
+ function xor_reduce (L : BIT_VECTOR) return BIT;
+ function xnor_reduce (L : BIT_VECTOR) return BIT;
+
+ function \?=\ (L, R : BIT_VECTOR) return BIT;
+ function \?/=\ (L, R : BIT_VECTOR) return BIT;
+
+ function MINIMUM (L, R : BIT_VECTOR) return BIT_VECTOR;
+ function MAXIMUM (L, R : BIT_VECTOR) return BIT_VECTOR;
+
+ function MINIMUM (L : BIT_VECTOR) return BIT;
+ function MAXIMUM (L : BIT_VECTOR) return BIT;
+
+ function TO_STRING (VALUE : BIT_VECTOR) return STRING;
+
+ alias TO_BSTRING is TO_STRING [BIT_VECTOR return STRING];
+ alias TO_BINARY_STRING is TO_STRING [BIT_VECTOR return STRING];
+ function TO_OSTRING (VALUE : BIT_VECTOR) return STRING;
+ alias TO_OCTAL_STRING is TO_OSTRING [BIT_VECTOR return STRING];
+ function TO_HSTRING (VALUE : BIT_VECTOR) return STRING;
+ alias TO_HEX_STRING is TO_HSTRING [BIT_VECTOR return STRING];
+
+ type INTEGER_VECTOR is array (NATURAL range <>) of INTEGER;
+
+ -- The predefined operations for this type are as follows:
+ function "=" (L, R : INTEGER_VECTOR) return BOOLEAN;
+ function "/=" (L, R : INTEGER_VECTOR) return BOOLEAN;
+ function "<" (L, R : INTEGER_VECTOR) return BOOLEAN;
+ function "<=" (L, R : INTEGER_VECTOR) return BOOLEAN;
+ function ">" (L, R : INTEGER_VECTOR) return BOOLEAN;
+ function ">=" (L, R : INTEGER_VECTOR) return BOOLEAN;
+
+-- function "&" (L : INTEGER_VECTOR; R : INTEGER_VECTOR)
+-- return INTEGER_VECTOR;
+-- function "&" (L : INTEGER_VECTOR; R : INTEGER) return INTEGER_VECTOR;
+-- function "&" (L : INTEGER; R : INTEGER_VECTOR) return INTEGER_VECTOR;
+-- function "&" (L : INTEGER; R : INTEGER) return INTEGER_VECTOR;
+
+ function MINIMUM (L, R : INTEGER_VECTOR) return INTEGER_VECTOR;
+ function MAXIMUM (L, R : INTEGER_VECTOR) return INTEGER_VECTOR;
+
+ function MINIMUM (L : INTEGER_VECTOR) return INTEGER;
+ function MAXIMUM (L : INTEGER_VECTOR) return INTEGER;
+
+ type REAL_VECTOR is array (NATURAL range <>) of REAL;
+
+ -- The predefined operations for this type are as follows:
+ function "=" (L, R : REAL_VECTOR) return BOOLEAN;
+ function "/=" (L, R : REAL_VECTOR) return BOOLEAN;
+ function "<" (L, R : REAL_VECTOR) return BOOLEAN;
+ function "<=" (L, R : REAL_VECTOR) return BOOLEAN;
+ function ">" (L, R : REAL_VECTOR) return BOOLEAN;
+ function ">=" (L, R : REAL_VECTOR) return BOOLEAN;
+
+-- function "&" (L : REAL_VECTOR; R : REAL_VECTOR)
+-- return REAL_VECTOR;
+-- function "&" (L : REAL_VECTOR; R : REAL) return REAL_VECTOR;
+-- function "&" (L : REAL; R : REAL_VECTOR) return REAL_VECTOR;
+-- function "&" (L : REAL; R : REAL) return REAL_VECTOR;
+
+ function MINIMUM (L, R : REAL_VECTOR) return REAL_VECTOR;
+ function MAXIMUM (L, R : REAL_VECTOR) return REAL_VECTOR;
+
+ function MINIMUM (L : REAL_VECTOR) return REAL;
+ function MAXIMUM (L : REAL_VECTOR) return REAL;
+
+ type TIME_VECTOR is array (NATURAL range <>) of TIME;
+
+ -- The predefined operations for this type are as follows:
+ function "=" (L, R : TIME_VECTOR) return BOOLEAN;
+ function "/=" (L, R : TIME_VECTOR) return BOOLEAN;
+ function "<" (L, R : TIME_VECTOR) return BOOLEAN;
+ function "<=" (L, R : TIME_VECTOR) return BOOLEAN;
+ function ">" (L, R : TIME_VECTOR) return BOOLEAN;
+ function ">=" (L, R : TIME_VECTOR) return BOOLEAN;
+
+-- function "&" (L : TIME_VECTOR; R : TIME_VECTOR)
+-- return TIME_VECTOR;
+-- function "&" (L : TIME_VECTOR; R : TIME) return TIME_VECTOR;
+-- function "&" (L : TIME; R : TIME_VECTOR) return TIME_VECTOR;
+-- function "&" (L : TIME; R : TIME) return TIME_VECTOR;
+
+ function MINIMUM (L, R : TIME_VECTOR) return TIME_VECTOR;
+ function MAXIMUM (L, R : TIME_VECTOR) return TIME_VECTOR;
+
+ function MINIMUM (L : TIME_VECTOR) return TIME;
+ function MAXIMUM (L : TIME_VECTOR) return TIME;
+
+ function MINIMUM (L, R : FILE_OPEN_KIND) return FILE_OPEN_KIND;
+ function MAXIMUM (L, R : FILE_OPEN_KIND) return FILE_OPEN_KIND;
+
+ function MINIMUM (L, R : FILE_OPEN_STATUS) return FILE_OPEN_STATUS;
+ function MAXIMUM (L, R : FILE_OPEN_STATUS) return FILE_OPEN_STATUS;
+
+ -- predefined TO_STRING operations on scalar types
+ function TO_STRING (VALUE : BOOLEAN) return STRING;
+ function TO_STRING (VALUE : BIT) return STRING;
+ function TO_STRING (VALUE : CHARACTER) return STRING;
+ function TO_STRING (VALUE : SEVERITY_LEVEL) return STRING;
+ function TO_STRING (VALUE : INTEGER) return STRING;
+ function TO_STRING (VALUE : REAL) return STRING;
+ function TO_STRING (VALUE : TIME) return STRING;
+ function TO_STRING (VALUE : FILE_OPEN_KIND) return STRING;
+ function TO_STRING (VALUE : FILE_OPEN_STATUS) return STRING;
+
+ -- predefined overloaded TO_STRING operations
+ function TO_STRING (VALUE : REAL; DIGITS : NATURAL) return STRING;
+ function TO_STRING (VALUE : REAL; FORMAT : STRING) return STRING;
+ function TO_STRING (VALUE : TIME; UNIT : TIME) return STRING;
+end package standard_additions;
+
+------------------------------------------------------------------------------
+-- "standard_additions" package contains the additions to the built in
+-- "standard.std" package. In the final version this package will be implicit.
+-- Created for VHDL-200X par, David Bishop (dbishop@vhdl.org)
+------------------------------------------------------------------------------
+use std.textio.all;
+package body standard_additions is
+
+ function \?=\ (L, R : BOOLEAN) return BOOLEAN is
+ begin
+ return L = R;
+ end function \?=\;
+
+ function \?/=\ (L, R : BOOLEAN) return BOOLEAN is
+ begin
+ return L /= R;
+ end function \?/=\;
+
+ function \?<\ (L, R : BOOLEAN) return BOOLEAN is
+ begin
+ return L < R;
+ end function \?<\;
+
+ function \?<=\ (L, R : BOOLEAN) return BOOLEAN is
+ begin
+ return L <= R;
+ end function \?<=\;
+
+ function \?>\ (L, R : BOOLEAN) return BOOLEAN is
+ begin
+ return L > R;
+ end function \?>\;
+
+ function \?>=\ (L, R : BOOLEAN) return BOOLEAN is
+ begin
+ return L >= R;
+ end function \?>=\;
+
+ function MINIMUM (L, R : BOOLEAN) return BOOLEAN is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+ function MAXIMUM (L, R : BOOLEAN) return BOOLEAN is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function TO_STRING (VALUE : BOOLEAN) return STRING is
+ begin
+ return BOOLEAN'image(VALUE);
+ end function TO_STRING;
+
+ function RISING_EDGE (signal S : BOOLEAN) return BOOLEAN is
+ begin
+ return (s'event and (s = true) and (s'last_value = false));
+ end function rising_edge;
+
+ function FALLING_EDGE (signal S : BOOLEAN) return BOOLEAN is
+ begin
+ return (s'event and (s = false) and (s'last_value = true));
+ end function falling_edge;
+
+ function \?=\ (L, R : BIT) return BIT is
+ begin
+ if L = R then
+ return '1';
+ else
+ return '0';
+ end if;
+ end function \?=\;
+
+ function \?/=\ (L, R : BIT) return BIT is
+ begin
+ if L /= R then
+ return '1';
+ else
+ return '0';
+ end if;
+ end function \?/=\;
+
+ function \?<\ (L, R : BIT) return BIT is
+ begin
+ if L < R then
+ return '1';
+ else
+ return '0';
+ end if;
+ end function \?<\;
+
+ function \?<=\ (L, R : BIT) return BIT is
+ begin
+ if L <= R then
+ return '1';
+ else
+ return '0';
+ end if;
+ end function \?<=\;
+
+ function \?>\ (L, R : BIT) return BIT is
+ begin
+ if L > R then
+ return '1';
+ else
+ return '0';
+ end if;
+ end function \?>\;
+
+ function \?>=\ (L, R : BIT) return BIT is
+ begin
+ if L >= R then
+ return '1';
+ else
+ return '0';
+ end if;
+ end function \?>=\;
+
+ function MINIMUM (L, R : BIT) return BIT is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : BIT) return BIT is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function TO_STRING (VALUE : BIT) return STRING is
+ begin
+ if VALUE = '1' then
+ return "1";
+ else
+ return "0";
+ end if;
+ end function TO_STRING;
+
+ function \??\ (L : BIT) return BOOLEAN is
+ begin
+ return L = '1';
+ end function \??\;
+
+ function RISING_EDGE (signal S : BIT) return BOOLEAN is
+ begin
+ return (s'event and (s = '1') and (s'last_value = '0'));
+ end function rising_edge;
+
+ function FALLING_EDGE (signal S : BIT) return BOOLEAN is
+ begin
+ return (s'event and (s = '0') and (s'last_value = '1'));
+ end function falling_edge;
+
+ function MINIMUM (L, R : CHARACTER) return CHARACTER is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : CHARACTER) return CHARACTER is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function TO_STRING (VALUE : CHARACTER) return STRING is
+ variable result : STRING (1 to 1);
+ begin
+ result (1) := VALUE;
+ return result;
+ end function TO_STRING;
+
+ function MINIMUM (L, R : SEVERITY_LEVEL) return SEVERITY_LEVEL is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : SEVERITY_LEVEL) return SEVERITY_LEVEL is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function TO_STRING (VALUE : SEVERITY_LEVEL) return STRING is
+ begin
+ return SEVERITY_LEVEL'image(VALUE);
+ end function TO_STRING;
+
+ function MINIMUM (L, R : INTEGER) return INTEGER is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : INTEGER) return INTEGER is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function TO_STRING (VALUE : INTEGER) return STRING is
+ begin
+ return INTEGER'image(VALUE);
+ end function TO_STRING;
+
+ function MINIMUM (L, R : REAL) return REAL is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : REAL) return REAL is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function TO_STRING (VALUE : REAL) return STRING is
+ begin
+ return REAL'image (VALUE);
+ end function TO_STRING;
+
+ function TO_STRING (VALUE : REAL; DIGITS : NATURAL) return STRING is
+ begin
+ return to_string (VALUE, "%1." & INTEGER'image(DIGITS) & "f");
+ end function TO_STRING;
+
+ function "mod" (L, R : TIME) return TIME is
+ variable lint, rint : INTEGER;
+ begin
+ lint := L / 1.0 ns;
+ rint := R / 1.0 ns;
+ return (lint mod rint) * 1.0 ns;
+ end function "mod";
+
+ function "rem" (L, R : TIME) return TIME is
+ variable lint, rint : INTEGER;
+ begin
+ lint := L / 1.0 ns;
+ rint := R / 1.0 ns;
+ return (lint rem rint) * 1.0 ns;
+ end function "rem";
+
+ function MINIMUM (L, R : TIME) return TIME is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : TIME) return TIME is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function TO_STRING (VALUE : TIME) return STRING is
+ begin
+ return TIME'image (VALUE);
+ end function TO_STRING;
+
+ function MINIMUM (L, R : STRING) return STRING is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : STRING) return STRING is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function MINIMUM (L : STRING) return CHARACTER is
+ variable result : CHARACTER := CHARACTER'high;
+ begin
+ for i in l'range loop
+ result := minimum (l(i), result);
+ end loop;
+ return result;
+ end function MINIMUM;
+
+ function MAXIMUM (L : STRING) return CHARACTER is
+ variable result : CHARACTER := CHARACTER'low;
+ begin
+ for i in l'range loop
+ result := maximum (l(i), result);
+ end loop;
+ return result;
+ end function MAXIMUM;
+
+ -- type BOOLEAN_VECTOR is array (NATURAL range <>) of BOOLEAN;
+ -- The predefined operations for this type are as follows:
+ function "and" (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ alias rv : BOOLEAN_VECTOR (1 to r'length) is r;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ if (l'length /= r'length) then
+ assert false
+ report "STD.""and"": "
+ & "arguments of overloaded 'and' operator are not of the same length"
+ severity failure;
+ else
+ for i in result'range loop
+ result(i) := (lv(i) and rv(i));
+ end loop;
+ end if;
+ return result;
+ end function "and";
+
+ function "or" (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ alias rv : BOOLEAN_VECTOR (1 to r'length) is r;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ if (l'length /= r'length) then
+ assert false
+ report "STD.""or"": "
+ & "arguments of overloaded 'or' operator are not of the same length"
+ severity failure;
+ else
+ for i in result'range loop
+ result(i) := (lv(i) or rv(i));
+ end loop;
+ end if;
+ return result;
+ end function "or";
+
+ function "nand" (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ alias rv : BOOLEAN_VECTOR (1 to r'length) is r;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ if (l'length /= r'length) then
+ assert false
+ report "STD.""nand"": "
+ & "arguments of overloaded 'nand' operator are not of the same length"
+ severity failure;
+ else
+ for i in result'range loop
+ result(i) := (lv(i) nand rv(i));
+ end loop;
+ end if;
+ return result;
+ end function "nand";
+
+ function "nor" (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ alias rv : BOOLEAN_VECTOR (1 to r'length) is r;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ if (l'length /= r'length) then
+ assert false
+ report "STD.""nor"": "
+ & "arguments of overloaded 'nor' operator are not of the same length"
+ severity failure;
+ else
+ for i in result'range loop
+ result(i) := (lv(i) nor rv(i));
+ end loop;
+ end if;
+ return result;
+ end function "nor";
+
+ function "xor" (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ alias rv : BOOLEAN_VECTOR (1 to r'length) is r;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ if (l'length /= r'length) then
+ assert false
+ report "STD.""xor"": "
+ & "arguments of overloaded 'xor' operator are not of the same length"
+ severity failure;
+ else
+ for i in result'range loop
+ result(i) := (lv(i) xor rv(i));
+ end loop;
+ end if;
+ return result;
+ end function "xor";
+
+ function "xnor" (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ alias rv : BOOLEAN_VECTOR (1 to r'length) is r;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ if (l'length /= r'length) then
+ assert false
+ report "STD.""xnor"": "
+ & "arguments of overloaded 'xnor' operator are not of the same length"
+ severity failure;
+ else
+ for i in result'range loop
+ result(i) := (lv(i) xnor rv(i));
+ end loop;
+ end if;
+ return result;
+ end function "xnor";
+
+ function "not" (L : BOOLEAN_VECTOR) return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := not (lv(i));
+ end loop;
+ return result;
+ end function "not";
+
+ function "and" (L : BOOLEAN_VECTOR; R : BOOLEAN)
+ return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := lv(i) and r;
+ end loop;
+ return result;
+ end function "and";
+
+ function "and" (L : BOOLEAN; R : BOOLEAN_VECTOR)
+ return BOOLEAN_VECTOR is
+ alias rv : BOOLEAN_VECTOR (1 to r'length) is r;
+ variable result : BOOLEAN_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := l and rv(i);
+ end loop;
+ return result;
+ end function "and";
+
+ function "or" (L : BOOLEAN_VECTOR; R : BOOLEAN)
+ return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := lv(i) or r;
+ end loop;
+ return result;
+ end function "or";
+
+ function "or" (L : BOOLEAN; R : BOOLEAN_VECTOR)
+ return BOOLEAN_VECTOR is
+ alias rv : BOOLEAN_VECTOR (1 to r'length) is r;
+ variable result : BOOLEAN_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := l or rv(i);
+ end loop;
+ return result;
+ end function "or";
+
+ function "nand" (L : BOOLEAN_VECTOR; R : BOOLEAN)
+ return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := lv(i) nand r;
+ end loop;
+ return result;
+ end function "nand";
+
+ function "nand" (L : BOOLEAN; R : BOOLEAN_VECTOR)
+ return BOOLEAN_VECTOR is
+ alias rv : BOOLEAN_VECTOR (1 to r'length) is r;
+ variable result : BOOLEAN_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := l nand rv(i);
+ end loop;
+ return result;
+ end function "nand";
+
+ function "nor" (L : BOOLEAN_VECTOR; R : BOOLEAN)
+ return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := lv(i) nor r;
+ end loop;
+ return result;
+ end function "nor";
+
+ function "nor" (L : BOOLEAN; R : BOOLEAN_VECTOR)
+ return BOOLEAN_VECTOR is
+ alias rv : BOOLEAN_VECTOR (1 to r'length) is r;
+ variable result : BOOLEAN_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := l nor rv(i);
+ end loop;
+ return result;
+ end function "nor";
+
+ function "xor" (L : BOOLEAN_VECTOR; R : BOOLEAN)
+ return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := lv(i) xor r;
+ end loop;
+ return result;
+ end function "xor";
+
+ function "xor" (L : BOOLEAN; R : BOOLEAN_VECTOR)
+ return BOOLEAN_VECTOR is
+ alias rv : BOOLEAN_VECTOR (1 to r'length) is r;
+ variable result : BOOLEAN_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := l xor rv(i);
+ end loop;
+ return result;
+ end function "xor";
+
+ function "xnor" (L : BOOLEAN_VECTOR; R : BOOLEAN)
+ return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := lv(i) xnor r;
+ end loop;
+ return result;
+ end function "xnor";
+
+ function "xnor" (L : BOOLEAN; R : BOOLEAN_VECTOR)
+ return BOOLEAN_VECTOR is
+ alias rv : BOOLEAN_VECTOR (1 to r'length) is r;
+ variable result : BOOLEAN_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := l xnor rv(i);
+ end loop;
+ return result;
+ end function "xnor";
+
+ function and_reduce (L : BOOLEAN_VECTOR) return BOOLEAN is
+ variable result : BOOLEAN := true;
+ begin
+ for i in l'reverse_range loop
+ result := l(i) and result;
+ end loop;
+ return result;
+ end function and_reduce;
+
+ function or_reduce (L : BOOLEAN_VECTOR) return BOOLEAN is
+ variable result : BOOLEAN := false;
+ begin
+ for i in l'reverse_range loop
+ result := l(i) or result;
+ end loop;
+ return result;
+ end function or_reduce;
+
+ function nand_reduce (L : BOOLEAN_VECTOR) return BOOLEAN is
+ variable result : BOOLEAN := true;
+ begin
+ for i in l'reverse_range loop
+ result := l(i) and result;
+ end loop;
+ return not result;
+ end function nand_reduce;
+
+ function nor_reduce (L : BOOLEAN_VECTOR) return BOOLEAN is
+ variable result : BOOLEAN := false;
+ begin
+ for i in l'reverse_range loop
+ result := l(i) or result;
+ end loop;
+ return not result;
+ end function nor_reduce;
+
+ function xor_reduce (L : BOOLEAN_VECTOR) return BOOLEAN is
+ variable result : BOOLEAN := false;
+ begin
+ for i in l'reverse_range loop
+ result := l(i) xor result;
+ end loop;
+ return result;
+ end function xor_reduce;
+
+ function xnor_reduce (L : BOOLEAN_VECTOR) return BOOLEAN is
+ variable result : BOOLEAN := false;
+ begin
+ for i in l'reverse_range loop
+ result := l(i) xor result;
+ end loop;
+ return not result;
+ end function xnor_reduce;
+
+ function "sll" (L : BOOLEAN_VECTOR; R : INTEGER)
+ return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ if r >= 0 then
+ result(1 to l'length - r) := lv(r + 1 to l'length);
+ else
+ result := l srl -r;
+ end if;
+ return result;
+ end function "sll";
+
+ function "srl" (L : BOOLEAN_VECTOR; R : INTEGER)
+ return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ if r >= 0 then
+ result(r + 1 to l'length) := lv(1 to l'length - r);
+ else
+ result := l sll -r;
+ end if;
+ return result;
+ end function "srl";
+
+ function "sla" (L : BOOLEAN_VECTOR; R : INTEGER)
+ return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ for i in L'range loop
+ result (i) := L(L'high);
+ end loop;
+ if r >= 0 then
+ result(1 to l'length - r) := lv(r + 1 to l'length);
+ else
+ result := l sra -r;
+ end if;
+ return result;
+ end function "sla";
+
+ function "sra" (L : BOOLEAN_VECTOR; R : INTEGER)
+ return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ begin
+ for i in L'range loop
+ result (i) := L(L'low);
+ end loop;
+ if r >= 0 then
+ result(1 to l'length - r) := lv(r + 1 to l'length);
+ else
+ result := l sra -r;
+ end if;
+ return result;
+ end function "sra";
+
+ function "rol" (L : BOOLEAN_VECTOR; R : INTEGER)
+ return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ constant rm : INTEGER := r mod l'length;
+ begin
+ if r >= 0 then
+ result(1 to l'length - rm) := lv(rm + 1 to l'length);
+ result(l'length - rm + 1 to l'length) := lv(1 to rm);
+ else
+ result := l ror -r;
+ end if;
+ return result;
+ end function "rol";
+
+ function "ror" (L : BOOLEAN_VECTOR; R : INTEGER)
+ return BOOLEAN_VECTOR is
+ alias lv : BOOLEAN_VECTOR (1 to l'length) is l;
+ variable result : BOOLEAN_VECTOR (1 to l'length);
+ constant rm : INTEGER := r mod l'length;
+ begin
+ if r >= 0 then
+ result(rm + 1 to l'length) := lv(1 to l'length - rm);
+ result(1 to rm) := lv(l'length - rm + 1 to l'length);
+ else
+ result := l rol -r;
+ end if;
+ return result;
+ end function "ror";
+-- function "=" (L, R: BOOLEAN_VECTOR) return BOOLEAN;
+-- function "/=" (L, R: BOOLEAN_VECTOR) return BOOLEAN;
+-- function "<" (L, R: BOOLEAN_VECTOR) return BOOLEAN;
+-- function "<=" (L, R: BOOLEAN_VECTOR) return BOOLEAN;
+-- function ">" (L, R: BOOLEAN_VECTOR) return BOOLEAN;
+-- function ">=" (L, R: BOOLEAN_VECTOR) return BOOLEAN;
+
+ function \?=\ (L, R : BOOLEAN_VECTOR) return BOOLEAN is
+ begin
+ return L = R;
+ end function \?=\;
+
+ function \?/=\ (L, R : BOOLEAN_VECTOR) return BOOLEAN is
+ begin
+ return L /= R;
+ end function \?/=\;
+-- function "&" (L: BOOLEAN_VECTOR; R: BOOLEAN_VECTOR)
+-- return BOOLEAN_VECTOR;
+-- function "&" (L: BOOLEAN_VECTOR; R: BOOLEAN) return BOOLEAN_VECTOR;
+-- function "&" (L: BOOLEAN; R: BOOLEAN_VECTOR) return BOOLEAN_VECTOR;
+-- function "&" (L: BOOLEAN; R: BOOLEAN) return BOOLEAN_VECTOR;
+
+ function MINIMUM (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : BOOLEAN_VECTOR) return BOOLEAN_VECTOR is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function MINIMUM (L : BOOLEAN_VECTOR) return BOOLEAN is
+ variable result : BOOLEAN := BOOLEAN'high;
+ begin
+ for i in l'range loop
+ result := minimum (l(i), result);
+ end loop;
+ return result;
+ end function MINIMUM;
+
+ function MAXIMUM (L : BOOLEAN_VECTOR) return BOOLEAN is
+ variable result : BOOLEAN := BOOLEAN'low;
+ begin
+ for i in l'range loop
+ result := maximum (l(i), result);
+ end loop;
+ return result;
+ end function MAXIMUM;
+
+ function "and" (L : BIT_VECTOR; R : BIT) return BIT_VECTOR is
+ alias lv : BIT_VECTOR (1 to l'length) is l;
+ variable result : BIT_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := lv(i) and r;
+ end loop;
+ return result;
+ end function "and";
+
+ function "and" (L : BIT; R : BIT_VECTOR) return BIT_VECTOR is
+ alias rv : BIT_VECTOR (1 to r'length) is r;
+ variable result : BIT_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := l and rv(i);
+ end loop;
+ return result;
+ end function "and";
+
+ function "or" (L : BIT_VECTOR; R : BIT) return BIT_VECTOR is
+ alias lv : BIT_VECTOR (1 to l'length) is l;
+ variable result : BIT_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := lv(i) or r;
+ end loop;
+ return result;
+ end function "or";
+
+ function "or" (L : BIT; R : BIT_VECTOR) return BIT_VECTOR is
+ alias rv : BIT_VECTOR (1 to r'length) is r;
+ variable result : BIT_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := l or rv(i);
+ end loop;
+ return result;
+ end function "or";
+
+ function "nand" (L : BIT_VECTOR; R : BIT) return BIT_VECTOR is
+ alias lv : BIT_VECTOR (1 to l'length) is l;
+ variable result : BIT_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := lv(i) and r;
+ end loop;
+ return not result;
+ end function "nand";
+
+ function "nand" (L : BIT; R : BIT_VECTOR) return BIT_VECTOR is
+ alias rv : BIT_VECTOR (1 to r'length) is r;
+ variable result : BIT_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := l and rv(i);
+ end loop;
+ return not result;
+ end function "nand";
+
+ function "nor" (L : BIT_VECTOR; R : BIT) return BIT_VECTOR is
+ alias lv : BIT_VECTOR (1 to l'length) is l;
+ variable result : BIT_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := lv(i) or r;
+ end loop;
+ return not result;
+ end function "nor";
+
+ function "nor" (L : BIT; R : BIT_VECTOR) return BIT_VECTOR is
+ alias rv : BIT_VECTOR (1 to r'length) is r;
+ variable result : BIT_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := l or rv(i);
+ end loop;
+ return not result;
+ end function "nor";
+
+ function "xor" (L : BIT_VECTOR; R : BIT) return BIT_VECTOR is
+ alias lv : BIT_VECTOR (1 to l'length) is l;
+ variable result : BIT_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := lv(i) xor r;
+ end loop;
+ return result;
+ end function "xor";
+
+ function "xor" (L : BIT; R : BIT_VECTOR) return BIT_VECTOR is
+ alias rv : BIT_VECTOR (1 to r'length) is r;
+ variable result : BIT_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := l xor rv(i);
+ end loop;
+ return result;
+ end function "xor";
+
+ function "xnor" (L : BIT_VECTOR; R : BIT) return BIT_VECTOR is
+ alias lv : BIT_VECTOR (1 to l'length) is l;
+ variable result : BIT_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := lv(i) xor r;
+ end loop;
+ return not result;
+ end function "xnor";
+
+ function "xnor" (L : BIT; R : BIT_VECTOR) return BIT_VECTOR is
+ alias rv : BIT_VECTOR (1 to r'length) is r;
+ variable result : BIT_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := l xor rv(i);
+ end loop;
+ return not result;
+ end function "xnor";
+
+ function and_reduce (L : BIT_VECTOR) return BIT is
+ variable result : BIT := '1';
+ begin
+ for i in l'reverse_range loop
+ result := l(i) and result;
+ end loop;
+ return result;
+ end function and_reduce;
+
+ function or_reduce (L : BIT_VECTOR) return BIT is
+ variable result : BIT := '0';
+ begin
+ for i in l'reverse_range loop
+ result := l(i) or result;
+ end loop;
+ return result;
+ end function or_reduce;
+
+ function nand_reduce (L : BIT_VECTOR) return BIT is
+ variable result : BIT := '1';
+ begin
+ for i in l'reverse_range loop
+ result := l(i) and result;
+ end loop;
+ return not result;
+ end function nand_reduce;
+
+ function nor_reduce (L : BIT_VECTOR) return BIT is
+ variable result : BIT := '0';
+ begin
+ for i in l'reverse_range loop
+ result := l(i) or result;
+ end loop;
+ return not result;
+ end function nor_reduce;
+
+ function xor_reduce (L : BIT_VECTOR) return BIT is
+ variable result : BIT := '0';
+ begin
+ for i in l'reverse_range loop
+ result := l(i) xor result;
+ end loop;
+ return result;
+ end function xor_reduce;
+
+ function xnor_reduce (L : BIT_VECTOR) return BIT is
+ variable result : BIT := '0';
+ begin
+ for i in l'reverse_range loop
+ result := l(i) xor result;
+ end loop;
+ return not result;
+ end function xnor_reduce;
+
+ function \?=\ (L, R : BIT_VECTOR) return BIT is
+ begin
+ if L = R then
+ return '1';
+ else
+ return '0';
+ end if;
+ end function \?=\;
+
+ function \?/=\ (L, R : BIT_VECTOR) return BIT is
+ begin
+ if L /= R then
+ return '1';
+ else
+ return '0';
+ end if;
+ end function \?/=\;
+
+ function MINIMUM (L, R : BIT_VECTOR) return BIT_VECTOR is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : BIT_VECTOR) return BIT_VECTOR is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function MINIMUM (L : BIT_VECTOR) return BIT is
+ variable result : BIT := BIT'high;
+ begin
+ for i in l'range loop
+ result := minimum (l(i), result);
+ end loop;
+ return result;
+ end function MINIMUM;
+
+ function MAXIMUM (L : BIT_VECTOR) return BIT is
+ variable result : BIT := BIT'low;
+ begin
+ for i in l'range loop
+ result := maximum (l(i), result);
+ end loop;
+ return result;
+ end function MAXIMUM;
+
+ function TO_STRING (VALUE : BIT_VECTOR) return STRING is
+ alias ivalue : BIT_VECTOR(1 to value'length) is value;
+ variable result : STRING(1 to value'length);
+ begin
+ if value'length < 1 then
+ return "";
+ else
+ for i in ivalue'range loop
+ if iValue(i) = '0' then
+ result(i) := '0';
+ else
+ result(i) := '1';
+ end if;
+ end loop;
+ return result;
+ end if;
+ end function to_string;
+
+-- alias TO_BSTRING is TO_STRING [BIT_VECTOR return STRING];
+-- alias TO_BINARY_STRING is TO_STRING [BIT_VECTOR return STRING];
+
+ function TO_OSTRING (VALUE : BIT_VECTOR) return STRING is
+ constant ne : INTEGER := (value'length+2)/3;
+ constant pad : BIT_VECTOR(0 to (ne*3 - value'length) - 1) := (others => '0');
+ variable ivalue : BIT_VECTOR(0 to ne*3 - 1);
+ variable result : STRING(1 to ne);
+ variable tri : BIT_VECTOR(0 to 2);
+ begin
+ if value'length < 1 then
+ return "";
+ end if;
+ ivalue := pad & value;
+ for i in 0 to ne-1 loop
+ tri := ivalue(3*i to 3*i+2);
+ case tri is
+ when o"0" => result(i+1) := '0';
+ when o"1" => result(i+1) := '1';
+ when o"2" => result(i+1) := '2';
+ when o"3" => result(i+1) := '3';
+ when o"4" => result(i+1) := '4';
+ when o"5" => result(i+1) := '5';
+ when o"6" => result(i+1) := '6';
+ when o"7" => result(i+1) := '7';
+ end case;
+ end loop;
+ return result;
+ end function to_ostring;
+-- alias TO_OCTAL_STRING is TO_OSTRING [BIT_VECTOR return STRING];
+
+ function TO_HSTRING (VALUE : BIT_VECTOR) return STRING is
+ constant ne : INTEGER := (value'length+3)/4;
+ constant pad : BIT_VECTOR(0 to (ne*4 - value'length) - 1) := (others => '0');
+ variable ivalue : BIT_VECTOR(0 to ne*4 - 1);
+ variable result : STRING(1 to ne);
+ variable quad : BIT_VECTOR(0 to 3);
+ begin
+ if value'length < 1 then
+ return "";
+ end if;
+ ivalue := pad & value;
+ for i in 0 to ne-1 loop
+ quad := ivalue(4*i to 4*i+3);
+ case quad is
+ when x"0" => result(i+1) := '0';
+ when x"1" => result(i+1) := '1';
+ when x"2" => result(i+1) := '2';
+ when x"3" => result(i+1) := '3';
+ when x"4" => result(i+1) := '4';
+ when x"5" => result(i+1) := '5';
+ when x"6" => result(i+1) := '6';
+ when x"7" => result(i+1) := '7';
+ when x"8" => result(i+1) := '8';
+ when x"9" => result(i+1) := '9';
+ when x"A" => result(i+1) := 'A';
+ when x"B" => result(i+1) := 'B';
+ when x"C" => result(i+1) := 'C';
+ when x"D" => result(i+1) := 'D';
+ when x"E" => result(i+1) := 'E';
+ when x"F" => result(i+1) := 'F';
+ end case;
+ end loop;
+ return result;
+ end function to_hstring;
+-- alias TO_HEX_STRING is TO_HSTRING [BIT_VECTOR return STRING];
+
+-- type INTEGER_VECTOR is array (NATURAL range <>) of INTEGER;
+ -- The predefined operations for this type are as follows:
+
+ function "=" (L, R : INTEGER_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length or L'length < 1 or R'length < 1 then
+ return false;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ return false;
+ end if;
+ end loop;
+ return true;
+ end if;
+ end function "=";
+
+ function "/=" (L, R : INTEGER_VECTOR) return BOOLEAN is
+ begin
+ return not (L = R);
+ end function "/=";
+
+ function "<" (L, R : INTEGER_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length then
+ return L'length < R'length;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ if L(i) < R(i) then
+ return true;
+ else
+ return false;
+ end if;
+ end if;
+ end loop;
+ return false;
+ end if;
+ end function "<";
+
+ function "<=" (L, R : INTEGER_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length then
+ return L'length < R'length;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ if L(i) < R(i) then
+ return true;
+ else
+ return false;
+ end if;
+ end if;
+ end loop;
+ return true;
+ end if;
+ end function "<=";
+
+ function ">" (L, R : INTEGER_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length then
+ return L'length > R'length;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ if L(i) > R(i) then
+ return true;
+ else
+ return false;
+ end if;
+ end if;
+ end loop;
+ return false;
+ end if;
+ end function ">";
+
+ function ">=" (L, R : INTEGER_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length then
+ return L'length > R'length;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ if L(i) > R(i) then
+ return true;
+ else
+ return false;
+ end if;
+ end if;
+ end loop;
+ return true;
+ end if;
+ end function ">=";
+-- function "&" (L: INTEGER_VECTOR; R: INTEGER_VECTOR)
+-- return INTEGER_VECTOR;
+-- function "&" (L: INTEGER_VECTOR; R: INTEGER) return INTEGER_VECTOR;
+-- function "&" (L: INTEGER; R: INTEGER_VECTOR) return INTEGER_VECTOR;
+-- function "&" (L: INTEGER; R: INTEGER) return INTEGER_VECTOR;
+
+ function MINIMUM (L, R : INTEGER_VECTOR) return INTEGER_VECTOR is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : INTEGER_VECTOR) return INTEGER_VECTOR is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function MINIMUM (L : INTEGER_VECTOR) return INTEGER is
+ variable result : INTEGER := INTEGER'high;
+ begin
+ for i in l'range loop
+ result := minimum (l(i), result);
+ end loop;
+ return result;
+ end function MINIMUM;
+
+ function MAXIMUM (L : INTEGER_VECTOR) return INTEGER is
+ variable result : INTEGER := INTEGER'low;
+ begin
+ for i in l'range loop
+ result := maximum (l(i), result);
+ end loop;
+ return result;
+ end function MAXIMUM;
+
+ -- type REAL_VECTOR is array (NATURAL range <>) of REAL;
+ -- The predefined operations for this type are as follows:
+ function "=" (L, R : REAL_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length or L'length < 1 or R'length < 1 then
+ return false;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ return false;
+ end if;
+ end loop;
+ return true;
+ end if;
+ end function "=";
+
+ function "/=" (L, R : REAL_VECTOR) return BOOLEAN is
+ begin
+ return not (L = R);
+ end function "/=";
+
+ function "<" (L, R : REAL_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length then
+ return L'length < R'length;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ if L(i) < R(i) then
+ return true;
+ else
+ return false;
+ end if;
+ end if;
+ end loop;
+ return false;
+ end if;
+ end function "<";
+
+ function "<=" (L, R : REAL_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length then
+ return L'length < R'length;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ if L(i) < R(i) then
+ return true;
+ else
+ return false;
+ end if;
+ end if;
+ end loop;
+ return true;
+ end if;
+ end function "<=";
+
+ function ">" (L, R : REAL_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length then
+ return L'length > R'length;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ if L(i) > R(i) then
+ return true;
+ else
+ return false;
+ end if;
+ end if;
+ end loop;
+ return false;
+ end if;
+ end function ">";
+
+ function ">=" (L, R : REAL_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length then
+ return L'length > R'length;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ if L(i) > R(i) then
+ return true;
+ else
+ return false;
+ end if;
+ end if;
+ end loop;
+ return true;
+ end if;
+ end function ">=";
+-- function "&" (L: REAL_VECTOR; R: REAL_VECTOR)
+-- return REAL_VECTOR;
+-- function "&" (L: REAL_VECTOR; R: REAL) return REAL_VECTOR;
+-- function "&" (L: REAL; R: REAL_VECTOR) return REAL_VECTOR;
+-- function "&" (L: REAL; R: REAL) return REAL_VECTOR;
+
+ function MINIMUM (L, R : REAL_VECTOR) return REAL_VECTOR is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : REAL_VECTOR) return REAL_VECTOR is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function MINIMUM (L : REAL_VECTOR) return REAL is
+ variable result : REAL := REAL'high;
+ begin
+ for i in l'range loop
+ result := minimum (l(i), result);
+ end loop;
+ return result;
+ end function MINIMUM;
+
+ function MAXIMUM (L : REAL_VECTOR) return REAL is
+ variable result : REAL := REAL'low;
+ begin
+ for i in l'range loop
+ result := maximum (l(i), result);
+ end loop;
+ return result;
+ end function MAXIMUM;
+
+ -- type TIME_VECTOR is array (NATURAL range <>) of TIME;
+ -- The predefined implicit operations for this type are as follows:
+ function "=" (L, R : TIME_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length or L'length < 1 or R'length < 1 then
+ return false;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ return false;
+ end if;
+ end loop;
+ return true;
+ end if;
+ end function "=";
+
+ function "/=" (L, R : TIME_VECTOR) return BOOLEAN is
+ begin
+ return not (L = R);
+ end function "/=";
+
+ function "<" (L, R : TIME_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length then
+ return L'length < R'length;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ if L(i) < R(i) then
+ return true;
+ else
+ return false;
+ end if;
+ end if;
+ end loop;
+ return false;
+ end if;
+ end function "<";
+
+ function "<=" (L, R : TIME_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length then
+ return L'length < R'length;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ if L(i) < R(i) then
+ return true;
+ else
+ return false;
+ end if;
+ end if;
+ end loop;
+ return true;
+ end if;
+ end function "<=";
+
+ function ">" (L, R : TIME_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length then
+ return L'length > R'length;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ if L(i) > R(i) then
+ return true;
+ else
+ return false;
+ end if;
+ end if;
+ end loop;
+ return false;
+ end if;
+ end function ">";
+
+ function ">=" (L, R : TIME_VECTOR) return BOOLEAN is
+ begin
+ if L'length /= R'length then
+ return L'length > R'length;
+ else
+ for i in l'range loop
+ if L(i) /= R(i) then
+ if L(i) > R(i) then
+ return true;
+ else
+ return false;
+ end if;
+ end if;
+ end loop;
+ return true;
+ end if;
+ end function ">=";
+-- function "&" (L: TIME_VECTOR; R: TIME_VECTOR)
+-- return TIME_VECTOR;
+-- function "&" (L: TIME_VECTOR; R: TIME) return TIME_VECTOR;
+-- function "&" (L: TIME; R: TIME_VECTOR) return TIME_VECTOR;
+-- function "&" (L: TIME; R: TIME) return TIME_VECTOR;
+
+ function MINIMUM (L, R : TIME_VECTOR) return TIME_VECTOR is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : TIME_VECTOR) return TIME_VECTOR is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function MINIMUM (L : TIME_VECTOR) return TIME is
+ variable result : TIME := TIME'high;
+ begin
+ for i in l'range loop
+ result := minimum (l(i), result);
+ end loop;
+ return result;
+ end function MINIMUM;
+
+ function MAXIMUM (L : TIME_VECTOR) return TIME is
+ variable result : TIME := TIME'low;
+ begin
+ for i in l'range loop
+ result := maximum (l(i), result);
+ end loop;
+ return result;
+ end function MAXIMUM;
+
+ function MINIMUM (L, R : FILE_OPEN_KIND) return FILE_OPEN_KIND is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : FILE_OPEN_KIND) return FILE_OPEN_KIND is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function TO_STRING (VALUE : FILE_OPEN_KIND) return STRING is
+ begin
+ return FILE_OPEN_KIND'image(VALUE);
+ end function TO_STRING;
+
+ function MINIMUM (L, R : FILE_OPEN_STATUS) return FILE_OPEN_STATUS is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function MINIMUM;
+
+ function MAXIMUM (L, R : FILE_OPEN_STATUS) return FILE_OPEN_STATUS is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function MAXIMUM;
+
+ function TO_STRING (VALUE : FILE_OPEN_STATUS) return STRING is
+ begin
+ return FILE_OPEN_STATUS'image(VALUE);
+ end function TO_STRING;
+
+ -- USED INTERNALLY!
+ function justify (
+ value : in STRING;
+ justified : in SIDE := right;
+ field : in width := 0)
+ return STRING is
+ constant VAL_LEN : INTEGER := value'length;
+ variable result : STRING (1 to field) := (others => ' ');
+ begin -- function justify
+ -- return value if field is too small
+ if VAL_LEN >= field then
+ return value;
+ end if;
+ if justified = left then
+ result(1 to VAL_LEN) := value;
+ elsif justified = right then
+ result(field - VAL_LEN + 1 to field) := value;
+ end if;
+ return result;
+ end function justify;
+
+ function TO_STRING (VALUE : TIME; UNIT : TIME) return STRING is
+ variable L : LINE; -- pointer
+ begin
+ deallocate (L);
+ write (L => L,
+ VALUE => VALUE,
+ UNIT => UNIT);
+ return L.all;
+ end function to_string;
+
+ function TO_STRING (VALUE : REAL; FORMAT : STRING) return STRING is
+ constant czero : CHARACTER := '0'; -- zero
+ constant half : REAL := 0.4999999999; -- almost 0.5
+ -- Log10 funciton
+ function log10 (arg : REAL) return INTEGER is
+ variable i : INTEGER := 1;
+ begin
+ if ((arg = 0.0)) then
+ return 0;
+ elsif arg >= 1.0 then
+ while arg >= 10.0**i loop
+ i := i + 1;
+ end loop;
+ return (i-1);
+ else
+ while arg < 10.0**i loop
+ i := i - 1;
+ end loop;
+ return i;
+ end if;
+ end function log10;
+ -- purpose: writes a fractional real number into a line
+ procedure writefrc (
+ variable L : inout LINE; -- LINE
+ variable cdes : in CHARACTER;
+ variable precision : in INTEGER; -- number of decimal places
+ variable value : in REAL) is -- real value
+ variable rvar : REAL; -- temp variable
+ variable xint : INTEGER;
+ variable xreal : REAL;
+ begin
+ xreal := (10.0**(-precision));
+ write (L, '.');
+ rvar := value;
+ for i in 1 to precision loop
+ rvar := rvar * 10.0;
+ xint := INTEGER(rvar-0.49999999999); -- round
+ write (L, xint);
+ rvar := rvar - REAL(xint);
+ xreal := xreal * 10.0;
+ if (cdes = 'g') and (rvar < xreal) then
+ exit;
+ end if;
+ end loop;
+ end procedure writefrc;
+ -- purpose: replace the "." with a "@", and "e" with "j" to get around
+ -- read ("6.") and read ("2e") issues.
+ function subdot (
+ constant format : STRING)
+ return STRING is
+ variable result : STRING (format'range);
+ begin
+ for i in format'range loop
+ if (format(i) = '.') then
+ result(i) := '@'; -- Because the parser reads 6.2 as REAL
+ elsif (format(i) = 'e') then
+ result(i) := 'j'; -- Because the parser read 2e as REAL
+ elsif (format(i) = 'E') then
+ result(i) := 'J'; -- Because the parser reads 2E as REAL
+ else
+ result(i) := format(i);
+ end if;
+ end loop;
+ return result;
+ end function subdot;
+ -- purpose: find a . in a STRING
+ function isdot (
+ constant format : STRING)
+ return BOOLEAN is
+ begin
+ for i in format'range loop
+ if (format(i) = '@') then
+ return true;
+ end if;
+ end loop;
+ return false;
+ end function isdot;
+ variable exp : INTEGER; -- integer version of baseexp
+ variable bvalue : REAL; -- base value
+ variable roundvar, tvar : REAL; -- Rounding values
+ variable frcptr : INTEGER; -- integer version of number
+ variable fwidth, dwidth : INTEGER; -- field width and decimal width
+ variable dash, dot : BOOLEAN := false;
+ variable cdes, ddes : CHARACTER := ' ';
+ variable L : LINE; -- line type
+ begin
+ -- Perform the same function that "printf" does
+ -- examples "%6.2f" "%-7e" "%g"
+ if not (format(format'left) = '%') then
+ report "to_string: Illegal format string """ & format & '"'
+ severity error;
+ return "";
+ end if;
+ L := new STRING'(subdot(format));
+ read (L, ddes); -- toss the '%'
+ case L.all(1) is
+ when '-' => dash := true;
+ when '@' => dash := true; -- in FP, a "-" and a "." are the same
+ when 'f' => cdes := 'f';
+ when 'F' => cdes := 'F';
+ when 'g' => cdes := 'g';
+ when 'G' => cdes := 'G';
+ when 'j' => cdes := 'e'; -- parser reads 5e as real, thus we sub j
+ when 'J' => cdes := 'E';
+ when '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9' => null;
+ when others =>
+ report "to_string: Illegal format string """ & format & '"'
+ severity error;
+ return "";
+ end case;
+ if (dash or (cdes /= ' ')) then
+ read (L, ddes); -- toss the next character
+ end if;
+ if (cdes = ' ') then
+ if (isdot(L.all)) then -- if you see a . two numbers
+ read (L, fwidth); -- read field width
+ read (L, ddes); -- toss the next character .
+ read (L, dwidth); -- read decimal width
+ else
+ read (L, fwidth); -- read field width
+ dwidth := 6; -- the default decimal width is 6
+ end if;
+ read (L, cdes);
+ if (cdes = 'j') then
+ cdes := 'e'; -- because 2e reads as "REAL".
+ elsif (cdes = 'J') then
+ cdes := 'E';
+ end if;
+ else
+ if (cdes = 'E' or cdes = 'e') then
+ fwidth := 10; -- default for e and E is %10.6e
+ else
+ fwidth := 0; -- default for f and g is %0.6f
+ end if;
+ dwidth := 6;
+ end if;
+ deallocate (L); -- reclame the pointer L.
+-- assert (not debug) report "Format: " & format & " "
+-- & INTEGER'image(fwidth) & "." & INTEGER'image(dwidth) & cdes
+-- severity note;
+ if (not (cdes = 'f' or cdes = 'F' or cdes = 'g' or cdes = 'G'
+ or cdes = 'e' or cdes = 'E')) then
+ report "to_string: Illegal format """ & format & '"' severity error;
+ return "";
+ end if;
+ if (VALUE < 0.0) then
+ bvalue := -value;
+ write (L, '-');
+ else
+ bvalue := value;
+ end if;
+ case cdes is
+ when 'e' | 'E' => -- 7.000E+01
+ exp := log10(bvalue);
+ roundvar := half*(10.0**(exp-dwidth));
+ bvalue := bvalue + roundvar; -- round
+ exp := log10(bvalue); -- because we CAN overflow
+ bvalue := bvalue * (10.0**(-exp)); -- result is D.XXXXXX
+ frcptr := INTEGER(bvalue-half); -- Write a single digit.
+ write (L, frcptr);
+ bvalue := bvalue - REAL(frcptr);
+ writefrc (-- Write out the fraction
+ L => L,
+ cdes => cdes,
+ precision => dwidth,
+ value => bvalue);
+ write (L, cdes); -- e or E
+ if (exp < 0) then
+ write (L, '-');
+ else
+ write (L, '+');
+ end if;
+ exp := abs(exp);
+ if (exp < 10) then -- we need another "0".
+ write (L, czero);
+ end if;
+ write (L, exp);
+ when 'f' | 'F' => -- 70.0
+ exp := log10(bvalue);
+ roundvar := half*(10.0**(-dwidth));
+ bvalue := bvalue + roundvar; -- round
+ exp := log10(bvalue); -- because we CAN overflow
+ if (exp < 0) then -- 0.X case
+ write (L, czero);
+ else -- loop because real'high > integer'high
+ while (exp >= 0) loop
+ frcptr := INTEGER(bvalue * (10.0**(-exp)) - half);
+ write (L, frcptr);
+ bvalue := bvalue - (REAL(frcptr) * (10.0**exp));
+ exp := exp-1;
+ end loop;
+ end if;
+ writefrc (
+ L => L,
+ cdes => cdes,
+ precision => dwidth,
+ value => bvalue);
+ when 'g' | 'G' => -- 70
+ exp := log10(bvalue);
+ roundvar := half*(10.0**(exp-dwidth)); -- small number
+ bvalue := bvalue + roundvar; -- round
+ exp := log10(bvalue); -- because we CAN overflow
+ frcptr := INTEGER(bvalue-half);
+ tvar := bvalue-roundvar - REAL(frcptr); -- even smaller number
+ if (exp < dwidth)
+ and (tvar < roundvar and tvar > -roundvar) then
+-- and ((bvalue-roundvar) = real(frcptr)) then
+ write (L, frcptr); -- Just a short integer, write it.
+ elsif (exp >= dwidth) or (exp < -4) then
+ -- in "e" format (modified)
+ bvalue := bvalue * (10.0**(-exp)); -- result is D.XXXXXX
+ frcptr := INTEGER(bvalue-half);
+ write (L, frcptr);
+ bvalue := bvalue - REAL(frcptr);
+ if (bvalue > (10.0**(1-dwidth))) then
+ dwidth := dwidth - 1;
+ writefrc (
+ L => L,
+ cdes => cdes,
+ precision => dwidth,
+ value => bvalue);
+ end if;
+ if (cdes = 'G') then
+ write (L, 'E');
+ else
+ write (L, 'e');
+ end if;
+ if (exp < 0) then
+ write (L, '-');
+ else
+ write (L, '+');
+ end if;
+ exp := abs(exp);
+ if (exp < 10) then
+ write (L, czero);
+ end if;
+ write (L, exp);
+ else
+ -- in "f" format (modified)
+ if (exp < 0) then
+ write (L, czero);
+ dwidth := maximum (dwidth, 4); -- if exp < -4 or > precision.
+ bvalue := bvalue - roundvar; -- recalculate rounding
+ roundvar := half*(10.0**(-dwidth));
+ bvalue := bvalue + roundvar;
+ else
+ write (L, frcptr); -- integer part (always small)
+ bvalue := bvalue - (REAL(frcptr));
+ dwidth := dwidth - exp - 1;
+ end if;
+ if (bvalue > roundvar) then
+ writefrc (
+ L => L,
+ cdes => cdes,
+ precision => dwidth,
+ value => bvalue);
+ end if;
+ end if;
+ when others => return "";
+ end case;
+ -- You don't truncate real numbers.
+-- if (dot) then -- truncate
+-- if (L.all'length > fwidth) then
+-- return justify (value => L.all (1 to fwidth),
+-- justified => RIGHT,
+-- field => fwidth);
+-- else
+-- return justify (value => L.all,
+-- justified => RIGHT,
+-- field => fwidth);
+-- end if;
+ if (dash) then -- fill to fwidth
+ return justify (value => L.all,
+ justified => left,
+ field => fwidth);
+ else
+ return justify (value => L.all,
+ justified => right,
+ field => fwidth);
+ end if;
+ end function to_string;
+
+end package body standard_additions;
diff --git a/testsuite/gna/ticket89/x_ieee_proposed/src/standard_textio_additions_c.vhdl b/testsuite/gna/ticket89/x_ieee_proposed/src/standard_textio_additions_c.vhdl new file mode 100644 index 0000000..aad96f5 --- /dev/null +++ b/testsuite/gna/ticket89/x_ieee_proposed/src/standard_textio_additions_c.vhdl @@ -0,0 +1,480 @@ +------------------------------------------------------------------------------
+-- "standard_textio_additions" package contains the additions to the built in
+-- "standard.textio" package.
+-- This package should be compiled into "ieee_proposed" and used as follows:
+-- use ieee_proposed.standard_textio_additions.all;
+-- Last Modified: $Date: 2007/03/13 18:25:58 $
+-- RCS ID: $Id: standard_textio_additions_c.vhdl,v 1.5 2007/03/13 18:25:58 l435385 Exp $
+--
+-- Created for VHDL-200X par, David Bishop (dbishop@vhdl.org)
+------------------------------------------------------------------------------
+use std.textio.all;
+package standard_textio_additions is
+
+-- procedure DEALLOCATE (P : inout LINE);
+
+-- procedure FLUSH (file F : TEXT);
+--
+-- function MINIMUM (L, R : SIDE) return SIDE;
+-- function MAXIMUM (L, R : SIDE) return SIDE;
+--
+-- function TO_STRING (VALUE : SIDE) return STRING;
+--
+-- function JUSTIFY (VALUE : STRING; JUSTIFIED : SIDE := right; FIELD : WIDTH := 0) return STRING;
+--
+-- procedure SREAD (L : inout LINE; VALUE : out STRING; STRLEN : out NATURAL);
+-- alias STRING_READ is SREAD [LINE, STRING, NATURAL];
+-- alias BREAD is READ [LINE, BIT_VECTOR, BOOLEAN];
+-- alias BREAD is READ [LINE, BIT_VECTOR];
+-- alias BINARY_READ is READ [LINE, BIT_VECTOR, BOOLEAN];
+-- alias BINARY_READ is READ [LINE, BIT_VECTOR];
+-- procedure OREAD (L : inout LINE; VALUE : out BIT_VECTOR; GOOD : out BOOLEAN);
+-- procedure OREAD (L : inout LINE; VALUE : out BIT_VECTOR);
+-- alias OCTAL_READ is OREAD [LINE, BIT_VECTOR, BOOLEAN];
+-- alias OCTAL_READ is OREAD [LINE, BIT_VECTOR];
+-- procedure HREAD (L : inout LINE; VALUE : out BIT_VECTOR; GOOD : out BOOLEAN);
+-- procedure HREAD (L : inout LINE; VALUE : out BIT_VECTOR);
+-- alias HEX_READ is HREAD [LINE, BIT_VECTOR, BOOLEAN];
+-- alias HEX_READ is HREAD [LINE, BIT_VECTOR];
+-- procedure TEE (file F : TEXT; L : inout LINE);
+-- procedure WRITE (L : inout LINE; VALUE : in REAL;
+-- FORMAT : in STRING);
+ alias SWRITE is WRITE [LINE, STRING, SIDE, WIDTH];
+ alias STRING_WRITE is WRITE [LINE, STRING, SIDE, WIDTH];
+ alias BWRITE is WRITE [LINE, BIT_VECTOR, SIDE, WIDTH];
+ alias BINARY_WRITE is WRITE [LINE, BIT_VECTOR, SIDE, WIDTH];
+ procedure OWRITE (L : inout LINE; VALUE : in BIT_VECTOR;
+ JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0);
+ alias OCTAL_WRITE is OWRITE [LINE, BIT_VECTOR, SIDE, WIDTH];
+ procedure HWRITE (L : inout LINE; VALUE : in BIT_VECTOR;
+ JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0);
+ alias HEX_WRITE is HWRITE [LINE, BIT_VECTOR, SIDE, WIDTH];
+
+end package standard_textio_additions;
+
+library ieee_proposed;
+use ieee_proposed.standard_additions.all;
+
+package body standard_textio_additions is
+ --pragma synthesis_off
+ constant NUS : STRING(2 to 1) := (others => ' '); -- NULL array
+ constant NBSP : CHARACTER := CHARACTER'val(160); -- space character
+
+ -- Writes L to a file without modifying the contents of the line
+ procedure TEE (file F : TEXT; L : inout LINE) is
+ begin
+ write (OUTPUT, L.all & LF);
+ writeline(F, L);
+ end procedure TEE;
+
+ procedure FLUSH (file F: TEXT) is -- Implicit
+ begin
+ file_close (F);
+ end procedure FLUSH;
+
+ -- Read and Write procedure for strings
+ procedure SREAD (L : inout LINE;
+ VALUE : out STRING;
+ STRLEN : out natural) is
+ variable ok : BOOLEAN;
+ variable c : CHARACTER;
+ -- Result is padded with space characters
+ variable result : STRING (1 to VALUE'length) := (others => ' ');
+ begin
+ VALUE := result;
+ loop -- skip white space
+ read(L, c, ok);
+ exit when (ok = false) or ((c /= ' ') and (c /= NBSP) and (c /= HT));
+ end loop;
+ -- Bail out if there was a bad read
+ if not ok then
+ STRLEN := 0;
+ return;
+ end if;
+ result (1) := c;
+ STRLEN := 1;
+ for i in 2 to VALUE'length loop
+ read(L, c, ok);
+ if (ok = false) or ((c = ' ') or (c = NBSP) or (c = HT)) then
+ exit;
+ else
+ result (i) := c;
+ end if;
+ STRLEN := i;
+ end loop;
+ VALUE := result;
+ end procedure SREAD;
+
+ -- Hex Read and Write procedures for bit_vector.
+ -- Procedure only visible internally.
+ procedure Char2QuadBits (C : CHARACTER;
+ RESULT : out BIT_VECTOR(3 downto 0);
+ 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 others =>
+ assert not ISSUE_ERROR report
+ "TEXTIO.HREAD Error: Read a '" & c &
+ "', expected a Hex character (0-F)." severity error;
+ GOOD := false;
+ end case;
+ end procedure Char2QuadBits;
+
+ procedure HREAD (L : inout LINE;
+ VALUE : out BIT_VECTOR;
+ GOOD : out BOOLEAN) is
+ variable ok : BOOLEAN;
+ variable c : CHARACTER;
+ constant ne : INTEGER := (VALUE'length+3)/4;
+ constant pad : INTEGER := ne*4 - VALUE'length;
+ variable sv : BIT_VECTOR (0 to ne*4 - 1) := (others => '0');
+ variable s : STRING(1 to ne-1);
+ begin
+ VALUE := (VALUE'range => '0');
+ loop -- skip white space
+ read(l, c, ok);
+ exit when (ok = false) or ((c /= ' ') and (c /= NBSP) and (c /= HT));
+ end loop;
+ -- Bail out if there was a bad read
+ if not ok then
+ GOOD := false;
+ return;
+ end if;
+ Char2QuadBits(c, sv(0 to 3), ok, false);
+ if not ok then
+ GOOD := false;
+ return;
+ end if;
+ read(L, s, ok);
+ if not ok then
+ GOOD := false;
+ return;
+ end if;
+ for i in 1 to ne-1 loop
+ Char2QuadBits(s(i), sv(4*i to 4*i+3), ok, false);
+ if not ok then
+ GOOD := false;
+ return;
+ end if;
+ end loop;
+ if or_reduce (sv (0 to pad-1)) = '1' then
+ GOOD := false; -- vector was truncated.
+ else
+ GOOD := true;
+ VALUE := sv (pad to sv'high);
+ end if;
+ end procedure HREAD;
+
+ procedure HREAD (L : inout LINE;
+ VALUE : out BIT_VECTOR) is
+ variable ok : BOOLEAN;
+ variable c : CHARACTER;
+ constant ne : INTEGER := (VALUE'length+3)/4;
+ constant pad : INTEGER := ne*4 - VALUE'length;
+ variable sv : BIT_VECTOR(0 to ne*4 - 1) := (others => '0');
+ variable s : STRING(1 to ne-1);
+ begin
+ VALUE := (VALUE'range => '0');
+ loop -- skip white space
+ read(l, c, ok);
+ exit when (ok = false) or ((c /= ' ') and (c /= NBSP) and (c /= HT));
+ end loop;
+ -- Bail out if there was a bad read
+ if not ok then
+ report "TEXTIO.HREAD Error: Failed skipping white space"
+ severity error;
+ return;
+ end if;
+ Char2QuadBits(c, sv(0 to 3), ok, true);
+ if not ok then
+ return;
+ end if;
+ read(L, s, ok);
+ if not ok then
+ report "TEXTIO.HREAD Error: Failed to read the STRING"
+ severity error;
+ return;
+ end if;
+ for i in 1 to ne-1 loop
+ Char2QuadBits(s(i), sv(4*i to 4*i+3), ok, true);
+ if not ok then
+ return;
+ end if;
+ end loop;
+ if or_reduce (sv (0 to pad-1)) = '1' then
+ report "TEXTIO.HREAD Error: Vector truncated"
+ severity error;
+ else
+ VALUE := sv (pad to sv'high);
+ end if;
+ end procedure HREAD;
+
+ procedure HWRITE (L : inout LINE;
+ VALUE : in BIT_VECTOR;
+ JUSTIFIED : in SIDE := right;
+ FIELD : in WIDTH := 0) is
+ begin
+ write (L => L,
+ VALUE => to_hstring(VALUE),
+ JUSTIFIED => JUSTIFIED,
+ FIELD => FIELD);
+ end procedure HWRITE;
+
+ -- Procedure only visible internally.
+ procedure Char2TriBits (C : CHARACTER;
+ RESULT : out BIT_VECTOR(2 downto 0);
+ 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 others =>
+ assert not ISSUE_ERROR
+ report
+ "TEXTIO.OREAD Error: Read a '" & c &
+ "', expected an Octal character (0-7)."
+ severity error;
+ GOOD := false;
+ end case;
+ end procedure Char2TriBits;
+
+ -- Read and Write procedures for Octal values
+ procedure OREAD (L : inout LINE;
+ VALUE : out BIT_VECTOR;
+ GOOD : out BOOLEAN) is
+ variable ok : BOOLEAN;
+ variable c : CHARACTER;
+ constant ne : INTEGER := (VALUE'length+2)/3;
+ constant pad : INTEGER := ne*3 - VALUE'length;
+ variable sv : BIT_VECTOR(0 to ne*3 - 1) := (others => '0');
+ variable s : STRING(1 to ne-1);
+ begin
+ VALUE := (VALUE'range => '0');
+ loop -- skip white space
+ read(l, c, ok);
+ exit when (ok = false) or ((c /= ' ') and (c /= NBSP) and (c /= HT));
+ end loop;
+ -- Bail out if there was a bad read
+ if not ok then
+ GOOD := false;
+ return;
+ end if;
+ Char2TriBits(c, sv(0 to 2), ok, false);
+ if not ok then
+ GOOD := false;
+ return;
+ end if;
+ read(L, s, ok);
+ if not ok then
+ GOOD := false;
+ return;
+ end if;
+ for i in 1 to ne-1 loop
+ Char2TriBits(s(i), sv(3*i to 3*i+2), ok, false);
+ if not ok then
+ GOOD := false;
+ return;
+ end if;
+ end loop;
+ if or_reduce (sv (0 to pad-1)) = '1' then
+ GOOD := false; -- vector was truncated.
+ else
+ GOOD := true;
+ VALUE := sv (pad to sv'high);
+ end if;
+ end procedure OREAD;
+
+ procedure OREAD (L : inout LINE;
+ VALUE : out BIT_VECTOR) is
+ variable c : CHARACTER;
+ variable ok : BOOLEAN;
+ constant ne : INTEGER := (VALUE'length+2)/3;
+ constant pad : INTEGER := ne*3 - VALUE'length;
+ variable sv : BIT_VECTOR(0 to ne*3 - 1) := (others => '0');
+ variable s : STRING(1 to ne-1);
+ begin
+ VALUE := (VALUE'range => '0');
+ loop -- skip white space
+ read(l, c, ok);
+ exit when (ok = false) or ((c /= ' ') and (c /= NBSP) and (c /= HT));
+ end loop;
+ -- Bail out if there was a bad read
+ if not ok then
+ report "TEXTIO.OREAD Error: Failed skipping white space"
+ severity error;
+ return;
+ end if;
+ Char2TriBits(c, sv(0 to 2), ok, true);
+ if not ok then
+ return;
+ end if;
+ read(L, s, ok);
+ if not ok then
+ report "TEXTIO.OREAD Error: Failed to read the STRING"
+ severity error;
+ return;
+ end if;
+ for i in 1 to ne-1 loop
+ Char2TriBits(s(i), sv(3*i to 3*i+2), ok, true);
+ if not ok then
+ return;
+ end if;
+ end loop;
+ if or_reduce (sv (0 to pad-1)) = '1' then
+ report "TEXTIO.OREAD Error: Vector truncated"
+ severity error;
+ else
+ VALUE := sv (pad to sv'high);
+ end if;
+ end procedure OREAD;
+
+ procedure OWRITE (L : inout LINE;
+ VALUE : in BIT_VECTOR;
+ JUSTIFIED : in SIDE := right;
+ FIELD : in WIDTH := 0) is
+ begin
+ write (L => L,
+ VALUE => to_ostring(VALUE),
+ JUSTIFIED => JUSTIFIED,
+ FIELD => FIELD);
+ end procedure OWRITE;
+
+ -- read and write for vector versions
+ -- These versions produce "value1, value2, value3 ...."
+ procedure read (L : inout LINE;
+ VALUE : out boolean_vector;
+ GOOD : out BOOLEAN) is
+ variable dummy : CHARACTER;
+ variable igood : BOOLEAN := true;
+ begin
+ for i in VALUE'range loop
+ read (L => L,
+ VALUE => VALUE(i),
+ GOOD => igood);
+ if (igood) and (i /= value'right) then
+ read (L => L,
+ VALUE => dummy, -- Toss the comma or seperator
+ good => igood);
+ end if;
+ if (not igood) then
+ good := false;
+ return;
+ end if;
+ end loop;
+ good := true;
+ end procedure read;
+
+ procedure read (L : inout LINE;
+ VALUE : out boolean_vector) is
+ variable dummy : CHARACTER;
+ variable igood : BOOLEAN;
+ begin
+ for i in VALUE'range loop
+ read (L => L,
+ VALUE => VALUE(i),
+ good => igood);
+ if (igood) and (i /= value'right) then
+ read (L => L,
+ VALUE => dummy, -- Toss the comma or seperator
+ good => igood);
+ end if;
+ if (not igood) then
+ report "STANDARD.STD_TEXTIO(BOOLEAN_VECTOR) "
+ & "Read error ecounted during vector read" severity error;
+ return;
+ end if;
+ end loop;
+ end procedure read;
+
+ procedure write (L : inout LINE;
+ VALUE : in boolean_vector;
+ JUSTIFIED : in SIDE := right;
+ FIELD : in WIDTH := 0) is
+ begin
+ for i in VALUE'range loop
+ write (L => L,
+ VALUE => VALUE(i),
+ JUSTIFIED => JUSTIFIED,
+ FIELD => FIELD);
+ if (i /= value'right) then
+ swrite (L, ", ");
+ end if;
+ end loop;
+ end procedure write;
+
+ procedure WRITE (L: inout LINE; VALUE: in REAL;
+ FORMAT: in STRING) is
+ begin
+--ET: Below modification is required to avoid the following error in iSim
+-- "FATAL_ERROR:Simulator:CompilerAssert.h:40:1.67 - Internal Compiler Error in file ../src/VhdlExpr.cpp at line 7524 Process will terminate. For technical support on this issue, please open a WebCase with this project attached at http://www.xilinx.com/support."
+-- swrite ( L => L, VALUE => to_string (VALUE, FORMAT));
+ swrite ( L, to_string (VALUE, FORMAT));
+ end procedure WRITE;
+
+ function justify (
+ value : STRING;
+ justified : SIDE := right;
+ field : width := 0)
+ return STRING is
+ constant VAL_LEN : INTEGER := value'length;
+ variable result : STRING (1 to field) := (others => ' ');
+ begin -- function justify
+ -- return value if field is too small
+ if VAL_LEN >= field then
+ return value;
+ end if;
+ if justified = left then
+ result(1 to VAL_LEN) := value;
+ elsif justified = right then
+ result(field - VAL_LEN + 1 to field) := value;
+ end if;
+ return result;
+ end function justify;
+
+ function to_string (
+ VALUE : SIDE) return STRING is
+ begin
+ return SIDE'image(VALUE);
+ end function to_string;
+
+ -- pragma synthesis_on
+ -- Will be implicit
+ function minimum (L, R : SIDE) return SIDE is
+ begin
+ if L > R then return R;
+ else return L;
+ end if;
+ end function minimum;
+
+ function maximum (L, R : SIDE) return SIDE is
+ begin
+ if L > R then return L;
+ else return R;
+ end if;
+ end function maximum;
+
+end package body standard_textio_additions;
diff --git a/testsuite/gna/ticket89/x_ieee_proposed/src/std_logic_1164_additions.vhdl b/testsuite/gna/ticket89/x_ieee_proposed/src/std_logic_1164_additions.vhdl new file mode 100644 index 0000000..3e42ef2 --- /dev/null +++ b/testsuite/gna/ticket89/x_ieee_proposed/src/std_logic_1164_additions.vhdl @@ -0,0 +1,1680 @@ +------------------------------------------------------------------------------
+-- "std_logic_1164_additions" package contains the additions to the standard
+-- "std_logic_1164" package proposed by the VHDL-200X-ft working group.
+-- This package should be compiled into "ieee_proposed" and used as follows:
+-- use ieee.std_logic_1164.all;
+-- use ieee_proposed.std_logic_1164_additions.all;
+-- Last Modified: $Date: 2010/09/22 18:32:33 $
+-- RCS ID: $Id: std_logic_1164_additions.vhdl,v 1.13 2010/09/22 18:32:33 l435385 Exp $
+--
+-- Created for VHDL-200X par, David Bishop (dbishop@vhdl.org)
+------------------------------------------------------------------------------
+library ieee;
+use ieee.std_logic_1164.all;
+use std.textio.all;
+package std_logic_1164_additions is
+
+ -- NOTE that in the new std_logic_1164, STD_LOGIC_VECTOR is a resolved
+ -- subtype of STD_ULOGIC_VECTOR. Thus there is no need for funcitons which
+ -- take inputs in STD_LOGIC_VECTOR.
+ -- For compatability with VHDL-2002, I have replicated all of these funcitons
+ -- here for STD_LOGIC_VECTOR.
+ -- new aliases
+ alias to_bv is ieee.std_logic_1164.To_bitvector [STD_LOGIC_VECTOR, BIT return BIT_VECTOR];
+ alias to_bv is ieee.std_logic_1164.To_bitvector [STD_ULOGIC_VECTOR, BIT return BIT_VECTOR];
+ alias to_bit_vector is ieee.std_logic_1164.To_bitvector [STD_LOGIC_VECTOR, BIT return BIT_VECTOR];
+ alias to_bit_vector is ieee.std_logic_1164.To_bitvector [STD_ULOGIC_VECTOR, BIT return BIT_VECTOR];
+ alias to_slv is ieee.std_logic_1164.To_StdLogicVector [BIT_VECTOR return STD_LOGIC_VECTOR];
+ alias to_slv is ieee.std_logic_1164.To_StdLogicVector [STD_ULOGIC_VECTOR return STD_LOGIC_VECTOR];
+ alias to_std_logic_vector is ieee.std_logic_1164.To_StdLogicVector [BIT_VECTOR return STD_LOGIC_VECTOR];
+ alias to_std_logic_vector is ieee.std_logic_1164.To_StdLogicVector [STD_ULOGIC_VECTOR return STD_LOGIC_VECTOR];
+ alias to_sulv is ieee.std_logic_1164.To_StdULogicVector [BIT_VECTOR return STD_ULOGIC_VECTOR];
+ alias to_sulv is ieee.std_logic_1164.To_StdULogicVector [STD_LOGIC_VECTOR return STD_ULOGIC_VECTOR];
+ alias to_std_ulogic_vector is ieee.std_logic_1164.To_StdULogicVector [BIT_VECTOR return STD_ULOGIC_VECTOR];
+ alias to_std_ulogic_vector is ieee.std_logic_1164.To_StdULogicVector [STD_LOGIC_VECTOR return STD_ULOGIC_VECTOR];
+
+ function TO_01 (s : STD_ULOGIC_VECTOR; xmap : STD_ULOGIC := '0')
+ return STD_ULOGIC_VECTOR;
+ function TO_01 (s : STD_ULOGIC; xmap : STD_ULOGIC := '0')
+ return STD_ULOGIC;
+ function TO_01 (s : BIT_VECTOR; xmap : STD_ULOGIC := '0')
+ return STD_ULOGIC_VECTOR;
+ function TO_01 (s : BIT; xmap : STD_ULOGIC := '0')
+ return STD_ULOGIC;
+
+ -------------------------------------------------------------------
+ -- overloaded shift operators
+ -------------------------------------------------------------------
+
+ function "sll" (l : STD_LOGIC_VECTOR; r : INTEGER) return STD_LOGIC_VECTOR;
+ function "sll" (l : STD_ULOGIC_VECTOR; r : INTEGER) return STD_ULOGIC_VECTOR;
+
+ function "srl" (l : STD_LOGIC_VECTOR; r : INTEGER) return STD_LOGIC_VECTOR;
+ function "srl" (l : STD_ULOGIC_VECTOR; r : INTEGER) return STD_ULOGIC_VECTOR;
+
+ function "rol" (l : STD_LOGIC_VECTOR; r : INTEGER) return STD_LOGIC_VECTOR;
+ function "rol" (l : STD_ULOGIC_VECTOR; r : INTEGER) return STD_ULOGIC_VECTOR;
+
+ function "ror" (l : STD_LOGIC_VECTOR; r : INTEGER) return STD_LOGIC_VECTOR;
+ function "ror" (l : STD_ULOGIC_VECTOR; r : INTEGER) return STD_ULOGIC_VECTOR;
+ -------------------------------------------------------------------
+ -- vector/scalar overloaded logical operators
+ -------------------------------------------------------------------
+ function "and" (l : STD_LOGIC_VECTOR; r : STD_ULOGIC) return STD_LOGIC_VECTOR;
+ function "and" (l : STD_ULOGIC_VECTOR; r : STD_ULOGIC) return STD_ULOGIC_VECTOR;
+ function "and" (l : STD_ULOGIC; r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "and" (l : STD_ULOGIC; r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
+ function "nand" (l : STD_LOGIC_VECTOR; r : STD_ULOGIC) return STD_LOGIC_VECTOR;
+ function "nand" (l : STD_ULOGIC_VECTOR; r : STD_ULOGIC) return STD_ULOGIC_VECTOR;
+ function "nand" (l : STD_ULOGIC; r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "nand" (l : STD_ULOGIC; r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
+ function "or" (l : STD_LOGIC_VECTOR; r : STD_ULOGIC) return STD_LOGIC_VECTOR;
+ function "or" (l : STD_ULOGIC_VECTOR; r : STD_ULOGIC) return STD_ULOGIC_VECTOR;
+ function "or" (l : STD_ULOGIC; r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "or" (l : STD_ULOGIC; r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
+ function "nor" (l : STD_LOGIC_VECTOR; r : STD_ULOGIC) return STD_LOGIC_VECTOR;
+ function "nor" (l : STD_ULOGIC_VECTOR; r : STD_ULOGIC) return STD_ULOGIC_VECTOR;
+ function "nor" (l : STD_ULOGIC; r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "nor" (l : STD_ULOGIC; r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
+ function "xor" (l : STD_LOGIC_VECTOR; r : STD_ULOGIC) return STD_LOGIC_VECTOR;
+ function "xor" (l : STD_ULOGIC_VECTOR; r : STD_ULOGIC) return STD_ULOGIC_VECTOR;
+ function "xor" (l : STD_ULOGIC; r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "xor" (l : STD_ULOGIC; r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
+ function "xnor" (l : STD_LOGIC_VECTOR; r : STD_ULOGIC) return STD_LOGIC_VECTOR;
+ function "xnor" (l : STD_ULOGIC_VECTOR; r : STD_ULOGIC) return STD_ULOGIC_VECTOR;
+ function "xnor" (l : STD_ULOGIC; r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "xnor" (l : STD_ULOGIC; r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
+
+ -------------------------------------------------------------------
+ -- vector-reduction functions.
+ -- "and" functions default to "1", or defaults to "0"
+ -------------------------------------------------------------------
+ -----------------------------------------------------------------------------
+ -- %%% Replace the "_reduce" functions with the ones commented out below.
+ -----------------------------------------------------------------------------
+ -- function "and" ( l : std_logic_vector ) RETURN std_ulogic;
+ -- function "and" ( l : std_ulogic_vector ) RETURN std_ulogic;
+ -- function "nand" ( l : std_logic_vector ) RETURN std_ulogic;
+ -- function "nand" ( l : std_ulogic_vector ) RETURN std_ulogic;
+ -- function "or" ( l : std_logic_vector ) RETURN std_ulogic;
+ -- function "or" ( l : std_ulogic_vector ) RETURN std_ulogic;
+ -- function "nor" ( l : std_logic_vector ) RETURN std_ulogic;
+ -- function "nor" ( l : std_ulogic_vector ) RETURN std_ulogic;
+ -- function "xor" ( l : std_logic_vector ) RETURN std_ulogic;
+ -- function "xor" ( l : std_ulogic_vector ) RETURN std_ulogic;
+ -- function "xnor" ( l : std_logic_vector ) RETURN std_ulogic;
+ -- function "xnor" ( l : std_ulogic_vector ) RETURN std_ulogic;
+ function and_reduce (l : STD_LOGIC_VECTOR) return STD_ULOGIC;
+ function and_reduce (l : STD_ULOGIC_VECTOR) return STD_ULOGIC;
+ function nand_reduce (l : STD_LOGIC_VECTOR) return STD_ULOGIC;
+ function nand_reduce (l : STD_ULOGIC_VECTOR) return STD_ULOGIC;
+ function or_reduce (l : STD_LOGIC_VECTOR) return STD_ULOGIC;
+ function or_reduce (l : STD_ULOGIC_VECTOR) return STD_ULOGIC;
+ function nor_reduce (l : STD_LOGIC_VECTOR) return STD_ULOGIC;
+ function nor_reduce (l : STD_ULOGIC_VECTOR) return STD_ULOGIC;
+ function xor_reduce (l : STD_LOGIC_VECTOR) return STD_ULOGIC;
+ function xor_reduce (l : STD_ULOGIC_VECTOR) return STD_ULOGIC;
+ function xnor_reduce (l : STD_LOGIC_VECTOR) return STD_ULOGIC;
+ function xnor_reduce (l : STD_ULOGIC_VECTOR) return STD_ULOGIC;
+ -------------------------------------------------------------------
+ -- ?= operators, same functionality as 1076.3 1994 std_match
+ -------------------------------------------------------------------
+-- FUNCTION "?=" ( l, r : std_ulogic ) RETURN std_ulogic;
+-- FUNCTION "?=" ( l, r : std_logic_vector ) RETURN std_ulogic;
+-- FUNCTION "?=" ( l, r : std_ulogic_vector ) RETURN std_ulogic;
+-- FUNCTION "?/=" ( l, r : std_ulogic ) RETURN std_ulogic;
+-- FUNCTION "?/=" ( l, r : std_logic_vector ) RETURN std_ulogic;
+-- FUNCTION "?/=" ( l, r : std_ulogic_vector ) RETURN std_ulogic;
+-- FUNCTION "?>" ( l, r : std_ulogic ) RETURN std_ulogic;
+-- FUNCTION "?>=" ( l, r : std_ulogic ) RETURN std_ulogic;
+-- FUNCTION "?<" ( l, r : std_ulogic ) RETURN std_ulogic;
+-- FUNCTION "?<=" ( l, r : std_ulogic ) RETURN std_ulogic;
+
+ function \?=\ (l, r : STD_ULOGIC) return STD_ULOGIC;
+ function \?=\ (l, r : STD_LOGIC_VECTOR) return STD_ULOGIC;
+ function \?=\ (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC;
+ function \?/=\ (l, r : STD_ULOGIC) return STD_ULOGIC;
+ function \?/=\ (l, r : STD_LOGIC_VECTOR) return STD_ULOGIC;
+ function \?/=\ (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC;
+ function \?>\ (l, r : STD_ULOGIC) return STD_ULOGIC;
+ function \?>=\ (l, r : STD_ULOGIC) return STD_ULOGIC;
+ function \?<\ (l, r : STD_ULOGIC) return STD_ULOGIC;
+ function \?<=\ (l, r : STD_ULOGIC) return STD_ULOGIC;
+
+
+ -- "??" operator, converts a std_ulogic to a boolean.
+ --%%% Uncomment the following operators
+ -- FUNCTION "??" (S : STD_ULOGIC) RETURN BOOLEAN;
+ --%%% REMOVE the following funciton (for testing only)
+ function \??\ (S : STD_ULOGIC) return BOOLEAN;
+
+ -- rtl_synthesis off
+-- pragma synthesis_off
+ function to_string (value : STD_ULOGIC) return STRING;
+ function to_string (value : STD_ULOGIC_VECTOR) return STRING;
+ function to_string (value : STD_LOGIC_VECTOR) return STRING;
+
+ -- explicitly defined operations
+
+ alias TO_BSTRING is TO_STRING [STD_ULOGIC_VECTOR return STRING];
+ alias TO_BINARY_STRING is TO_STRING [STD_ULOGIC_VECTOR return STRING];
+ function TO_OSTRING (VALUE : STD_ULOGIC_VECTOR) return STRING;
+ alias TO_OCTAL_STRING is TO_OSTRING [STD_ULOGIC_VECTOR return STRING];
+ function TO_HSTRING (VALUE : STD_ULOGIC_VECTOR) return STRING;
+ alias TO_HEX_STRING is TO_HSTRING [STD_ULOGIC_VECTOR return STRING];
+
+ procedure READ (L : inout LINE; VALUE : out STD_ULOGIC; GOOD : out BOOLEAN);
+ procedure READ (L : inout LINE; VALUE : out STD_ULOGIC);
+
+ procedure READ (L : inout LINE; VALUE : out STD_ULOGIC_VECTOR; GOOD : out BOOLEAN);
+ procedure READ (L : inout LINE; VALUE : out STD_ULOGIC_VECTOR);
+
+ procedure WRITE (L : inout LINE; VALUE : in STD_ULOGIC;
+ JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0);
+
+ procedure WRITE (L : inout LINE; VALUE : in STD_ULOGIC_VECTOR;
+ JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0);
+
+ alias BREAD is READ [LINE, STD_ULOGIC_VECTOR, BOOLEAN];
+ alias BREAD is READ [LINE, STD_ULOGIC_VECTOR];
+ alias BINARY_READ is READ [LINE, STD_ULOGIC_VECTOR, BOOLEAN];
+ alias BINARY_READ is READ [LINE, STD_ULOGIC_VECTOR];
+
+ procedure OREAD (L : inout LINE; VALUE : out STD_ULOGIC_VECTOR; GOOD : out BOOLEAN);
+ procedure OREAD (L : inout LINE; VALUE : out STD_ULOGIC_VECTOR);
+ alias OCTAL_READ is OREAD [LINE, STD_ULOGIC_VECTOR, BOOLEAN];
+ alias OCTAL_READ is OREAD [LINE, STD_ULOGIC_VECTOR];
+
+ procedure HREAD (L : inout LINE; VALUE : out STD_ULOGIC_VECTOR; GOOD : out BOOLEAN);
+ procedure HREAD (L : inout LINE; VALUE : out STD_ULOGIC_VECTOR);
+ alias HEX_READ is HREAD [LINE, STD_ULOGIC_VECTOR, BOOLEAN];
+ alias HEX_READ is HREAD [LINE, STD_ULOGIC_VECTOR];
+
+ 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];
+
+ alias TO_BSTRING is TO_STRING [STD_LOGIC_VECTOR return STRING];
+ alias TO_BINARY_STRING is TO_STRING [STD_LOGIC_VECTOR return STRING];
+ function TO_OSTRING (VALUE : STD_LOGIC_VECTOR) return STRING;
+ alias TO_OCTAL_STRING is TO_OSTRING [STD_LOGIC_VECTOR return STRING];
+ function TO_HSTRING (VALUE : STD_LOGIC_VECTOR) return STRING;
+ alias TO_HEX_STRING is TO_HSTRING [STD_LOGIC_VECTOR return STRING];
+
+ procedure READ (L : inout LINE; VALUE : out STD_LOGIC_VECTOR; GOOD : out BOOLEAN);
+ procedure READ (L : inout LINE; VALUE : out STD_LOGIC_VECTOR);
+
+ procedure WRITE (L : inout LINE; VALUE : in STD_LOGIC_VECTOR;
+ JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0);
+
+ alias BREAD is READ [LINE, STD_LOGIC_VECTOR, BOOLEAN];
+ alias BREAD is READ [LINE, STD_LOGIC_VECTOR];
+ alias BINARY_READ is READ [LINE, STD_LOGIC_VECTOR, BOOLEAN];
+ alias BINARY_READ is READ [LINE, STD_LOGIC_VECTOR];
+
+ procedure OREAD (L : inout LINE; VALUE : out STD_LOGIC_VECTOR; GOOD : out BOOLEAN);
+ procedure OREAD (L : inout LINE; VALUE : out STD_LOGIC_VECTOR);
+ alias OCTAL_READ is OREAD [LINE, STD_LOGIC_VECTOR, BOOLEAN];
+ alias OCTAL_READ is OREAD [LINE, STD_LOGIC_VECTOR];
+
+ procedure HREAD (L : inout LINE; VALUE : out STD_LOGIC_VECTOR; GOOD : out BOOLEAN);
+ procedure HREAD (L : inout LINE; VALUE : out STD_LOGIC_VECTOR);
+ alias HEX_READ is HREAD [LINE, STD_LOGIC_VECTOR, BOOLEAN];
+ alias HEX_READ is HREAD [LINE, STD_LOGIC_VECTOR];
+
+ alias BWRITE is WRITE [LINE, STD_LOGIC_VECTOR, SIDE, WIDTH];
+ alias BINARY_WRITE is WRITE [LINE, STD_LOGIC_VECTOR, SIDE, WIDTH];
+
+ procedure OWRITE (L : inout LINE; VALUE : in STD_LOGIC_VECTOR;
+ JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0);
+ alias OCTAL_WRITE is OWRITE [LINE, STD_LOGIC_VECTOR, SIDE, WIDTH];
+
+ procedure HWRITE (L : inout LINE; VALUE : in STD_LOGIC_VECTOR;
+ JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0);
+ alias HEX_WRITE is HWRITE [LINE, STD_LOGIC_VECTOR, SIDE, WIDTH];
+ -- rtl_synthesis on
+-- pragma synthesis_on
+ function maximum (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
+ function maximum (l, r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function maximum (l, r : STD_ULOGIC) return STD_ULOGIC;
+ function minimum (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR;
+ function minimum (l, r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function minimum (l, r : STD_ULOGIC) return STD_ULOGIC;
+end package std_logic_1164_additions;
+
+package body std_logic_1164_additions is
+ type stdlogic_table is array(STD_ULOGIC, STD_ULOGIC) of STD_ULOGIC;
+ -----------------------------------------------------------------------------
+ -- New/updated funcitons for VHDL-200X fast track
+ -----------------------------------------------------------------------------
+ -- to_01
+ -------------------------------------------------------------------
+ function TO_01 (s : STD_ULOGIC_VECTOR; xmap : STD_ULOGIC := '0')
+ return STD_ULOGIC_VECTOR is
+ variable RESULT : STD_ULOGIC_VECTOR(s'length-1 downto 0);
+ variable BAD_ELEMENT : BOOLEAN := false;
+ alias XS : STD_ULOGIC_VECTOR(s'length-1 downto 0) is s;
+ begin
+ for I in RESULT'range loop
+ case XS(I) is
+ when '0' | 'L' => RESULT(I) := '0';
+ when '1' | 'H' => RESULT(I) := '1';
+ when others => BAD_ELEMENT := true;
+ end case;
+ end loop;
+ if BAD_ELEMENT then
+ for I in RESULT'range loop
+ 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
+ when '0' | 'L' => RETURN '0';
+ when '1' | 'H' => RETURN '1';
+ 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
+ variable RESULT : STD_ULOGIC_VECTOR(s'length-1 downto 0);
+ alias XS : BIT_VECTOR(s'length-1 downto 0) is s;
+ begin
+ for I in RESULT'range loop
+ case XS(I) is
+ when '0' => RESULT(I) := '0';
+ when '1' => RESULT(I) := '1';
+ end case;
+ 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
+ when '0' => RETURN '0';
+ when '1' => RETURN '1';
+ end case;
+ end function TO_01;
+-- end Bugzilla issue #148
+ -------------------------------------------------------------------
+
+ -------------------------------------------------------------------
+ -- overloaded shift operators
+ -------------------------------------------------------------------
+
+ -------------------------------------------------------------------
+ -- sll
+ -------------------------------------------------------------------
+ function "sll" (l : STD_LOGIC_VECTOR; r : INTEGER) return STD_LOGIC_VECTOR is
+ alias lv : STD_LOGIC_VECTOR (1 to l'length) is l;
+ variable result : STD_LOGIC_VECTOR (1 to l'length) := (others => '0');
+ begin
+ if r >= 0 then
+ result(1 to l'length - r) := lv(r + 1 to l'length);
+ else
+ result := l srl -r;
+ end if;
+ return result;
+ end function "sll";
+ -------------------------------------------------------------------
+ function "sll" (l : STD_ULOGIC_VECTOR; r : INTEGER) 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 => '0');
+ begin
+ if r >= 0 then
+ result(1 to l'length - r) := lv(r + 1 to l'length);
+ else
+ result := l srl -r;
+ end if;
+ return result;
+ end function "sll";
+
+ -------------------------------------------------------------------
+ -- srl
+ -------------------------------------------------------------------
+ function "srl" (l : STD_LOGIC_VECTOR; r : INTEGER) return STD_LOGIC_VECTOR is
+ alias lv : STD_LOGIC_VECTOR (1 to l'length) is l;
+ variable result : STD_LOGIC_VECTOR (1 to l'length) := (others => '0');
+ begin
+ if r >= 0 then
+ result(r + 1 to l'length) := lv(1 to l'length - r);
+ else
+ result := l sll -r;
+ end if;
+ return result;
+ end function "srl";
+ -------------------------------------------------------------------
+ function "srl" (l : STD_ULOGIC_VECTOR; r : INTEGER) 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 => '0');
+ begin
+ if r >= 0 then
+ result(r + 1 to l'length) := lv(1 to l'length - r);
+ else
+ result := l sll -r;
+ end if;
+ return result;
+ end function "srl";
+
+ -------------------------------------------------------------------
+ -- rol
+ -------------------------------------------------------------------
+ function "rol" (l : STD_LOGIC_VECTOR; r : INTEGER) return STD_LOGIC_VECTOR is
+ alias lv : STD_LOGIC_VECTOR (1 to l'length) is l;
+ variable result : STD_LOGIC_VECTOR (1 to l'length);
+ constant rm : INTEGER := r mod l'length;
+ begin
+ if r >= 0 then
+ result(1 to l'length - rm) := lv(rm + 1 to l'length);
+ result(l'length - rm + 1 to l'length) := lv(1 to rm);
+ else
+ result := l ror -r;
+ end if;
+ return result;
+ end function "rol";
+ -------------------------------------------------------------------
+ function "rol" (l : STD_ULOGIC_VECTOR; r : INTEGER) 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);
+ constant rm : INTEGER := r mod l'length;
+ begin
+ if r >= 0 then
+ result(1 to l'length - rm) := lv(rm + 1 to l'length);
+ result(l'length - rm + 1 to l'length) := lv(1 to rm);
+ else
+ result := l ror -r;
+ end if;
+ return result;
+ end function "rol";
+
+ -------------------------------------------------------------------
+ -- ror
+ -------------------------------------------------------------------
+ function "ror" (l : STD_LOGIC_VECTOR; r : INTEGER) return STD_LOGIC_VECTOR is
+ alias lv : STD_LOGIC_VECTOR (1 to l'length) is l;
+ variable result : STD_LOGIC_VECTOR (1 to l'length) := (others => '0');
+ constant rm : INTEGER := r mod l'length;
+ begin
+ if r >= 0 then
+ result(rm + 1 to l'length) := lv(1 to l'length - rm);
+ result(1 to rm) := lv(l'length - rm + 1 to l'length);
+ else
+ result := l rol -r;
+ end if;
+ return result;
+ end function "ror";
+ -------------------------------------------------------------------
+ function "ror" (l : STD_ULOGIC_VECTOR; r : INTEGER) 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 => '0');
+ constant rm : INTEGER := r mod l'length;
+ begin
+ if r >= 0 then
+ result(rm + 1 to l'length) := lv(1 to l'length - rm);
+ result(1 to rm) := lv(l'length - rm + 1 to l'length);
+ else
+ result := l rol -r;
+ end if;
+ return result;
+ end function "ror";
+ -------------------------------------------------------------------
+ -- vector/scalar overloaded logical operators
+ -------------------------------------------------------------------
+
+ -------------------------------------------------------------------
+ -- and
+ -------------------------------------------------------------------
+ function "and" (l : STD_LOGIC_VECTOR; r : STD_ULOGIC) return STD_LOGIC_VECTOR is
+ alias lv : STD_LOGIC_VECTOR (1 to l'length) is l;
+ variable result : STD_LOGIC_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := "and" (lv(i), r);
+ end loop;
+ return result;
+ end function "and";
+ -------------------------------------------------------------------
+ function "and" (l : STD_ULOGIC_VECTOR; r : STD_ULOGIC) 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);
+ begin
+ for i in result'range loop
+ result(i) := "and" (lv(i), r);
+ end loop;
+ return result;
+ end function "and";
+ -------------------------------------------------------------------
+ function "and" (l : STD_ULOGIC; r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ alias rv : STD_LOGIC_VECTOR (1 to r'length) is r;
+ variable result : STD_LOGIC_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := "and" (l, rv(i));
+ end loop;
+ return result;
+ end function "and";
+ -------------------------------------------------------------------
+ function "and" (l : STD_ULOGIC; r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is
+ alias rv : STD_ULOGIC_VECTOR (1 to r'length) is r;
+ variable result : STD_ULOGIC_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := "and" (l, rv(i));
+ end loop;
+ return result;
+ end function "and";
+
+ -------------------------------------------------------------------
+ -- nand
+ -------------------------------------------------------------------
+ function "nand" (l : STD_LOGIC_VECTOR; r : STD_ULOGIC) return STD_LOGIC_VECTOR is
+ alias lv : STD_LOGIC_VECTOR (1 to l'length) is l;
+ variable result : STD_LOGIC_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := "not"("and" (lv(i), r));
+ end loop;
+ return result;
+ end function "nand";
+ -------------------------------------------------------------------
+ function "nand" (l : STD_ULOGIC_VECTOR; r : STD_ULOGIC) 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);
+ begin
+ for i in result'range loop
+ result(i) := "not"("and" (lv(i), r));
+ end loop;
+ return result;
+ end function "nand";
+ -------------------------------------------------------------------
+ function "nand" (l : STD_ULOGIC; r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ alias rv : STD_LOGIC_VECTOR (1 to r'length) is r;
+ variable result : STD_LOGIC_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := "not"("and" (l, rv(i)));
+ end loop;
+ return result;
+ end function "nand";
+ -------------------------------------------------------------------
+ function "nand" (l : STD_ULOGIC; r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is
+ alias rv : STD_ULOGIC_VECTOR (1 to r'length) is r;
+ variable result : STD_ULOGIC_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := "not"("and" (l, rv(i)));
+ end loop;
+ return result;
+ end function "nand";
+
+ -------------------------------------------------------------------
+ -- or
+ -------------------------------------------------------------------
+ function "or" (l : STD_LOGIC_VECTOR; r : STD_ULOGIC) return STD_LOGIC_VECTOR is
+ alias lv : STD_LOGIC_VECTOR (1 to l'length) is l;
+ variable result : STD_LOGIC_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := "or" (lv(i), r);
+ end loop;
+ return result;
+ end function "or";
+ -------------------------------------------------------------------
+ function "or" (l : STD_ULOGIC_VECTOR; r : STD_ULOGIC) 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);
+ begin
+ for i in result'range loop
+ result(i) := "or" (lv(i), r);
+ end loop;
+ return result;
+ end function "or";
+ -------------------------------------------------------------------
+ function "or" (l : STD_ULOGIC; r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ alias rv : STD_LOGIC_VECTOR (1 to r'length) is r;
+ variable result : STD_LOGIC_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := "or" (l, rv(i));
+ end loop;
+ return result;
+ end function "or";
+ -------------------------------------------------------------------
+ function "or" (l : STD_ULOGIC; r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is
+ alias rv : STD_ULOGIC_VECTOR (1 to r'length) is r;
+ variable result : STD_ULOGIC_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := "or" (l, rv(i));
+ end loop;
+ return result;
+ end function "or";
+
+ -------------------------------------------------------------------
+ -- nor
+ -------------------------------------------------------------------
+ function "nor" (l : STD_LOGIC_VECTOR; r : STD_ULOGIC) return STD_LOGIC_VECTOR is
+ alias lv : STD_LOGIC_VECTOR (1 to l'length) is l;
+ variable result : STD_LOGIC_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := "not"("or" (lv(i), r));
+ end loop;
+ return result;
+ end function "nor";
+ -------------------------------------------------------------------
+ function "nor" (l : STD_ULOGIC_VECTOR; r : STD_ULOGIC) 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);
+ begin
+ for i in result'range loop
+ result(i) := "not"("or" (lv(i), r));
+ end loop;
+ return result;
+ end function "nor";
+ -------------------------------------------------------------------
+ function "nor" (l : STD_ULOGIC; r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ alias rv : STD_LOGIC_VECTOR (1 to r'length) is r;
+ variable result : STD_LOGIC_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := "not"("or" (l, rv(i)));
+ end loop;
+ return result;
+ end function "nor";
+ -------------------------------------------------------------------
+ function "nor" (l : STD_ULOGIC; r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is
+ alias rv : STD_ULOGIC_VECTOR (1 to r'length) is r;
+ variable result : STD_ULOGIC_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := "not"("or" (l, rv(i)));
+ end loop;
+ return result;
+ end function "nor";
+
+ -------------------------------------------------------------------
+ -- xor
+ -------------------------------------------------------------------
+ function "xor" (l : STD_LOGIC_VECTOR; r : STD_ULOGIC) return STD_LOGIC_VECTOR is
+ alias lv : STD_LOGIC_VECTOR (1 to l'length) is l;
+ variable result : STD_LOGIC_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := "xor" (lv(i), r);
+ end loop;
+ return result;
+ end function "xor";
+ -------------------------------------------------------------------
+ function "xor" (l : STD_ULOGIC_VECTOR; r : STD_ULOGIC) 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);
+ begin
+ for i in result'range loop
+ result(i) := "xor" (lv(i), r);
+ end loop;
+ return result;
+ end function "xor";
+ -------------------------------------------------------------------
+ function "xor" (l : STD_ULOGIC; r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ alias rv : STD_LOGIC_VECTOR (1 to r'length) is r;
+ variable result : STD_LOGIC_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := "xor" (l, rv(i));
+ end loop;
+ return result;
+ end function "xor";
+ -------------------------------------------------------------------
+ function "xor" (l : STD_ULOGIC; r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is
+ alias rv : STD_ULOGIC_VECTOR (1 to r'length) is r;
+ variable result : STD_ULOGIC_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := "xor" (l, rv(i));
+ end loop;
+ return result;
+ end function "xor";
+
+ -------------------------------------------------------------------
+ -- xnor
+ -------------------------------------------------------------------
+ function "xnor" (l : STD_LOGIC_VECTOR; r : STD_ULOGIC) return STD_LOGIC_VECTOR is
+ alias lv : STD_LOGIC_VECTOR (1 to l'length) is l;
+ variable result : STD_LOGIC_VECTOR (1 to l'length);
+ begin
+ for i in result'range loop
+ result(i) := "not"("xor" (lv(i), r));
+ end loop;
+ return result;
+ end function "xnor";
+ -------------------------------------------------------------------
+ function "xnor" (l : STD_ULOGIC_VECTOR; r : STD_ULOGIC) 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);
+ begin
+ for i in result'range loop
+ result(i) := "not"("xor" (lv(i), r));
+ end loop;
+ return result;
+ end function "xnor";
+ -------------------------------------------------------------------
+ function "xnor" (l : STD_ULOGIC; r : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ alias rv : STD_LOGIC_VECTOR (1 to r'length) is r;
+ variable result : STD_LOGIC_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := "not"("xor" (l, rv(i)));
+ end loop;
+ return result;
+ end function "xnor";
+ -------------------------------------------------------------------
+ function "xnor" (l : STD_ULOGIC; r : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is
+ alias rv : STD_ULOGIC_VECTOR (1 to r'length) is r;
+ variable result : STD_ULOGIC_VECTOR (1 to r'length);
+ begin
+ for i in result'range loop
+ result(i) := "not"("xor" (l, rv(i)));
+ end loop;
+ return result;
+ end function "xnor";
+
+ -------------------------------------------------------------------
+ -- vector-reduction functions
+ -------------------------------------------------------------------
+
+ -------------------------------------------------------------------
+ -- and
+ -------------------------------------------------------------------
+ function and_reduce (l : STD_LOGIC_VECTOR) return STD_ULOGIC is
+ begin
+ return and_reduce (to_StdULogicVector (l));
+ end function and_reduce;
+ -------------------------------------------------------------------
+ function and_reduce (l : STD_ULOGIC_VECTOR) return STD_ULOGIC is
+ variable result : STD_ULOGIC := '1';
+ begin
+ for i in l'reverse_range loop
+ result := (l(i) and result);
+ end loop;
+ return result;
+ end function and_reduce;
+
+ -------------------------------------------------------------------
+ -- nand
+ -------------------------------------------------------------------
+ function nand_reduce (l : STD_LOGIC_VECTOR) return STD_ULOGIC is
+ begin
+ return not (and_reduce(to_StdULogicVector(l)));
+ end function nand_reduce;
+ -------------------------------------------------------------------
+ function nand_reduce (l : STD_ULOGIC_VECTOR) return STD_ULOGIC is
+ begin
+ return not (and_reduce(l));
+ end function nand_reduce;
+
+ -------------------------------------------------------------------
+ -- or
+ -------------------------------------------------------------------
+ function or_reduce (l : STD_LOGIC_VECTOR) return STD_ULOGIC is
+ begin
+ return or_reduce (to_StdULogicVector (l));
+ end function or_reduce;
+ -------------------------------------------------------------------
+ function or_reduce (l : STD_ULOGIC_VECTOR) return STD_ULOGIC is
+ variable result : STD_ULOGIC := '0';
+ begin
+ for i in l'reverse_range loop
+ result := (l(i) or result);
+ end loop;
+ return result;
+ end function or_reduce;
+
+ -------------------------------------------------------------------
+ -- nor
+ -------------------------------------------------------------------
+ function nor_reduce (l : STD_LOGIC_VECTOR) return STD_ULOGIC is
+ begin
+ return "not"(or_reduce(To_StdULogicVector(l)));
+ end function nor_reduce;
+ -------------------------------------------------------------------
+ function nor_reduce (l : STD_ULOGIC_VECTOR) return STD_ULOGIC is
+ begin
+ return "not"(or_reduce(l));
+ end function nor_reduce;
+
+ -------------------------------------------------------------------
+ -- xor
+ -------------------------------------------------------------------
+ function xor_reduce (l : STD_LOGIC_VECTOR) return STD_ULOGIC is
+ begin
+ return xor_reduce (to_StdULogicVector (l));
+ end function xor_reduce;
+ -------------------------------------------------------------------
+ function xor_reduce (l : STD_ULOGIC_VECTOR) return STD_ULOGIC is
+ variable result : STD_ULOGIC := '0';
+ begin
+ for i in l'reverse_range loop
+ result := (l(i) xor result);
+ end loop;
+ return result;
+ end function xor_reduce;
+
+ -------------------------------------------------------------------
+ -- xnor
+ -------------------------------------------------------------------
+ function xnor_reduce (l : STD_LOGIC_VECTOR) return STD_ULOGIC is
+ begin
+ return "not"(xor_reduce(To_StdULogicVector(l)));
+ end function xnor_reduce;
+ -------------------------------------------------------------------
+ function xnor_reduce (l : STD_ULOGIC_VECTOR) return STD_ULOGIC is
+ begin
+ return "not"(xor_reduce(l));
+ end function xnor_reduce;
+ -- %%% End "remove the following functions"
+
+ constant match_logic_table : stdlogic_table := (
+ -----------------------------------------------------
+ -- U X 0 1 Z W L H - | |
+ -----------------------------------------------------
+ ('U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', '1'), -- | U |
+ ('U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', '1'), -- | X |
+ ('U', 'X', '1', '0', 'X', 'X', '1', '0', '1'), -- | 0 |
+ ('U', 'X', '0', '1', 'X', 'X', '0', '1', '1'), -- | 1 |
+ ('U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', '1'), -- | Z |
+ ('U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', '1'), -- | W |
+ ('U', 'X', '1', '0', 'X', 'X', '1', '0', '1'), -- | L |
+ ('U', 'X', '0', '1', 'X', 'X', '0', '1', '1'), -- | H |
+ ('1', '1', '1', '1', '1', '1', '1', '1', '1') -- | - |
+ );
+
+ -------------------------------------------------------------------
+ -- ?= functions, Similar to "std_match", but returns "std_ulogic".
+ -------------------------------------------------------------------
+ -- %%% FUNCTION "?=" ( l, r : std_ulogic ) RETURN std_ulogic IS
+ function \?=\ (l, r : STD_ULOGIC) return STD_ULOGIC is
+ begin
+ return match_logic_table (l, r);
+ end function \?=\;
+ -- %%% END FUNCTION "?=";
+ -------------------------------------------------------------------
+ -- %%% FUNCTION "?=" ( l, r : std_logic_vector ) RETURN std_ulogic IS
+ function \?=\ (l, r : STD_LOGIC_VECTOR) return STD_ULOGIC is
+ alias lv : STD_LOGIC_VECTOR(1 to l'length) is l;
+ alias rv : STD_LOGIC_VECTOR(1 to r'length) is r;
+ variable result, result1 : STD_ULOGIC; -- result
+ begin
+ -- Logically identical to an "=" operator.
+ if ((l'length < 1) and (r'length < 1)) then
+ -- VHDL-2008 LRM 9.2.3 Two NULL arrays of the same type are equal
+ return '1';
+ elsif lv'length /= rv'length then
+ -- Two arrays of different lengths are false
+ return '0';
+ else
+ result := '1';
+ for i in lv'low to lv'high loop
+ result1 := match_logic_table(lv(i), rv(i));
+ result := result and result1;
+ end loop;
+ return result;
+ end if;
+ end function \?=\;
+ -- %%% END FUNCTION "?=";
+ -------------------------------------------------------------------
+ -- %%% FUNCTION "?=" ( l, r : std_ulogic_vector ) RETURN std_ulogic IS
+ function \?=\ (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC is
+ alias lv : STD_ULOGIC_VECTOR(1 to l'length) is l;
+ alias rv : STD_ULOGIC_VECTOR(1 to r'length) is r;
+ variable result, result1 : STD_ULOGIC;
+ begin
+ -- Logically identical to an "=" operator.
+ if ((l'length < 1) and (r'length < 1)) then
+ -- VHDL-2008 LRM 9.2.3 Two NULL arrays of the same type are equal
+ return '1';
+ elsif lv'length /= rv'length then
+ -- Two arrays of different lengths are false
+ return '0';
+ else
+ result := '1';
+ for i in lv'low to lv'high loop
+ result1 := match_logic_table(lv(i), rv(i));
+ result := result and result1;
+ end loop;
+ return result;
+ end if;
+ end function \?=\;
+ -- %%% END FUNCTION "?=";
+ -- %%% FUNCTION "?/=" ( l, r : std_ulogic ) RETURN std_ulogic is
+ function \?/=\ (l, r : STD_ULOGIC) return STD_ULOGIC is
+ begin
+ return not \?=\ (l, r);
+ end function \?/=\;
+ -- %%% END FUNCTION "?/=";
+ -- %%% FUNCTION "?/=" ( l, r : std_logic_vector ) RETURN std_ulogic is
+ function \?/=\ (l, r : STD_LOGIC_VECTOR) return STD_ULOGIC is
+ begin
+ return not \?=\ (l, r);
+ end function \?/=\;
+ -- %%% END FUNCTION "?/=";
+ -- %%% FUNCTION "?/=" ( l, r : std_ulogic_vector ) RETURN std_ulogic is
+ function \?/=\ (l, r : STD_ULOGIC_VECTOR) return STD_ULOGIC is
+ begin
+ return not \?=\ (l, r);
+ end function \?/=\;
+ -- %%% END FUNCTION "?/=";
+
+ -- Table for the ?< function (Section 9.2.3)
+ constant qlt : stdlogic_table := (
+ -----------------------------------------------------
+ -- U X 0 1 Z W L H - | |
+ -----------------------------------------------------
+ ('U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'X'), -- | U |
+ ('U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'), -- | X |
+ ('U', 'X', '0', '1', 'X', 'X', '0', '1', 'X'), -- | 0 |
+ ('U', 'X', '0', '0', 'X', 'X', '0', '0', 'X'), -- | 1 |
+ ('U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'), -- | Z |
+ ('U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'), -- | W |
+ ('U', 'X', '0', '1', 'X', 'X', '0', '1', 'X'), -- | L |
+ ('U', 'X', '0', '0', 'X', 'X', '0', '0', 'X'), -- | H |
+ ('X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X') -- | - |
+ );
+
+ -- %%% FUNCTION "?>" ( l, r : std_ulogic ) RETURN std_ulogic is
+ function \?>\ (l, r : STD_ULOGIC) return STD_ULOGIC is
+ begin
+ return not (qlt (l, r) or match_logic_table (l,r));
+ end function \?>\;
+ -- %%% END FUNCTION "?>";
+
+ -- %%% FUNCTION "?>=" ( l, r : std_ulogic ) RETURN std_ulogic is
+ function \?>=\ (l, r : STD_ULOGIC) return STD_ULOGIC is
+ begin
+ return not qlt (l, r);
+ end function \?>=\;
+ -- %%% END FUNCTION "?>=";
+
+ -- %%% FUNCTION "?<" ( l, r : std_ulogic ) RETURN std_ulogic is
+ function \?<\ (l, r : STD_ULOGIC) return STD_ULOGIC is
+ begin
+ return qlt (l, r);
+ end function \?<\;
+ -- %%% END FUNCTION "?<";
+
+ -- %%% FUNCTION "?<=" ( l, r : std_ulogic ) RETURN std_ulogic is
+ function \?<=\ (l, r : STD_ULOGIC) return STD_ULOGIC is
+ begin
+ return qlt (l, r) or match_logic_table (l,r);
+ end function \?<=\;
+ -- %%% END FUNCTION "?<=";
+
+ -- "??" operator, converts a std_ulogic to a boolean.
+-- %%% FUNCTION "??"
+ function \??\ (S : STD_ULOGIC) return BOOLEAN is
+ begin
+ return S = '1' or S = 'H';
+ end function \??\;
+-- %%% END FUNCTION "??";
+
+ -- rtl_synthesis off
+-- pragma synthesis_off
+ -----------------------------------------------------------------------------
+ -- This section copied from "std_logic_textio"
+ -----------------------------------------------------------------------------
+ -- 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;
+ type MVL9_indexed_by_char is array (CHARACTER) of STD_ULOGIC;
+ type MVL9plus_indexed_by_char is array (CHARACTER) of MVL9plus;
+ constant MVL9_to_char : char_indexed_by_MVL9 := "UX01ZWLH-";
+ constant char_to_MVL9 : MVL9_indexed_by_char :=
+ ('U' => 'U', 'X' => 'X', '0' => '0', '1' => '1', 'Z' => 'Z',
+ 'W' => 'W', 'L' => 'L', 'H' => 'H', '-' => '-', others => 'U');
+ constant char_to_MVL9plus : MVL9plus_indexed_by_char :=
+ ('U' => 'U', 'X' => 'X', '0' => '0', '1' => '1', 'Z' => 'Z',
+ 'W' => 'W', 'L' => 'L', 'H' => 'H', '-' => '-', others => error);
+
+ constant NBSP : CHARACTER := CHARACTER'val(160); -- space character
+ constant NUS : STRING(2 to 1) := (others => ' '); -- null STRING
+
+ -- purpose: Skips white space
+ procedure skip_whitespace (
+ L : inout LINE) is
+ variable readOk : BOOLEAN;
+ variable c : CHARACTER;
+ begin
+ while L /= null and L.all'length /= 0 loop
+ if (L.all(1) = ' ' or L.all(1) = NBSP or L.all(1) = HT) then
+ read (l, c, readOk);
+ else
+ exit;
+ end if;
+ end loop;
+ end procedure skip_whitespace;
+
+ procedure READ (L : inout LINE; VALUE : out STD_ULOGIC;
+ GOOD : out BOOLEAN) is
+ variable c : CHARACTER;
+ variable readOk : BOOLEAN;
+ begin
+ VALUE := 'U'; -- initialize to a "U"
+ Skip_whitespace (L);
+ read (l, c, readOk);
+ if not readOk then
+ good := false;
+ else
+ if char_to_MVL9plus(c) = error then
+ good := false;
+ else
+ VALUE := char_to_MVL9(c);
+ 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;
+ variable i : INTEGER;
+ variable lastu : BOOLEAN := false; -- last character was an "_"
+ begin
+ VALUE := (VALUE'range => 'U'); -- initialize to a "U"
+ Skip_whitespace (L);
+ if VALUE'length > 0 then
+ read (l, c, readOk);
+ i := 0;
+ good := false;
+ while i < VALUE'length loop
+ if not readOk then -- Bail out if there was a bad read
+ return;
+ elsif c = '_' then
+ if i = 0 then -- Begins with an "_"
+ return;
+ elsif lastu then -- "__" detected
+ return;
+ else
+ lastu := true;
+ end if;
+ elsif (char_to_MVL9plus(c) = error) then -- Illegal character
+ return;
+ else
+ mv(i) := char_to_MVL9(c);
+ i := i + 1;
+ if i > mv'high then -- reading done
+ good := true;
+ VALUE := mv;
+ return;
+ end if;
+ lastu := false;
+ end if;
+ read(L, c, readOk);
+ end loop;
+ else
+ good := true; -- read into a null array
+ end if;
+ end procedure READ;
+
+ procedure READ (L : inout LINE; VALUE : out STD_ULOGIC) is
+ variable c : CHARACTER;
+ variable readOk : BOOLEAN;
+ begin
+ VALUE := 'U'; -- initialize to a "U"
+ Skip_whitespace (L);
+ read (l, c, readOk);
+ if not readOk then
+ report "STD_LOGIC_1164.READ(STD_ULOGIC) "
+ & "End of string encountered"
+ severity error;
+ return;
+ elsif char_to_MVL9plus(c) = error then
+ report
+ "STD_LOGIC_1164.READ(STD_ULOGIC) Error: Character '" &
+ c & "' read, expected STD_ULOGIC literal."
+ severity error;
+ else
+ VALUE := char_to_MVL9(c);
+ end if;
+ 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);
+ variable i : INTEGER;
+ variable lastu : BOOLEAN := false; -- last character was an "_"
+ begin
+ VALUE := (VALUE'range => 'U'); -- initialize to a "U"
+ Skip_whitespace (L);
+ if VALUE'length > 0 then -- non Null input string
+ read (l, c, readOk);
+ i := 0;
+ while i < VALUE'length loop
+ if readOk = false then -- Bail out if there was a bad read
+ report "STD_LOGIC_1164.READ(STD_ULOGIC_VECTOR) "
+ & "End of string encountered"
+ severity error;
+ return;
+ elsif c = '_' then
+ if i = 0 then
+ report "STD_LOGIC_1164.READ(STD_ULOGIC_VECTOR) "
+ & "String begins with an ""_""" severity error;
+ return;
+ elsif lastu then
+ report "STD_LOGIC_1164.READ(STD_ULOGIC_VECTOR) "
+ & "Two underscores detected in input string ""__"""
+ severity error;
+ return;
+ else
+ lastu := true;
+ end if;
+ elsif c = ' ' or c = NBSP or c = HT then -- reading done.
+ report "STD_LOGIC_1164.READ(STD_ULOGIC_VECTOR) "
+ & "Short read, Space encounted in input string"
+ severity error;
+ return;
+ elsif char_to_MVL9plus(c) = error then
+ report "STD_LOGIC_1164.READ(STD_ULOGIC_VECTOR) "
+ & "Error: Character '" &
+ c & "' read, expected STD_ULOGIC literal."
+ severity error;
+ return;
+ else
+ mv(i) := char_to_MVL9(c);
+ i := i + 1;
+ if i > mv'high then
+ VALUE := mv;
+ return;
+ end if;
+ lastu := false;
+ end if;
+ read(L, c, readOk);
+ end loop;
+ end if;
+ end procedure READ;
+
+ 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);
+ end procedure WRITE;
+
+ procedure WRITE (L : inout LINE; VALUE : in STD_ULOGIC_VECTOR;
+ JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is
+ variable s : STRING(1 to VALUE'length);
+ variable m : STD_ULOGIC_VECTOR(1 to VALUE'length) := VALUE;
+ begin
+ for i in 1 to VALUE'length loop
+ s(i) := MVL9_to_char(m(i));
+ end loop;
+ write(l, s, justified, field);
+ end procedure WRITE;
+
+ -- Read and Write procedures for STD_LOGIC_VECTOR
+
+ procedure READ (L : inout LINE; VALUE : out STD_LOGIC_VECTOR;
+ GOOD : out BOOLEAN) is
+ variable ivalue : STD_ULOGIC_VECTOR (VALUE'range);
+ begin
+ READ (L => L, VALUE => ivalue, GOOD => GOOD);
+ VALUE := to_stdlogicvector (ivalue);
+ end procedure READ;
+
+ procedure READ (L : inout LINE; VALUE : out STD_LOGIC_VECTOR) is
+ variable ivalue : STD_ULOGIC_VECTOR (VALUE'range);
+ begin
+ READ (L => L, VALUE => ivalue);
+ VALUE := to_stdlogicvector (ivalue);
+ end procedure READ;
+
+ procedure WRITE (L : inout LINE; VALUE : in STD_LOGIC_VECTOR;
+ JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is
+ variable s : STRING(1 to VALUE'length);
+ variable m : STD_LOGIC_VECTOR(1 to VALUE'length) := VALUE;
+ begin
+ for i in 1 to VALUE'length loop
+ s(i) := MVL9_to_char(m(i));
+ end loop;
+ write(L, s, justified, field);
+ end procedure WRITE;
+
+ -----------------------------------------------------------------------
+ -- Alias for bread and bwrite are provided with call out the read and
+ -- write functions.
+ -----------------------------------------------------------------------
+
+ -- Hex Read and Write procedures for STD_ULOGIC_VECTOR.
+ -- Modified from the original to be more forgiving.
+
+ procedure Char2QuadBits (C : CHARACTER;
+ RESULT : out STD_ULOGIC_VECTOR(3 downto 0);
+ 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;
+ when others =>
+ assert not ISSUE_ERROR
+ report
+ "STD_LOGIC_1164.HREAD Read a '" & c &
+ "', expected a Hex character (0-F)."
+ severity error;
+ good := false;
+ end case;
+ end procedure Char2QuadBits;
+
+ procedure HREAD (L : inout LINE; VALUE : out STD_ULOGIC_VECTOR;
+ GOOD : out BOOLEAN) is
+ variable ok : BOOLEAN;
+ variable c : CHARACTER;
+ constant ne : INTEGER := (VALUE'length+3)/4;
+ constant pad : INTEGER := ne*4 - VALUE'length;
+ variable sv : STD_ULOGIC_VECTOR(0 to ne*4 - 1);
+ variable i : INTEGER;
+ variable lastu : BOOLEAN := false; -- last character was an "_"
+ begin
+ VALUE := (VALUE'range => 'U'); -- initialize to a "U"
+ Skip_whitespace (L);
+ if VALUE'length > 0 then
+ read (l, c, ok);
+ i := 0;
+ while i < ne loop
+ -- Bail out if there was a bad read
+ if not ok then
+ good := false;
+ return;
+ elsif c = '_' then
+ if i = 0 then
+ good := false; -- Begins with an "_"
+ return;
+ elsif lastu then
+ good := false; -- "__" detected
+ return;
+ else
+ lastu := true;
+ end if;
+ else
+ Char2QuadBits(c, sv(4*i to 4*i+3), ok, false);
+ if not ok then
+ good := false;
+ return;
+ end if;
+ i := i + 1;
+ lastu := false;
+ end if;
+ if i < ne then
+ read(L, c, ok);
+ end if;
+ end loop;
+ if or_reduce (sv (0 to pad-1)) = '1' then -- %%% replace with "or"
+ good := false; -- vector was truncated.
+ else
+ good := true;
+ VALUE := sv (pad to sv'high);
+ end if;
+ else
+ good := true; -- Null input string, skips whitespace
+ end if;
+ end procedure HREAD;
+
+ procedure HREAD (L : inout LINE; VALUE : out STD_ULOGIC_VECTOR) is
+ variable ok : BOOLEAN;
+ variable c : CHARACTER;
+ constant ne : INTEGER := (VALUE'length+3)/4;
+ constant pad : INTEGER := ne*4 - VALUE'length;
+ variable sv : STD_ULOGIC_VECTOR(0 to ne*4 - 1);
+ variable i : INTEGER;
+ variable lastu : BOOLEAN := false; -- last character was an "_"
+ begin
+ VALUE := (VALUE'range => 'U'); -- initialize to a "U"
+ Skip_whitespace (L);
+ if VALUE'length > 0 then -- non Null input string
+ read (l, c, ok);
+ i := 0;
+ while i < ne loop
+ -- Bail out if there was a bad read
+ if not ok then
+ report "STD_LOGIC_1164.HREAD "
+ & "End of string encountered"
+ severity error;
+ return;
+ end if;
+ if c = '_' then
+ if i = 0 then
+ report "STD_LOGIC_1164.HREAD "
+ & "String begins with an ""_""" severity error;
+ return;
+ elsif lastu then
+ report "STD_LOGIC_1164.HREAD "
+ & "Two underscores detected in input string ""__"""
+ severity error;
+ return;
+ else
+ lastu := true;
+ end if;
+ else
+ Char2QuadBits(c, sv(4*i to 4*i+3), ok, true);
+ if not ok then
+ return;
+ end if;
+ i := i + 1;
+ lastu := false;
+ end if;
+ if i < ne then
+ read(L, c, ok);
+ end if;
+ end loop;
+ if or_reduce (sv (0 to pad-1)) = '1' then -- %%% replace with "or"
+ report "STD_LOGIC_1164.HREAD Vector truncated"
+ severity error;
+ else
+ VALUE := sv (pad to sv'high);
+ end if;
+ end if;
+ end procedure HREAD;
+
+ 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);
+ end procedure HWRITE;
+
+
+ -- Octal Read and Write procedures for STD_ULOGIC_VECTOR.
+ -- Modified from the original to be more forgiving.
+
+ procedure Char2TriBits (C : CHARACTER;
+ RESULT : out STD_ULOGIC_VECTOR(2 downto 0);
+ 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;
+ when others =>
+ assert not ISSUE_ERROR
+ report
+ "STD_LOGIC_1164.OREAD Error: Read a '" & c &
+ "', expected an Octal character (0-7)."
+ severity error;
+ good := false;
+ end case;
+ end procedure Char2TriBits;
+
+ procedure OREAD (L : inout LINE; VALUE : out STD_ULOGIC_VECTOR;
+ GOOD : out BOOLEAN) is
+ variable ok : BOOLEAN;
+ variable c : CHARACTER;
+ constant ne : INTEGER := (VALUE'length+2)/3;
+ constant pad : INTEGER := ne*3 - VALUE'length;
+ variable sv : STD_ULOGIC_VECTOR(0 to ne*3 - 1);
+ variable i : INTEGER;
+ variable lastu : BOOLEAN := false; -- last character was an "_"
+ begin
+ VALUE := (VALUE'range => 'U'); -- initialize to a "U"
+ Skip_whitespace (L);
+ if VALUE'length > 0 then
+ read (l, c, ok);
+ i := 0;
+ while i < ne loop
+ -- Bail out if there was a bad read
+ if not ok then
+ good := false;
+ return;
+ elsif c = '_' then
+ if i = 0 then
+ good := false; -- Begins with an "_"
+ return;
+ elsif lastu then
+ good := false; -- "__" detected
+ return;
+ else
+ lastu := true;
+ end if;
+ else
+ Char2TriBits(c, sv(3*i to 3*i+2), ok, false);
+ if not ok then
+ good := false;
+ return;
+ end if;
+ i := i + 1;
+ lastu := false;
+ end if;
+ if i < ne then
+ read(L, c, ok);
+ end if;
+ end loop;
+ if or_reduce (sv (0 to pad-1)) = '1' then -- %%% replace with "or"
+ good := false; -- vector was truncated.
+ else
+ good := true;
+ VALUE := sv (pad to sv'high);
+ end if;
+ else
+ good := true; -- read into a null array
+ end if;
+ end procedure OREAD;
+
+ procedure OREAD (L : inout LINE; VALUE : out STD_ULOGIC_VECTOR) is
+ variable c : CHARACTER;
+ variable ok : BOOLEAN;
+ constant ne : INTEGER := (VALUE'length+2)/3;
+ constant pad : INTEGER := ne*3 - VALUE'length;
+ variable sv : STD_ULOGIC_VECTOR(0 to ne*3 - 1);
+ variable i : INTEGER;
+ variable lastu : BOOLEAN := false; -- last character was an "_"
+ begin
+ VALUE := (VALUE'range => 'U'); -- initialize to a "U"
+ Skip_whitespace (L);
+ if VALUE'length > 0 then
+ read (l, c, ok);
+ i := 0;
+ while i < ne loop
+ -- Bail out if there was a bad read
+ if not ok then
+ report "STD_LOGIC_1164.OREAD "
+ & "End of string encountered"
+ severity error;
+ return;
+ elsif c = '_' then
+ if i = 0 then
+ report "STD_LOGIC_1164.OREAD "
+ & "String begins with an ""_""" severity error;
+ return;
+ elsif lastu then
+ report "STD_LOGIC_1164.OREAD "
+ & "Two underscores detected in input string ""__"""
+ severity error;
+ return;
+ else
+ lastu := true;
+ end if;
+ else
+ Char2TriBits(c, sv(3*i to 3*i+2), ok, true);
+ if not ok then
+ return;
+ end if;
+ i := i + 1;
+ lastu := false;
+ end if;
+ if i < ne then
+ read(L, c, ok);
+ end if;
+ end loop;
+ if or_reduce (sv (0 to pad-1)) = '1' then -- %%% replace with "or"
+ report "STD_LOGIC_1164.OREAD Vector truncated"
+ severity error;
+ else
+ VALUE := sv (pad to sv'high);
+ end if;
+ end if;
+ end procedure OREAD;
+
+ 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);
+ end procedure OWRITE;
+
+ -- Hex Read and Write procedures for STD_LOGIC_VECTOR
+
+ procedure HREAD (L : inout LINE; VALUE : out STD_LOGIC_VECTOR;
+ GOOD : out BOOLEAN) is
+ variable ivalue : STD_ULOGIC_VECTOR (VALUE'range);
+ begin
+ HREAD (L => L, VALUE => ivalue, GOOD => GOOD);
+ VALUE := to_stdlogicvector (ivalue);
+ end procedure HREAD;
+
+ procedure HREAD (L : inout LINE; VALUE : out STD_LOGIC_VECTOR) is
+ variable ivalue : STD_ULOGIC_VECTOR (VALUE'range);
+ begin
+ HREAD (L => L, VALUE => ivalue);
+ VALUE := to_stdlogicvector (ivalue);
+ end procedure HREAD;
+
+ procedure HWRITE (L : inout LINE; VALUE : in STD_LOGIC_VECTOR;
+ JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is
+ begin
+ write (L, to_hstring(VALUE), JUSTIFIED, FIELD);
+ end procedure HWRITE;
+
+ -- Octal Read and Write procedures for STD_LOGIC_VECTOR
+
+ procedure OREAD (L : inout LINE; VALUE : out STD_LOGIC_VECTOR;
+ GOOD : out BOOLEAN) is
+ variable ivalue : STD_ULOGIC_VECTOR (VALUE'range);
+ begin
+ OREAD (L => L, VALUE => ivalue, GOOD => GOOD);
+ VALUE := to_stdlogicvector (ivalue);
+ end procedure OREAD;
+
+ procedure OREAD (L : inout LINE; VALUE : out STD_LOGIC_VECTOR) is
+ variable ivalue : STD_ULOGIC_VECTOR (VALUE'range);
+ begin
+ OREAD (L => L, VALUE => ivalue);
+ VALUE := to_stdlogicvector (ivalue);
+ end procedure OREAD;
+
+ procedure OWRITE (L : inout LINE; VALUE : in STD_LOGIC_VECTOR;
+ JUSTIFIED : in SIDE := right; FIELD : in WIDTH := 0) is
+ begin
+ write (L, to_ostring(VALUE), JUSTIFIED, FIELD);
+ end procedure OWRITE;
+
+ -----------------------------------------------------------------------------
+ -- New string functions for vhdl-200x fast track
+ -----------------------------------------------------------------------------
+ function to_string (value : STD_ULOGIC) return STRING is
+ variable result : STRING (1 to 1);
+ begin
+ result (1) := MVL9_to_char (value);
+ return result;
+ end function to_string;
+ -------------------------------------------------------------------
+ -- TO_STRING (an alias called "to_bstring" is provide)
+ -------------------------------------------------------------------
+ function to_string (value : STD_ULOGIC_VECTOR) return STRING is
+ alias ivalue : STD_ULOGIC_VECTOR(1 to value'length) is value;
+ variable result : STRING(1 to value'length);
+ begin
+ if value'length < 1 then
+ return NUS;
+ else
+ for i in ivalue'range loop
+ result(i) := MVL9_to_char(iValue(i));
+ end loop;
+ return result;
+ end if;
+ end function to_string;
+
+ -------------------------------------------------------------------
+ -- TO_HSTRING
+ -------------------------------------------------------------------
+ function to_hstring (value : STD_ULOGIC_VECTOR) return STRING is
+ constant ne : INTEGER := (value'length+3)/4;
+ variable pad : STD_ULOGIC_VECTOR(0 to (ne*4 - value'length) - 1);
+ variable ivalue : STD_ULOGIC_VECTOR(0 to ne*4 - 1);
+ variable result : STRING(1 to ne);
+ variable quad : STD_ULOGIC_VECTOR(0 to 3);
+ begin
+ if value'length < 1 then
+ return NUS;
+ else
+ if value (value'left) = 'Z' then
+ pad := (others => 'Z');
+ else
+ pad := (others => '0');
+ end if;
+ ivalue := pad & value;
+ for i in 0 to ne-1 loop
+ quad := To_X01Z(ivalue(4*i to 4*i+3));
+ case quad is
+ when x"0" => result(i+1) := '0';
+ when x"1" => result(i+1) := '1';
+ when x"2" => result(i+1) := '2';
+ when x"3" => result(i+1) := '3';
+ when x"4" => result(i+1) := '4';
+ when x"5" => result(i+1) := '5';
+ when x"6" => result(i+1) := '6';
+ when x"7" => result(i+1) := '7';
+ when x"8" => result(i+1) := '8';
+ when x"9" => result(i+1) := '9';
+ when x"A" => result(i+1) := 'A';
+ when x"B" => result(i+1) := 'B';
+ when x"C" => result(i+1) := 'C';
+ when x"D" => result(i+1) := 'D';
+ when x"E" => result(i+1) := 'E';
+ when x"F" => result(i+1) := 'F';
+ when "ZZZZ" => result(i+1) := 'Z';
+ when others => result(i+1) := 'X';
+ end case;
+ end loop;
+ return result;
+ end if;
+ end function to_hstring;
+
+ -------------------------------------------------------------------
+ -- TO_OSTRING
+ -------------------------------------------------------------------
+ function to_ostring (value : STD_ULOGIC_VECTOR) return STRING is
+ constant ne : INTEGER := (value'length+2)/3;
+ variable pad : STD_ULOGIC_VECTOR(0 to (ne*3 - value'length) - 1);
+ variable ivalue : STD_ULOGIC_VECTOR(0 to ne*3 - 1);
+ variable result : STRING(1 to ne);
+ variable tri : STD_ULOGIC_VECTOR(0 to 2);
+ begin
+ if value'length < 1 then
+ return NUS;
+ else
+ if value (value'left) = 'Z' then
+ pad := (others => 'Z');
+ else
+ pad := (others => '0');
+ end if;
+ ivalue := pad & value;
+ for i in 0 to ne-1 loop
+ tri := To_X01Z(ivalue(3*i to 3*i+2));
+ case tri is
+ when o"0" => result(i+1) := '0';
+ when o"1" => result(i+1) := '1';
+ when o"2" => result(i+1) := '2';
+ when o"3" => result(i+1) := '3';
+ when o"4" => result(i+1) := '4';
+ when o"5" => result(i+1) := '5';
+ when o"6" => result(i+1) := '6';
+ when o"7" => result(i+1) := '7';
+ when "ZZZ" => result(i+1) := 'Z';
+ when others => result(i+1) := 'X';
+ end case;
+ end loop;
+ return result;
+ end if;
+ end function to_ostring;
+
+ function to_string (value : STD_LOGIC_VECTOR) return STRING is
+ begin
+ return to_string (to_stdulogicvector (value));
+ end function to_string;
+
+ function to_hstring (value : STD_LOGIC_VECTOR) return STRING is
+ begin
+ return to_hstring (to_stdulogicvector (value));
+ end function to_hstring;
+
+ function to_ostring (value : STD_LOGIC_VECTOR) return STRING is
+ begin
+ return to_ostring (to_stdulogicvector (value));
+ end function to_ostring;
+
+ -- rtl_synthesis on
+-- pragma synthesis_on
+ function maximum (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is
+ begin -- function maximum
+ if L > R then return L;
+ else return R;
+ end if;
+ end function maximum;
+
+ -- std_logic_vector output
+ function minimum (L, R : STD_ULOGIC_VECTOR) return STD_ULOGIC_VECTOR is
+ begin -- function minimum
+ if L > R then return R;
+ else return L;
+ end if;
+ end function minimum;
+
+ function maximum (L, R : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ begin -- function maximum
+ if L > R then return L;
+ else return R;
+ end if;
+ end function maximum;
+
+ -- std_logic_vector output
+ function minimum (L, R : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ begin -- function minimum
+ if L > R then return R;
+ else return L;
+ end if;
+ end function minimum;
+
+ function maximum (L, R : STD_ULOGIC) return STD_ULOGIC is
+ begin -- function maximum
+ if L > R then return L;
+ else return R;
+ end if;
+ end function maximum;
+
+ -- std_logic_vector output
+ function minimum (L, R : STD_ULOGIC) return STD_ULOGIC is
+ begin -- function minimum
+ if L > R then return R;
+ else return L;
+ end if;
+ end function minimum;
+end package body std_logic_1164_additions;
|