IEEE-754 style binary floating-point arithmetic over the float type.
- Use clause
-
library IEEE;
use IEEE.FLOAT_GENERIC_PKG.all; - Source
-
ieee/float_generic_pkg.vhdlin the IEEE 1076 OSR, tag1076-2019
Apache License 2.0, © 2019 IEEE P1076 WG Authors - Length
- 1000 lines
- VHDL revisions
- Added in 1076-2008; updated through 1076-2019
- Body
- View package body ›
Overview
FLOAT_GENERIC_PKG defines IEEE-754 style binary
floating-point arithmetic on the unresolved type
UNRESOLVED_float and its resolved subtype float.
Each value carries one sign bit, an exponent field, and a fraction field,
with the field widths set by generic constants on instantiation. The
package covers the four arithmetic operators, comparisons, conversions to
and from REAL / INTEGER / fixed-point, the IEEE-754 recommended functions
(copysign, scalb, logb,
nextafter, finite, isnan, etc.), and
string I/O.
The package is generic over fraction and exponent widths plus rounding,
denormal, and error-checking flags; the instantiated
FLOAT_PKG ties those to single-
precision (8-bit exponent, 23-bit fraction). For the rules that govern
the body of this package, see §16.11 of IEEE Std 1076-2019.
What's defined here
- Types
-
UNRESOLVED_float(unconstrained array ofSTD_ULOGIC) and the resolved subtypefloat, plus the named-precision subtypesfloat32,float64, andfloat128. - Operator groups
-
Arithmetic (
"+","-","*","/","abs","mod","rem") · Comparison ("=","/=","<","<=",">",">=") · Logical · Conversion (to_float,to_real,to_integer,to_slv) · IEEE-754 recommended · String & textio - Key named functions
-
to_float,to_real,to_integer,to_slv,to_signed,to_unsigned,resize,copysign,scalb,logb,nextafter,finite,isnan,unordered,class,maximum,minimum,read,write,to_string,to_hstring,to_ostring
VHDL source listing
docFile header
lines 1–42
-- -----------------------------------------------------------------
--
-- Copyright 2019 IEEE P1076 WG Authors
--
-- See the LICENSE file distributed with this work for copyright and
-- licensing information and the AUTHORS file.
--
-- This file to you under the Apache License, Version 2.0 (the "License").
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-- implied. See the License for the specific language governing
-- permissions and limitations under the License.
--
-- Title : Floating-point package (Generic package declaration)
-- :
-- Library : This package shall be compiled into a library
-- : symbolically named IEEE.
-- :
-- Developers: Accellera VHDL-TC and IEEE P1076 Working Group
-- :
-- Purpose : This packages defines basic binary floating point
-- : arithmetic functions
-- :
-- Note : This package may be modified to include additional data
-- : required by tools, but it must in no way change the
-- : external interfaces or simulation behavior of the
-- : description. It is permissible to add comments and/or
-- : attributes to the package declarations, but not to change
-- : or delete any original lines of the package declaration.
-- : The package body may be changed only in accordance with
-- : the terms of Clause 16 of this standard.
-- :
-- --------------------------------------------------------------------
-- $Revision: 1220 $
-- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $
-- --------------------------------------------------------------------
use STD.TEXTIO.all;
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;
use IEEE.fixed_float_types.all;
package float_generic_pkg is
generic (
-- Defaults for sizing routines, when you do a "to_float" this will be
-- the default size. Example float32 would be 8 and 23 (8 downto -23)
float_exponent_width : NATURAL := 8;
float_fraction_width : NATURAL := 23;
-- Rounding algorithm, "round_nearest" is default, other valid values
-- are "round_zero" (truncation), "round_inf" (round up), and
-- "round_neginf" (round down)
float_round_style : round_type := round_nearest;
-- Denormal numbers (very small numbers near zero) true or false
float_denormalize : BOOLEAN := true;
-- Turns on NAN processing (invalid numbers and overflow) true of false
float_check_error : BOOLEAN := true;
-- Guard bits are added to the bottom of every operation for rounding.
-- any natural number (including 0) are valid.
float_guard_bits : NATURAL := 3;
-- If TRUE, then turn off warnings on "X" propagation
no_warning : BOOLEAN := false;
package fixed_pkg is new IEEE.fixed_generic_pkg
generic map (<>) );
coCopyRightNotice
lines 71–74
CopyRightNotice -- Author David Bishop (dbishop@vhdl.org)
constant CopyRightNotice : STRING :=
"Copyright IEEE P1076 WG. Licensed Apache 2.0";
use fixed_pkg.all;Floating-point type definitions
--============================================================================
-- Floating-Point Type Definitions
--============================================================================
-- Note that this is "INTEGER range <>", thus if you use a literal, then the
-- default range will be (INTEGER'low to INTEGER'low + X)
type UNRESOLVED_float is array (INTEGER range <>) of STD_ULOGIC; -- main type
alias U_float is UNRESOLVED_float;
subtype float is (resolved) UNRESOLVED_float;Use the float type to define your own floating point numbers.
-----------------------------------------------------------------------------
-- Use the float type to define your own floating point numbers.
-- There must be a negative index or the packages will error out.
-- Minimum supported is "subtype float7 is float (3 downto -3);"
-- "subtype float16 is float (6 downto -9);" is probably the smallest
-- practical one to use.
-----------------------------------------------------------------------------
-- IEEE 754 single precision
subtype UNRESOLVED_float32 is UNRESOLVED_float (8 downto -23);
alias U_float32 is UNRESOLVED_float32;
subtype float32 is float (8 downto -23);IEEE-754 single precision floating point. this is a "float"
-----------------------------------------------------------------------------
-- IEEE-754 single precision floating point. This is a "float"
-- in C, and a FLOAT in Fortran. The exponent is 8 bits wide, and
-- the fraction is 23 bits wide. This format can hold roughly 7 decimal
-- digits. Infinity is 2**127 = 1.7E38 in this number system.
-- The bit representation is as follows:
-- 1 09876543 21098765432109876543210
-- 8 76543210 12345678901234567890123
-- 0 00000000 00000000000000000000000
-- 8 7 0 -1 -23
-- +/- exp. fraction
-----------------------------------------------------------------------------
-- IEEE 754 double precision
subtype UNRESOLVED_float64 is UNRESOLVED_float (11 downto -52);
alias U_float64 is UNRESOLVED_float64;
subtype float64 is float (11 downto -52);IEEE-754 double precision floating point. this is a "double float"
-----------------------------------------------------------------------------
-- IEEE-754 double precision floating point. This is a "double float"
-- in C, and a FLOAT*8 in Fortran. The exponent is 11 bits wide, and
-- the fraction is 52 bits wide. This format can hold roughly 15 decimal
-- digits. Infinity is 2**2047 in this number system.
-- The bit representation is as follows:
-- 3 21098765432 1098765432109876543210987654321098765432109876543210
-- 1 09876543210 1234567890123456789012345678901234567890123456789012
-- S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
-- 11 10 0 -1 -52
-- +/- exponent fraction
-----------------------------------------------------------------------------
-- IEEE 854 & C extended precision
subtype UNRESOLVED_float128 is UNRESOLVED_float (15 downto -112);
alias U_float128 is UNRESOLVED_float128;
subtype float128 is float (15 downto -112);The 128 bit floating point number is "long double" in c (on
-----------------------------------------------------------------------------
-- The 128 bit floating point number is "long double" in C (on
-- some systems this is a 70 bit floating point number) and FLOAT*32
-- in Fortran. The exponent is 15 bits wide and the fraction is 112
-- bits wide. This number can handle approximately 33 decimal digits.
-- Infinity is 2**32,767 in this number system.
-----------------------------------------------------------------------------
Floating-point classification
--============================================================================
-- Floating-Point Classification
--============================================================================
tyvalid_fpstate
lines 145–157
valid_fpstate -- purpose: Checks for a valid floating point number
type valid_fpstate is (nan, -- Signaling NaN (C FP_NAN)
quiet_nan, -- Quiet NaN (C FP_NAN)
neg_inf, -- Negative infinity (C FP_INFINITE)
neg_normal, -- negative normalized nonzero
neg_denormal, -- negative denormalized (FP_SUBNORMAL)
neg_zero, -- -0 (C FP_ZERO)
pos_zero, -- +0 (C FP_ZERO)
pos_denormal, -- Positive denormalized (FP_SUBNORMAL)
pos_normal, -- positive normalized nonzero
pos_inf, -- positive infinity
isx); -- at least one input is unknown
cofphdlsynth_or_real
lines 158–161
fphdlsynth_or_real -- This deferred constant will tell you if the package body is synthesizable
-- or implemented as real numbers.
constant fphdlsynth_or_real : BOOLEAN; -- deferred constant
fnClassfp
lines 162–167
Classfp -- Returns the class which X falls into
function Classfp (
x : UNRESOLVED_float; -- floating point input
check_error : BOOLEAN := float_check_error) -- check for errors
return valid_fpstate;
Arithmetic operators
--============================================================================
-- Arithmetic Operators
--============================================================================
fn"abs"
lines 172–173
"abs" -- Arithmetic functions, these operators do not require parameters.
function "abs" (arg : UNRESOLVED_float) return UNRESOLVED_float;fn"-"
lines 174–178
"-" function "-" (arg : UNRESOLVED_float) return UNRESOLVED_float;
-- These allows the base math functions to use the default values
-- of their parameters. Thus they do full IEEE floating point.
fn"+"
lines 179–179
"+" function "+" (l, r : UNRESOLVED_float) return UNRESOLVED_float;fn"-"
lines 180–180
"-" function "-" (l, r : UNRESOLVED_float) return UNRESOLVED_float;fn"*"
lines 181–181
"*" function "*" (l, r : UNRESOLVED_float) return UNRESOLVED_float;fn"/"
lines 182–182
"/" function "/" (l, r : UNRESOLVED_float) return UNRESOLVED_float;fn"rem"
lines 183–183
"rem" function "rem" (l, r : UNRESOLVED_float) return UNRESOLVED_float;fn"mod"
lines 184–191
"mod" function "mod" (l, r : UNRESOLVED_float) return UNRESOLVED_float;
-- Basic parameter list
-- round_style - Selects the rounding algorithm to use
-- guard - extra bits added to the end if the operation to add precision
-- check_error - When "false" turns off NAN and overflow checks
-- denormalize - When "false" turns off denormal number processing
fnadd
lines 192–199
add function add (
l, r : UNRESOLVED_float; -- floating point input
constant round_style : round_type := float_round_style; -- rounding option
constant guard : NATURAL := float_guard_bits; -- number of guard bits
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
fnsubtract
lines 200–207
subtract function subtract (
l, r : UNRESOLVED_float; -- floating point input
constant round_style : round_type := float_round_style; -- rounding option
constant guard : NATURAL := float_guard_bits; -- number of guard bits
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
fnmultiply
lines 208–215
multiply function multiply (
l, r : UNRESOLVED_float; -- floating point input
constant round_style : round_type := float_round_style; -- rounding option
constant guard : NATURAL := float_guard_bits; -- number of guard bits
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
fndivide
lines 216–223
divide function divide (
l, r : UNRESOLVED_float; -- floating point input
constant round_style : round_type := float_round_style; -- rounding option
constant guard : NATURAL := float_guard_bits; -- number of guard bits
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
fnremainder
lines 224–231
remainder function remainder (
l, r : UNRESOLVED_float; -- floating point input
constant round_style : round_type := float_round_style; -- rounding option
constant guard : NATURAL := float_guard_bits; -- number of guard bits
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
fnmodulo
lines 232–240
modulo function modulo (
l, r : UNRESOLVED_float; -- floating point input
constant round_style : round_type := float_round_style; -- rounding option
constant guard : NATURAL := float_guard_bits; -- number of guard bits
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
-- reciprocalfnreciprocal
lines 241–248
reciprocal function reciprocal (
arg : UNRESOLVED_float; -- floating point input
constant round_style : round_type := float_round_style; -- rounding option
constant guard : NATURAL := float_guard_bits; -- number of guard bits
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
fndividebyp2
lines 249–257
dividebyp2 function dividebyp2 (
l, r : UNRESOLVED_float; -- floating point input
constant round_style : round_type := float_round_style; -- rounding option
constant guard : NATURAL := float_guard_bits; -- number of guard bits
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
-- Multiply accumulate result = l*r + cfnmac
lines 258–266
mac function mac (
l, r, c : UNRESOLVED_float; -- floating point input
constant round_style : round_type := float_round_style; -- rounding option
constant guard : NATURAL := float_guard_bits; -- number of guard bits
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
-- Square root (all 754 based implementations need this)fnsqrt
lines 267–274
sqrt function sqrt (
arg : UNRESOLVED_float; -- floating point input
constant round_style : round_type := float_round_style;
constant guard : NATURAL := float_guard_bits;
constant check_error : BOOLEAN := float_check_error;
constant denormalize : BOOLEAN := float_denormalize)
return UNRESOLVED_float;
fnIs_Negative
lines 275–276
Is_Negative function Is_Negative (arg : UNRESOLVED_float) return BOOLEAN;
Comparison and relational operators (=, /=, <, <=, >, >=, maximum, minimum)
--============================================================================
-- Comparison and Relational Operators (=, /=, <, <=, >, >=, maximum, minimum)
--============================================================================
fneq
lines 281–286
eq function eq ( -- equal =
l, r : UNRESOLVED_float; -- floating point input
constant check_error : BOOLEAN := float_check_error;
constant denormalize : BOOLEAN := float_denormalize)
return BOOLEAN;
fnne
lines 287–292
ne function ne ( -- not equal /=
l, r : UNRESOLVED_float; -- floating point input
constant check_error : BOOLEAN := float_check_error;
constant denormalize : BOOLEAN := float_denormalize)
return BOOLEAN;
fnlt
lines 293–298
lt function lt ( -- less than <
l, r : UNRESOLVED_float; -- floating point input
constant check_error : BOOLEAN := float_check_error;
constant denormalize : BOOLEAN := float_denormalize)
return BOOLEAN;
fngt
lines 299–304
gt function gt ( -- greater than >
l, r : UNRESOLVED_float; -- floating point input
constant check_error : BOOLEAN := float_check_error;
constant denormalize : BOOLEAN := float_denormalize)
return BOOLEAN;
fnle
lines 305–310
le function le ( -- less than or equal to <=
l, r : UNRESOLVED_float; -- floating point input
constant check_error : BOOLEAN := float_check_error;
constant denormalize : BOOLEAN := float_denormalize)
return BOOLEAN;
fnge
lines 311–317
ge function ge ( -- greater than or equal to >=
l, r : UNRESOLVED_float; -- floating point input
constant check_error : BOOLEAN := float_check_error;
constant denormalize : BOOLEAN := float_denormalize)
return BOOLEAN;
-- Need to overload the default versions of thesefn"="
lines 318–318
"=" function "=" (l, r : UNRESOLVED_float) return BOOLEAN;fn"/="
lines 319–319
"/=" function "/=" (l, r : UNRESOLVED_float) return BOOLEAN;fn">="
lines 320–320
">=" function ">=" (l, r : UNRESOLVED_float) return BOOLEAN;fn"<="
lines 321–321
"<=" function "<=" (l, r : UNRESOLVED_float) return BOOLEAN;fn">"
lines 322–322
">" function ">" (l, r : UNRESOLVED_float) return BOOLEAN;fn"<"
lines 323–324
"<" function "<" (l, r : UNRESOLVED_float) return BOOLEAN;
fn"?="
lines 325–325
"?=" function "?=" (l, r : UNRESOLVED_float) return STD_ULOGIC;fn"?/="
lines 326–326
"?/=" function "?/=" (l, r : UNRESOLVED_float) return STD_ULOGIC;fn"?>"
lines 327–327
"?>" function "?>" (l, r : UNRESOLVED_float) return STD_ULOGIC;fn"?>="
lines 328–328
"?>=" function "?>=" (l, r : UNRESOLVED_float) return STD_ULOGIC;fn"?<"
lines 329–329
"?<" function "?<" (l, r : UNRESOLVED_float) return STD_ULOGIC;fn"?<="
lines 330–331
"?<=" function "?<=" (l, r : UNRESOLVED_float) return STD_ULOGIC;
fnstd_match
lines 332–332
std_match function std_match (l, r : UNRESOLVED_float) return BOOLEAN;fnfind_rightmost
lines 333–334
find_rightmost function find_rightmost (arg : UNRESOLVED_float; y : STD_ULOGIC)
return INTEGER;fnfind_leftmost
lines 335–336
find_leftmost function find_leftmost (arg : UNRESOLVED_float; y : STD_ULOGIC)
return INTEGER;fnmaximum
lines 337–337
maximum function maximum (l, r : UNRESOLVED_float) return UNRESOLVED_float;fnminimum
lines 338–339
minimum function minimum (l, r : UNRESOLVED_float) return UNRESOLVED_float;
Conversion functions
--============================================================================
-- Conversion Functions
--============================================================================
fnresize
lines 344–363
resize -- Converts one floating point number into another.
function resize (
arg : UNRESOLVED_float; -- Floating point input
constant exponent_width : NATURAL := float_exponent_width; -- length of FP output exponent
constant fraction_width : NATURAL := float_fraction_width; -- length of FP output fraction
constant round_style : round_type := float_round_style; -- rounding option
constant check_error : BOOLEAN := float_check_error;
constant denormalize_in : BOOLEAN := float_denormalize; -- Use IEEE extended FP
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
function resize (
arg : UNRESOLVED_float; -- Floating point input
size_res : UNRESOLVED_float;
constant round_style : round_type := float_round_style; -- rounding option
constant check_error : BOOLEAN := float_check_error;
constant denormalize_in : BOOLEAN := float_denormalize; -- Use IEEE extended FP
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
fnto_float32
lines 364–371
to_float32 function to_float32 (
arg : UNRESOLVED_float;
constant round_style : round_type := float_round_style; -- rounding option
constant check_error : BOOLEAN := float_check_error;
constant denormalize_in : BOOLEAN := float_denormalize; -- Use IEEE extended FP
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float32;
fnto_float64
lines 372–379
to_float64 function to_float64 (
arg : UNRESOLVED_float;
constant round_style : round_type := float_round_style; -- rounding option
constant check_error : BOOLEAN := float_check_error;
constant denormalize_in : BOOLEAN := float_denormalize; -- Use IEEE extended FP
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float64;
fnto_float128
lines 380–388
to_float128 function to_float128 (
arg : UNRESOLVED_float;
constant round_style : round_type := float_round_style; -- rounding option
constant check_error : BOOLEAN := float_check_error;
constant denormalize_in : BOOLEAN := float_denormalize; -- Use IEEE extended FP
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float128;
-- Converts an fp into an SLV (needed for synthesis)fnalto_slv, to_StdLogicVector, to_Std_Logic_Vector
lines 389–393
to_slv, to_StdLogicVector, to_Std_Logic_Vector function to_slv (arg : UNRESOLVED_float) return STD_LOGIC_VECTOR;
alias to_StdLogicVector is to_slv [UNRESOLVED_float return STD_LOGIC_VECTOR];
alias to_Std_Logic_Vector is to_slv [UNRESOLVED_float return STD_LOGIC_VECTOR];
-- Converts an fp into an std_ulogic_vector (sulv)fnalto_sulv, to_StdULogicVector, to_Std_ULogic_Vector
lines 394–398
to_sulv, to_StdULogicVector, to_Std_ULogic_Vector function to_sulv (arg : UNRESOLVED_float) return STD_ULOGIC_VECTOR;
alias to_StdULogicVector is to_sulv [UNRESOLVED_float return STD_ULOGIC_VECTOR];
alias to_Std_ULogic_Vector is to_sulv [UNRESOLVED_float return STD_ULOGIC_VECTOR];
-- std_ulogic_vector to floatfnto_float
lines 399–508
to_float function to_float (
arg : STD_ULOGIC_VECTOR;
constant exponent_width : NATURAL := float_exponent_width; -- length of FP output exponent
constant fraction_width : NATURAL := float_fraction_width) -- length of FP output fraction
return UNRESOLVED_float;
-- Integer to float
function to_float (
arg : INTEGER;
constant exponent_width : NATURAL := float_exponent_width; -- length of FP output exponent
constant fraction_width : NATURAL := float_fraction_width; -- length of FP output fraction
constant round_style : round_type := float_round_style) -- rounding option
return UNRESOLVED_float;
-- real to float
function to_float (
arg : REAL;
constant exponent_width : NATURAL := float_exponent_width; -- length of FP output exponent
constant fraction_width : NATURAL := float_fraction_width; -- length of FP output fraction
constant round_style : round_type := float_round_style; -- rounding option
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
-- unsigned to float
function to_float (
arg : UNRESOLVED_UNSIGNED;
constant exponent_width : NATURAL := float_exponent_width; -- length of FP output exponent
constant fraction_width : NATURAL := float_fraction_width; -- length of FP output fraction
constant round_style : round_type := float_round_style) -- rounding option
return UNRESOLVED_float;
-- signed to float
function to_float (
arg : UNRESOLVED_SIGNED;
constant exponent_width : NATURAL := float_exponent_width; -- length of FP output exponent
constant fraction_width : NATURAL := float_fraction_width; -- length of FP output fraction
constant round_style : round_type := float_round_style) -- rounding option
return UNRESOLVED_float;
-- unsigned fixed point to float
function to_float (
arg : UNRESOLVED_ufixed; -- unsigned fixed point input
constant exponent_width : NATURAL := float_exponent_width; -- width of exponent
constant fraction_width : NATURAL := float_fraction_width; -- width of fraction
constant round_style : round_type := float_round_style; -- rounding
constant denormalize : BOOLEAN := float_denormalize) -- use ieee extensions
return UNRESOLVED_float;
-- signed fixed point to float
function to_float (
arg : UNRESOLVED_sfixed;
constant exponent_width : NATURAL := float_exponent_width; -- length of FP output exponent
constant fraction_width : NATURAL := float_fraction_width; -- length of FP output fraction
constant round_style : round_type := float_round_style; -- rounding
constant denormalize : BOOLEAN := float_denormalize) -- rounding option
return UNRESOLVED_float;
-- size_res functions
-- Integer to float
function to_float (
arg : INTEGER;
size_res : UNRESOLVED_float;
constant round_style : round_type := float_round_style) -- rounding option
return UNRESOLVED_float;
-- real to float
function to_float (
arg : REAL;
size_res : UNRESOLVED_float;
constant round_style : round_type := float_round_style; -- rounding option
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
-- unsigned to float
function to_float (
arg : UNRESOLVED_UNSIGNED;
size_res : UNRESOLVED_float;
constant round_style : round_type := float_round_style) -- rounding option
return UNRESOLVED_float;
-- signed to float
function to_float (
arg : UNRESOLVED_SIGNED;
size_res : UNRESOLVED_float;
constant round_style : round_type := float_round_style) -- rounding option
return UNRESOLVED_float;
-- sulv to float
function to_float (
arg : STD_ULOGIC_VECTOR;
size_res : UNRESOLVED_float)
return UNRESOLVED_float;
-- unsigned fixed point to float
function to_float (
arg : UNRESOLVED_ufixed; -- unsigned fixed point input
size_res : UNRESOLVED_float;
constant round_style : round_type := float_round_style; -- rounding
constant denormalize : BOOLEAN := float_denormalize) -- use ieee extensions
return UNRESOLVED_float;
-- signed fixed point to float
function to_float (
arg : UNRESOLVED_sfixed;
size_res : UNRESOLVED_float;
constant round_style : round_type := float_round_style; -- rounding
constant denormalize : BOOLEAN := float_denormalize) -- rounding option
return UNRESOLVED_float;
-- float to unsignedfnto_unsigned
lines 509–516
to_unsigned function to_unsigned (
arg : UNRESOLVED_float; -- floating point input
constant size : NATURAL; -- length of output
constant round_style : round_type := float_round_style; -- rounding option
constant check_error : BOOLEAN := float_check_error) -- check for errors
return UNRESOLVED_UNSIGNED;
-- float to signedfnto_signed
lines 517–524
to_signed function to_signed (
arg : UNRESOLVED_float; -- floating point input
constant size : NATURAL; -- length of output
constant round_style : round_type := float_round_style; -- rounding option
constant check_error : BOOLEAN := float_check_error) -- check for errors
return UNRESOLVED_SIGNED;
-- purpose: Converts a float to unsigned fixed pointfnto_ufixed
lines 525–535
to_ufixed function to_ufixed (
arg : UNRESOLVED_float; -- fp input
constant left_index : INTEGER; -- integer part
constant right_index : INTEGER; -- fraction part
constant overflow_style : fixed_overflow_style_type := fixed_overflow_style; -- saturate
constant round_style : fixed_round_style_type := fixed_round_style; -- rounding
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize)
return UNRESOLVED_ufixed;
-- float to signed fixed pointfnto_sfixed
lines 536–547
to_sfixed function to_sfixed (
arg : UNRESOLVED_float; -- fp input
constant left_index : INTEGER; -- integer part
constant right_index : INTEGER; -- fraction part
constant overflow_style : fixed_overflow_style_type := fixed_overflow_style; -- saturate
constant round_style : fixed_round_style_type := fixed_round_style; -- rounding
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize)
return UNRESOLVED_sfixed;
-- size_res versions
-- float to unsignedfnto_unsigned
lines 548–555
to_unsigned function to_unsigned (
arg : UNRESOLVED_float; -- floating point input
size_res : UNRESOLVED_UNSIGNED;
constant round_style : round_type := float_round_style; -- rounding option
constant check_error : BOOLEAN := float_check_error) -- check for errors
return UNRESOLVED_UNSIGNED;
-- float to signedfnto_signed
lines 556–563
to_signed function to_signed (
arg : UNRESOLVED_float; -- floating point input
size_res : UNRESOLVED_SIGNED;
constant round_style : round_type := float_round_style; -- rounding option
constant check_error : BOOLEAN := float_check_error) -- check for errors
return UNRESOLVED_SIGNED;
-- purpose: Converts a float to unsigned fixed pointfnto_ufixed
lines 564–573
to_ufixed function to_ufixed (
arg : UNRESOLVED_float; -- fp input
size_res : UNRESOLVED_ufixed;
constant overflow_style : fixed_overflow_style_type := fixed_overflow_style; -- saturate
constant round_style : fixed_round_style_type := fixed_round_style; -- rounding
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize)
return UNRESOLVED_ufixed;
-- float to signed fixed pointfnto_sfixed
lines 574–583
to_sfixed function to_sfixed (
arg : UNRESOLVED_float; -- fp input
size_res : UNRESOLVED_sfixed;
constant overflow_style : fixed_overflow_style_type := fixed_overflow_style; -- saturate
constant round_style : fixed_round_style_type := fixed_round_style; -- rounding
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize)
return UNRESOLVED_sfixed;
-- float to realfnto_real
lines 584–590
to_real function to_real (
arg : UNRESOLVED_float; -- floating point input
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return REAL;
-- float to integerfnto_integer
lines 591–597
to_integer function to_integer (
arg : UNRESOLVED_float; -- floating point input
constant round_style : round_type := float_round_style; -- rounding option
constant check_error : BOOLEAN := float_check_error) -- check for errors
return INTEGER;
-- For Verilog compatabilityfnrealtobits
lines 598–598
realtobits function realtobits (arg : REAL) return STD_ULOGIC_VECTOR;fnbitstoreal
lines 599–601
bitstoreal function bitstoreal (arg : STD_ULOGIC_VECTOR) return REAL;
-- Maps metalogical valuesfnto_01
lines 602–606
to_01 function to_01 (
arg : UNRESOLVED_float; -- floating point input
XMAP : STD_LOGIC := '0')
return UNRESOLVED_float;
fnIs_X
lines 607–607
Is_X function Is_X (arg : UNRESOLVED_float) return BOOLEAN;fnto_X01
lines 608–608
to_X01 function to_X01 (arg : UNRESOLVED_float) return UNRESOLVED_float;fnto_X01Z
lines 609–609
to_X01Z function to_X01Z (arg : UNRESOLVED_float) return UNRESOLVED_float;fnto_UX01
lines 610–611
to_UX01 function to_UX01 (arg : UNRESOLVED_float) return UNRESOLVED_float;
Vendor utility procedures (break number, normalize)
--============================================================================
-- Vendor Utility Procedures (Break Number, Normalize)
--============================================================================
prbreak_number
lines 616–640
break_number -- These two procedures were copied out of the body because they proved
-- very useful for vendor specific algorithm development
-- Break_number converts a floating point number into it's parts
-- Exponent is biased by -1
procedure break_number (
arg : in UNRESOLVED_float;
denormalize : in BOOLEAN := float_denormalize;
check_error : in BOOLEAN := float_check_error;
fract : out UNRESOLVED_UNSIGNED;
expon : out UNRESOLVED_SIGNED; -- NOTE: Add 1 to get the real exponent!
sign : out STD_ULOGIC);
procedure break_number (
arg : in UNRESOLVED_float;
denormalize : in BOOLEAN := float_denormalize;
check_error : in BOOLEAN := float_check_error;
fract : out UNRESOLVED_ufixed; -- a number between 1.0 and 2.0
expon : out UNRESOLVED_SIGNED; -- NOTE: Add 1 to get the real exponent!
sign : out STD_ULOGIC);
-- Normalize takes a fraction and and exponent and converts them into
-- a floating point number. Does the shifting and the rounding.
-- Exponent is assumed to be biased by -1
fnnormalize
lines 641–688
normalize function normalize (
fract : UNRESOLVED_UNSIGNED; -- fraction, unnormalized
expon : UNRESOLVED_SIGNED; -- exponent - 1, normalized
sign : STD_ULOGIC; -- sign bit
sticky : STD_ULOGIC := '0'; -- Sticky bit (rounding)
constant exponent_width : NATURAL := float_exponent_width; -- size of output exponent
constant fraction_width : NATURAL := float_fraction_width; -- size of output fraction
constant round_style : round_type := float_round_style; -- rounding option
constant denormalize : BOOLEAN := float_denormalize; -- Use IEEE extended FP
constant nguard : NATURAL := float_guard_bits) -- guard bits
return UNRESOLVED_float;
-- Exponent is assumed to be biased by -1
function normalize (
fract : UNRESOLVED_ufixed; -- unsigned fixed point
expon : UNRESOLVED_SIGNED; -- exponent - 1, normalized
sign : STD_ULOGIC; -- sign bit
sticky : STD_ULOGIC := '0'; -- Sticky bit (rounding)
constant exponent_width : NATURAL := float_exponent_width; -- size of output exponent
constant fraction_width : NATURAL := float_fraction_width; -- size of output fraction
constant round_style : round_type := float_round_style; -- rounding option
constant denormalize : BOOLEAN := float_denormalize; -- Use IEEE extended FP
constant nguard : NATURAL := float_guard_bits) -- guard bits
return UNRESOLVED_float;
function normalize (
fract : UNRESOLVED_UNSIGNED; -- unsigned
expon : UNRESOLVED_SIGNED; -- exponent - 1, normalized
sign : STD_ULOGIC; -- sign bit
sticky : STD_ULOGIC := '0'; -- Sticky bit (rounding)
size_res : UNRESOLVED_float; -- used for sizing only
constant round_style : round_type := float_round_style; -- rounding option
constant denormalize : BOOLEAN := float_denormalize; -- Use IEEE extended FP
constant nguard : NATURAL := float_guard_bits) -- guard bits
return UNRESOLVED_float;
-- Exponent is assumed to be biased by -1
function normalize (
fract : UNRESOLVED_ufixed; -- unsigned fixed point
expon : UNRESOLVED_SIGNED; -- exponent - 1, normalized
sign : STD_ULOGIC; -- sign bit
sticky : STD_ULOGIC := '0'; -- Sticky bit (rounding)
size_res : UNRESOLVED_float; -- used for sizing only
constant round_style : round_type := float_round_style; -- rounding option
constant denormalize : BOOLEAN := float_denormalize; -- Use IEEE extended FP
constant nguard : NATURAL := float_guard_bits) -- guard bits
return UNRESOLVED_float;
Overloads with REAL and INTEGER arguments
--============================================================================
-- Overloads with REAL and INTEGER Arguments
--============================================================================
fn"+"
lines 693–697
"+" -- overloaded versions
function "+" (l : UNRESOLVED_float; r : REAL) return UNRESOLVED_float;
function "+" (l : REAL; r : UNRESOLVED_float) return UNRESOLVED_float;
function "+" (l : UNRESOLVED_float; r : INTEGER) return UNRESOLVED_float;
function "+" (l : INTEGER; r : UNRESOLVED_float) return UNRESOLVED_float;fn"-"
lines 698–701
"-" function "-" (l : UNRESOLVED_float; r : REAL) return UNRESOLVED_float;
function "-" (l : REAL; r : UNRESOLVED_float) return UNRESOLVED_float;
function "-" (l : UNRESOLVED_float; r : INTEGER) return UNRESOLVED_float;
function "-" (l : INTEGER; r : UNRESOLVED_float) return UNRESOLVED_float;fn"*"
lines 702–705
"*" function "*" (l : UNRESOLVED_float; r : REAL) return UNRESOLVED_float;
function "*" (l : REAL; r : UNRESOLVED_float) return UNRESOLVED_float;
function "*" (l : UNRESOLVED_float; r : INTEGER) return UNRESOLVED_float;
function "*" (l : INTEGER; r : UNRESOLVED_float) return UNRESOLVED_float;fn"/"
lines 706–709
"/" function "/" (l : UNRESOLVED_float; r : REAL) return UNRESOLVED_float;
function "/" (l : REAL; r : UNRESOLVED_float) return UNRESOLVED_float;
function "/" (l : UNRESOLVED_float; r : INTEGER) return UNRESOLVED_float;
function "/" (l : INTEGER; r : UNRESOLVED_float) return UNRESOLVED_float;fn"rem"
lines 710–713
"rem" function "rem" (l : UNRESOLVED_float; r : REAL) return UNRESOLVED_float;
function "rem" (l : REAL; r : UNRESOLVED_float) return UNRESOLVED_float;
function "rem" (l : UNRESOLVED_float; r : INTEGER) return UNRESOLVED_float;
function "rem" (l : INTEGER; r : UNRESOLVED_float) return UNRESOLVED_float;fn"mod"
lines 714–719
"mod" function "mod" (l : UNRESOLVED_float; r : REAL) return UNRESOLVED_float;
function "mod" (l : REAL; r : UNRESOLVED_float) return UNRESOLVED_float;
function "mod" (l : UNRESOLVED_float; r : INTEGER) return UNRESOLVED_float;
function "mod" (l : INTEGER; r : UNRESOLVED_float) return UNRESOLVED_float;
-- overloaded compare functionsfn"="
lines 720–720
"=" function "=" (l : UNRESOLVED_float; r : REAL) return BOOLEAN;fn"/="
lines 721–721
"/=" function "/=" (l : UNRESOLVED_float; r : REAL) return BOOLEAN;fn">="
lines 722–722
">=" function ">=" (l : UNRESOLVED_float; r : REAL) return BOOLEAN;fn"<="
lines 723–723
"<=" function "<=" (l : UNRESOLVED_float; r : REAL) return BOOLEAN;fn">"
lines 724–724
">" function ">" (l : UNRESOLVED_float; r : REAL) return BOOLEAN;fn"<"
lines 725–725
"<" function "<" (l : UNRESOLVED_float; r : REAL) return BOOLEAN;fn"="
lines 726–726
"=" function "=" (l : REAL; r : UNRESOLVED_float) return BOOLEAN;fn"/="
lines 727–727
"/=" function "/=" (l : REAL; r : UNRESOLVED_float) return BOOLEAN;fn">="
lines 728–728
">=" function ">=" (l : REAL; r : UNRESOLVED_float) return BOOLEAN;fn"<="
lines 729–729
"<=" function "<=" (l : REAL; r : UNRESOLVED_float) return BOOLEAN;fn">"
lines 730–730
">" function ">" (l : REAL; r : UNRESOLVED_float) return BOOLEAN;fn"<"
lines 731–731
"<" function "<" (l : REAL; r : UNRESOLVED_float) return BOOLEAN;fn"="
lines 732–732
"=" function "=" (l : UNRESOLVED_float; r : INTEGER) return BOOLEAN;fn"/="
lines 733–733
"/=" function "/=" (l : UNRESOLVED_float; r : INTEGER) return BOOLEAN;fn">="
lines 734–734
">=" function ">=" (l : UNRESOLVED_float; r : INTEGER) return BOOLEAN;fn"<="
lines 735–735
"<=" function "<=" (l : UNRESOLVED_float; r : INTEGER) return BOOLEAN;fn">"
lines 736–736
">" function ">" (l : UNRESOLVED_float; r : INTEGER) return BOOLEAN;fn"<"
lines 737–737
"<" function "<" (l : UNRESOLVED_float; r : INTEGER) return BOOLEAN;fn"="
lines 738–738
"=" function "=" (l : INTEGER; r : UNRESOLVED_float) return BOOLEAN;fn"/="
lines 739–739
"/=" function "/=" (l : INTEGER; r : UNRESOLVED_float) return BOOLEAN;fn">="
lines 740–740
">=" function ">=" (l : INTEGER; r : UNRESOLVED_float) return BOOLEAN;fn"<="
lines 741–741
"<=" function "<=" (l : INTEGER; r : UNRESOLVED_float) return BOOLEAN;fn">"
lines 742–742
">" function ">" (l : INTEGER; r : UNRESOLVED_float) return BOOLEAN;fn"<"
lines 743–743
"<" function "<" (l : INTEGER; r : UNRESOLVED_float) return BOOLEAN;fn"?="
lines 744–744
"?=" function "?=" (l : UNRESOLVED_float; r : REAL) return STD_ULOGIC;fn"?/="
lines 745–745
"?/=" function "?/=" (l : UNRESOLVED_float; r : REAL) return STD_ULOGIC;fn"?>"
lines 746–746
"?>" function "?>" (l : UNRESOLVED_float; r : REAL) return STD_ULOGIC;fn"?>="
lines 747–747
"?>=" function "?>=" (l : UNRESOLVED_float; r : REAL) return STD_ULOGIC;fn"?<"
lines 748–748
"?<" function "?<" (l : UNRESOLVED_float; r : REAL) return STD_ULOGIC;fn"?<="
lines 749–749
"?<=" function "?<=" (l : UNRESOLVED_float; r : REAL) return STD_ULOGIC;fn"?="
lines 750–750
"?=" function "?=" (l : REAL; r : UNRESOLVED_float) return STD_ULOGIC;fn"?/="
lines 751–751
"?/=" function "?/=" (l : REAL; r : UNRESOLVED_float) return STD_ULOGIC;fn"?>"
lines 752–752
"?>" function "?>" (l : REAL; r : UNRESOLVED_float) return STD_ULOGIC;fn"?>="
lines 753–753
"?>=" function "?>=" (l : REAL; r : UNRESOLVED_float) return STD_ULOGIC;fn"?<"
lines 754–754
"?<" function "?<" (l : REAL; r : UNRESOLVED_float) return STD_ULOGIC;fn"?<="
lines 755–755
"?<=" function "?<=" (l : REAL; r : UNRESOLVED_float) return STD_ULOGIC;fn"?="
lines 756–756
"?=" function "?=" (l : UNRESOLVED_float; r : INTEGER) return STD_ULOGIC;fn"?/="
lines 757–757
"?/=" function "?/=" (l : UNRESOLVED_float; r : INTEGER) return STD_ULOGIC;fn"?>"
lines 758–758
"?>" function "?>" (l : UNRESOLVED_float; r : INTEGER) return STD_ULOGIC;fn"?>="
lines 759–759
"?>=" function "?>=" (l : UNRESOLVED_float; r : INTEGER) return STD_ULOGIC;fn"?<"
lines 760–760
"?<" function "?<" (l : UNRESOLVED_float; r : INTEGER) return STD_ULOGIC;fn"?<="
lines 761–761
"?<=" function "?<=" (l : UNRESOLVED_float; r : INTEGER) return STD_ULOGIC;fn"?="
lines 762–762
"?=" function "?=" (l : INTEGER; r : UNRESOLVED_float) return STD_ULOGIC;fn"?/="
lines 763–763
"?/=" function "?/=" (l : INTEGER; r : UNRESOLVED_float) return STD_ULOGIC;fn"?>"
lines 764–764
"?>" function "?>" (l : INTEGER; r : UNRESOLVED_float) return STD_ULOGIC;fn"?>="
lines 765–765
"?>=" function "?>=" (l : INTEGER; r : UNRESOLVED_float) return STD_ULOGIC;fn"?<"
lines 766–766
"?<" function "?<" (l : INTEGER; r : UNRESOLVED_float) return STD_ULOGIC;fn"?<="
lines 767–768
"?<=" function "?<=" (l : INTEGER; r : UNRESOLVED_float) return STD_ULOGIC;
-- minimum and maximum overloadsfnmaximum
lines 769–769
maximum function maximum (l : UNRESOLVED_float; r : REAL) return UNRESOLVED_float;fnminimum
lines 770–770
minimum function minimum (l : UNRESOLVED_float; r : REAL) return UNRESOLVED_float;fnmaximum
lines 771–771
maximum function maximum (l : REAL; r : UNRESOLVED_float) return UNRESOLVED_float;fnminimum
lines 772–772
minimum function minimum (l : REAL; r : UNRESOLVED_float) return UNRESOLVED_float;fnmaximum
lines 773–773
maximum function maximum (l : UNRESOLVED_float; r : INTEGER) return UNRESOLVED_float;fnminimum
lines 774–774
minimum function minimum (l : UNRESOLVED_float; r : INTEGER) return UNRESOLVED_float;fnmaximum
lines 775–775
maximum function maximum (l : INTEGER; r : UNRESOLVED_float) return UNRESOLVED_float;fnminimum
lines 776–776
minimum function minimum (l : INTEGER; r : UNRESOLVED_float) return UNRESOLVED_float;Logical functions
--============================================================================
-- Logical Functions
--============================================================================
fn"not"
lines 781–781
"not" function "not" (l : UNRESOLVED_float) return UNRESOLVED_float;fn"and"
lines 782–782
"and" function "and" (l, r : UNRESOLVED_float) return UNRESOLVED_float;fn"or"
lines 783–783
"or" function "or" (l, r : UNRESOLVED_float) return UNRESOLVED_float;fn"nand"
lines 784–784
"nand" function "nand" (l, r : UNRESOLVED_float) return UNRESOLVED_float;fn"nor"
lines 785–785
"nor" function "nor" (l, r : UNRESOLVED_float) return UNRESOLVED_float;fn"xor"
lines 786–786
"xor" function "xor" (l, r : UNRESOLVED_float) return UNRESOLVED_float;fn"xnor"
lines 787–788
"xnor" function "xnor" (l, r : UNRESOLVED_float) return UNRESOLVED_float;
-- Vector and std_ulogic functions, same as functions in numeric_stdfn"and"
lines 789–792
"and" function "and" (l : STD_ULOGIC; r : UNRESOLVED_float)
return UNRESOLVED_float;
function "and" (l : UNRESOLVED_float; r : STD_ULOGIC)
return UNRESOLVED_float;fn"or"
lines 793–796
"or" function "or" (l : STD_ULOGIC; r : UNRESOLVED_float)
return UNRESOLVED_float;
function "or" (l : UNRESOLVED_float; r : STD_ULOGIC)
return UNRESOLVED_float;fn"nand"
lines 797–800
"nand" function "nand" (l : STD_ULOGIC; r : UNRESOLVED_float)
return UNRESOLVED_float;
function "nand" (l : UNRESOLVED_float; r : STD_ULOGIC)
return UNRESOLVED_float;fn"nor"
lines 801–804
"nor" function "nor" (l : STD_ULOGIC; r : UNRESOLVED_float)
return UNRESOLVED_float;
function "nor" (l : UNRESOLVED_float; r : STD_ULOGIC)
return UNRESOLVED_float;fn"xor"
lines 805–808
"xor" function "xor" (l : STD_ULOGIC; r : UNRESOLVED_float)
return UNRESOLVED_float;
function "xor" (l : UNRESOLVED_float; r : STD_ULOGIC)
return UNRESOLVED_float;fn"xnor"
lines 809–813
"xnor" function "xnor" (l : STD_ULOGIC; r : UNRESOLVED_float)
return UNRESOLVED_float;
function "xnor" (l : UNRESOLVED_float; r : STD_ULOGIC)
return UNRESOLVED_float;
-- Reduction operators, same as numeric_std functionsfn"and"
lines 814–814
"and" function "and" (l : UNRESOLVED_float) return STD_ULOGIC;fn"nand"
lines 815–815
"nand" function "nand" (l : UNRESOLVED_float) return STD_ULOGIC;fn"or"
lines 816–816
"or" function "or" (l : UNRESOLVED_float) return STD_ULOGIC;fn"nor"
lines 817–817
"nor" function "nor" (l : UNRESOLVED_float) return STD_ULOGIC;fn"xor"
lines 818–818
"xor" function "xor" (l : UNRESOLVED_float) return STD_ULOGIC;fn"xnor"
lines 819–821
"xnor" function "xnor" (l : UNRESOLVED_float) return STD_ULOGIC;
-- Note: "sla", "sra", "sll", "slr", "rol" and "ror" not implemented.Recommended functions from the IEEE 754 appendix
--============================================================================
-- Recommended Functions from the IEEE 754 Appendix
--============================================================================
fnCopysign
lines 827–830
Copysign -- returns x with the sign of y.
function Copysign (x, y : UNRESOLVED_float) return UNRESOLVED_float;
-- Returns y * 2**n for integral values of N without computing 2**nfnScalb
lines 831–848
Scalb function Scalb (
y : UNRESOLVED_float; -- floating point input
N : INTEGER; -- exponent to add
constant round_style : round_type := float_round_style; -- rounding option
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
-- Returns y * 2**n for integral values of N without computing 2**n
function Scalb (
y : UNRESOLVED_float; -- floating point input
N : UNRESOLVED_SIGNED; -- exponent to add
constant round_style : round_type := float_round_style; -- rounding option
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize) -- Use IEEE extended FP
return UNRESOLVED_float;
-- returns the unbiased exponent of xfnLogb
lines 849–852
Logb function Logb (x : UNRESOLVED_float) return INTEGER;
function Logb (x : UNRESOLVED_float) return UNRESOLVED_SIGNED;
-- returns the next representable neighbor of x in the direction toward yfnNextafter
lines 853–859
Nextafter function Nextafter (
x, y : UNRESOLVED_float; -- floating point input
constant check_error : BOOLEAN := float_check_error; -- check for errors
constant denormalize : BOOLEAN := float_denormalize)
return UNRESOLVED_float;
-- Returns TRUE if X is unordered with Y.fnUnordered
lines 860–860
Unordered function Unordered (x, y : UNRESOLVED_float) return BOOLEAN;fnFinite
lines 861–861
Finite function Finite (x : UNRESOLVED_float) return BOOLEAN;fnIsnan
lines 862–864
Isnan function Isnan (x : UNRESOLVED_float) return BOOLEAN;
-- Function to return constants.fnzerofp
lines 865–868
zerofp function zerofp (
constant exponent_width : NATURAL := float_exponent_width; -- exponent
constant fraction_width : NATURAL := float_fraction_width) -- fraction
return UNRESOLVED_float;fnnanfp
lines 869–872
nanfp function nanfp (
constant exponent_width : NATURAL := float_exponent_width; -- exponent
constant fraction_width : NATURAL := float_fraction_width) -- fraction
return UNRESOLVED_float;fnqnanfp
lines 873–876
qnanfp function qnanfp (
constant exponent_width : NATURAL := float_exponent_width; -- exponent
constant fraction_width : NATURAL := float_fraction_width) -- fraction
return UNRESOLVED_float;fnpos_inffp
lines 877–880
pos_inffp function pos_inffp (
constant exponent_width : NATURAL := float_exponent_width; -- exponent
constant fraction_width : NATURAL := float_fraction_width) -- fraction
return UNRESOLVED_float;fnneg_inffp
lines 881–884
neg_inffp function neg_inffp (
constant exponent_width : NATURAL := float_exponent_width; -- exponent
constant fraction_width : NATURAL := float_fraction_width) -- fraction
return UNRESOLVED_float;fnneg_zerofp
lines 885–889
neg_zerofp function neg_zerofp (
constant exponent_width : NATURAL := float_exponent_width; -- exponent
constant fraction_width : NATURAL := float_fraction_width) -- fraction
return UNRESOLVED_float;
-- size_res versionsfnzerofp
lines 890–892
zerofp function zerofp (
size_res : UNRESOLVED_float) -- variable is only use for sizing
return UNRESOLVED_float;fnnanfp
lines 893–895
nanfp function nanfp (
size_res : UNRESOLVED_float) -- variable is only use for sizing
return UNRESOLVED_float;fnqnanfp
lines 896–898
qnanfp function qnanfp (
size_res : UNRESOLVED_float) -- variable is only use for sizing
return UNRESOLVED_float;fnpos_inffp
lines 899–901
pos_inffp function pos_inffp (
size_res : UNRESOLVED_float) -- variable is only use for sizing
return UNRESOLVED_float;fnneg_inffp
lines 902–904
neg_inffp function neg_inffp (
size_res : UNRESOLVED_float) -- variable is only use for sizing
return UNRESOLVED_float;fnneg_zerofp
lines 905–908
neg_zerofp function neg_zerofp (
size_res : UNRESOLVED_float) -- variable is only use for sizing
return UNRESOLVED_float;
String and textio functions
--===========================================================================
-- string and textio Functions
--===========================================================================
prWRITE
lines 913–920
WRITE -- writes S:EEEE:FFFFFFFF
procedure WRITE (
L : inout LINE; -- access type (pointer)
VALUE : in UNRESOLVED_float; -- value to write
JUSTIFIED : in SIDE := right; -- which side to justify text
FIELD : in WIDTH := 0); -- width of field
-- Reads SEEEEFFFFFFFF, "." and ":" are ignoredprREAD
lines 921–924
READ procedure READ (L : inout LINE; VALUE : out UNRESOLVED_float);
procedure READ (L : inout LINE; VALUE : out UNRESOLVED_float;
GOOD : out BOOLEAN);
alBREAD, BWRITE, BINARY_READ, BINARY_WRITE
lines 925–931
BREAD, BWRITE, BINARY_READ, BINARY_WRITE alias BREAD is READ [LINE, UNRESOLVED_float, BOOLEAN];
alias BREAD is READ [LINE, UNRESOLVED_float];
alias BWRITE is WRITE [LINE, UNRESOLVED_float, SIDE, WIDTH];
alias BINARY_READ is READ [LINE, UNRESOLVED_float, BOOLEAN];
alias BINARY_READ is READ [LINE, UNRESOLVED_float];
alias BINARY_WRITE is WRITE [LINE, UNRESOLVED_float, SIDE, WIDTH];
prOWRITE
lines 932–938
OWRITE procedure OWRITE (
L : inout LINE; -- access type (pointer)
VALUE : in UNRESOLVED_float; -- value to write
JUSTIFIED : in SIDE := right; -- which side to justify text
FIELD : in WIDTH := 0); -- width of field
-- Octal read with padding, no separators usedpralOREAD, OCTAL_READ, OCTAL_WRITE
lines 939–946
OREAD, OCTAL_READ, OCTAL_WRITE procedure OREAD (L : inout LINE; VALUE : out UNRESOLVED_float);
procedure OREAD (L : inout LINE; VALUE : out UNRESOLVED_float;
GOOD : out BOOLEAN);
alias OCTAL_READ is OREAD [LINE, UNRESOLVED_float, BOOLEAN];
alias OCTAL_READ is OREAD [LINE, UNRESOLVED_float];
alias OCTAL_WRITE is OWRITE [LINE, UNRESOLVED_float, SIDE, WIDTH];
-- Hex write with padding, no separatorsprHWRITE
lines 947–953
HWRITE procedure HWRITE (
L : inout LINE; -- access type (pointer)
VALUE : in UNRESOLVED_float; -- value to write
JUSTIFIED : in SIDE := right; -- which side to justify text
FIELD : in WIDTH := 0); -- width of field
-- Hex read with padding, no separators usedpralHREAD, HEX_READ, HEX_WRITE
lines 954–961
HREAD, HEX_READ, HEX_WRITE procedure HREAD (L : inout LINE; VALUE : out UNRESOLVED_float);
procedure HREAD (L : inout LINE; VALUE : out UNRESOLVED_float;
GOOD : out BOOLEAN);
alias HEX_READ is HREAD [LINE, UNRESOLVED_float, BOOLEAN];
alias HEX_READ is HREAD [LINE, UNRESOLVED_float];
alias HEX_WRITE is HWRITE [LINE, UNRESOLVED_float, SIDE, WIDTH];
-- returns "S:EEEE:FFFFFFFF"fnalto_string, TO_BSTRING, TO_BINARY_STRING
lines 962–966
to_string, TO_BSTRING, TO_BINARY_STRING function to_string (value : UNRESOLVED_float) return STRING;
alias TO_BSTRING is TO_STRING [UNRESOLVED_float return STRING];
alias TO_BINARY_STRING is TO_STRING [UNRESOLVED_float return STRING];
-- Returns a HEX string, with paddingfnalto_hstring, TO_HEX_STRING
lines 967–970
to_hstring, TO_HEX_STRING function to_hstring (value : UNRESOLVED_float) return STRING;
alias TO_HEX_STRING is to_hstring [UNRESOLVED_float return STRING];
-- Returns and octal string, with paddingfnalto_ostring, TO_OCTAL_STRING
lines 971–973
to_ostring, TO_OCTAL_STRING function to_ostring (value : UNRESOLVED_float) return STRING;
alias TO_OCTAL_STRING is to_ostring [UNRESOLVED_float return STRING];
fnalfrom_string, from_bstring, from_binary_string
lines 974–982
from_string, from_bstring, from_binary_string function from_string (
bstring : STRING; -- binary string
constant exponent_width : NATURAL := float_exponent_width;
constant fraction_width : NATURAL := float_fraction_width)
return UNRESOLVED_float;
alias from_bstring is from_string [STRING, NATURAL, NATURAL
return UNRESOLVED_float];
alias from_binary_string is from_string [STRING, NATURAL, NATURAL
return UNRESOLVED_float];fnalfrom_ostring, from_octal_string
lines 983–990
from_ostring, from_octal_string function from_ostring (
ostring : STRING; -- Octal string
constant exponent_width : NATURAL := float_exponent_width;
constant fraction_width : NATURAL := float_fraction_width)
return UNRESOLVED_float;
alias from_octal_string is from_ostring [STRING, NATURAL, NATURAL
return UNRESOLVED_float];
fnalfrom_hstring, from_hex_string
lines 991–998
from_hstring, from_hex_string function from_hstring (
hstring : STRING; -- hex string
constant exponent_width : NATURAL := float_exponent_width;
constant fraction_width : NATURAL := float_fraction_width)
return UNRESOLVED_float;
alias from_hex_string is from_hstring [STRING, NATURAL, NATURAL
return UNRESOLVED_float];
fnalfrom_string, from_bstring, from_binary_string
lines 999–1007
from_string, from_bstring, from_binary_string function from_string (
bstring : STRING; -- binary string
size_res : UNRESOLVED_float) -- used for sizing only
return UNRESOLVED_float;
alias from_bstring is from_string [STRING, UNRESOLVED_float
return UNRESOLVED_float];
alias from_binary_string is from_string [STRING, UNRESOLVED_float
return UNRESOLVED_float];
fnalfrom_ostring, from_octal_string
lines 1008–1014
from_ostring, from_octal_string function from_ostring (
ostring : STRING; -- Octal string
size_res : UNRESOLVED_float) -- used for sizing only
return UNRESOLVED_float;
alias from_octal_string is from_ostring [STRING, UNRESOLVED_float
return UNRESOLVED_float];
fnalfrom_hstring, from_hex_string
lines 1015–1021
from_hstring, from_hex_string function from_hstring (
hstring : STRING; -- hex string
size_res : UNRESOLVED_float) -- used for sizing only
return UNRESOLVED_float;
alias from_hex_string is from_hstring [STRING, UNRESOLVED_float
return UNRESOLVED_float];
end package float_generic_pkg;
