FLOAT_GENERIC_PKG package declaration

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.vhdl in the IEEE 1076 OSR, tag 1076-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 of STD_ULOGIC) and the resolved subtype float, plus the named-precision subtypes float32, float64, and float128.
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

ieee/float_generic_pkg.vhdl: declaration (1000 lines) 188 groups
License: Apache License 2.0 Download
doc

File header Comment block (42 lines)

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 (<>) );
co

CopyRightNotice

lines 71–74
  -- 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
  --============================================================================
ty

valid_fpstate

lines 145–157
  -- 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
co

fphdlsynth_or_real

lines 158–161
  -- This deferred constant will tell you if the package body is synthesizable
  -- or implemented as real numbers.
  constant fphdlsynth_or_real : BOOLEAN;  -- deferred constant
fn

Classfp

lines 162–167
  -- 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
  -- 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
  function "rem" (l, r : UNRESOLVED_float) return UNRESOLVED_float;
fn

"mod"

lines 184–191
  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
fn

add

lines 192–199
  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;
fn

subtract

lines 200–207
  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;
fn

multiply

lines 208–215
  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;
fn

divide

lines 216–223
  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;
fn

remainder

lines 224–231
  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;
fn

modulo

lines 232–240
  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;

  -- reciprocal
fn

reciprocal

lines 241–248
  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;
fn

dividebyp2

lines 249–257
  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 + c
fn

mac

lines 258–266
  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)
fn

sqrt

lines 267–274
  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;
fn

Is_Negative

lines 275–276
  function Is_Negative (arg : UNRESOLVED_float) return BOOLEAN;

Comparison and relational operators (=, /=, <, <=, >, >=, maximum, minimum)

  --============================================================================
  -- Comparison and Relational Operators (=, /=, <, <=, >, >=, maximum, minimum)
  --============================================================================
fn

eq

lines 281–286
  function eq (                               -- equal =
    l, r                 : UNRESOLVED_float;  -- floating point input
    constant check_error : BOOLEAN := float_check_error;
    constant denormalize : BOOLEAN := float_denormalize)
    return BOOLEAN;
fn

ne

lines 287–292
  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;
fn

lt

lines 293–298
  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;
fn

gt

lines 299–304
  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;
fn

le

lines 305–310
  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;
fn

ge

lines 311–317
  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 these
fn

"="

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;
fn

std_match

lines 332–332
  function std_match (l, r : UNRESOLVED_float) return BOOLEAN;
fn

find_rightmost

lines 333–334
  function find_rightmost (arg : UNRESOLVED_float; y : STD_ULOGIC)
    return INTEGER;
fn

find_leftmost

lines 335–336
  function find_leftmost (arg : UNRESOLVED_float; y : STD_ULOGIC)
    return INTEGER;
fn

maximum

lines 337–337
  function maximum (l, r : UNRESOLVED_float) return UNRESOLVED_float;
fn

minimum

lines 338–339
  function minimum (l, r : UNRESOLVED_float) return UNRESOLVED_float;

Conversion functions

  --============================================================================
  -- Conversion Functions
  --============================================================================
fn

resize 2 functions

lines 344–363
  -- 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;
fn

to_float32

lines 364–371
  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;
fn

to_float64

lines 372–379
  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;
fn

to_float128

lines 380–388
  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)
fnal

to_slv, to_StdLogicVector, to_Std_Logic_Vector function and 2 aliases

lines 389–393
  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)
fnal

to_sulv, to_StdULogicVector, to_Std_ULogic_Vector function and 2 aliases

lines 394–398
  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 float
fn

to_float 14 functions

lines 399–508
  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 unsigned
fn

to_unsigned

lines 509–516
  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 signed
fn

to_signed

lines 517–524
  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 point
fn

to_ufixed

lines 525–535
  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 point
fn

to_sfixed

lines 536–547
  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 unsigned
fn

to_unsigned

lines 548–555
  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 signed
fn

to_signed

lines 556–563
  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 point
fn

to_ufixed

lines 564–573
  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 point
fn

to_sfixed

lines 574–583
  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 real
fn

to_real

lines 584–590
  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 integer
fn

to_integer

lines 591–597
  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 compatability
fn

realtobits

lines 598–598
  function realtobits (arg : REAL) return STD_ULOGIC_VECTOR;
fn

bitstoreal

lines 599–601
  function bitstoreal (arg : STD_ULOGIC_VECTOR) return REAL;

  -- Maps metalogical values
fn

to_01

lines 602–606
  function to_01 (
    arg  : UNRESOLVED_float;            -- floating point input
    XMAP : STD_LOGIC := '0')
    return UNRESOLVED_float;
fn

Is_X

lines 607–607
  function Is_X (arg    : UNRESOLVED_float) return BOOLEAN;
fn

to_X01

lines 608–608
  function to_X01 (arg  : UNRESOLVED_float) return UNRESOLVED_float;
fn

to_X01Z

lines 609–609
  function to_X01Z (arg : UNRESOLVED_float) return UNRESOLVED_float;
fn

to_UX01

lines 610–611
  function to_UX01 (arg : UNRESOLVED_float) return UNRESOLVED_float;

Vendor utility procedures (break number, normalize)

  --============================================================================
  -- Vendor Utility Procedures (Break Number, Normalize)
  --============================================================================
pr

break_number 2 procedures

lines 616–640
  -- 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
fn

normalize 4 functions

lines 641–688
  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

"+" 4 functions

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

"-" 4 functions

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

"*" 4 functions

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

"/" 4 functions

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" 4 functions

lines 710–713
  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" 4 functions

lines 714–719
  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 functions
fn

"="

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 overloads
fn

maximum

lines 769–769
  function maximum (l : UNRESOLVED_float; r : REAL)    return UNRESOLVED_float;
fn

minimum

lines 770–770
  function minimum (l : UNRESOLVED_float; r : REAL)    return UNRESOLVED_float;
fn

maximum

lines 771–771
  function maximum (l : REAL; r : UNRESOLVED_float)    return UNRESOLVED_float;
fn

minimum

lines 772–772
  function minimum (l : REAL; r : UNRESOLVED_float)    return UNRESOLVED_float;
fn

maximum

lines 773–773
  function maximum (l : UNRESOLVED_float; r : INTEGER) return UNRESOLVED_float;
fn

minimum

lines 774–774
  function minimum (l : UNRESOLVED_float; r : INTEGER) return UNRESOLVED_float;
fn

maximum

lines 775–775
  function maximum (l : INTEGER; r : UNRESOLVED_float) return UNRESOLVED_float;
fn

minimum

lines 776–776
  function minimum (l : INTEGER; r : UNRESOLVED_float) return UNRESOLVED_float;

Logical functions

  --============================================================================
  -- Logical Functions
  --============================================================================
fn

"not"

lines 781–781
  function "not"  (l    : UNRESOLVED_float) return UNRESOLVED_float;
fn

"and"

lines 782–782
  function "and"  (l, r : UNRESOLVED_float) return UNRESOLVED_float;
fn

"or"

lines 783–783
  function "or"   (l, r : UNRESOLVED_float) return UNRESOLVED_float;
fn

"nand"

lines 784–784
  function "nand" (l, r : UNRESOLVED_float) return UNRESOLVED_float;
fn

"nor"

lines 785–785
  function "nor"  (l, r : UNRESOLVED_float) return UNRESOLVED_float;
fn

"xor"

lines 786–786
  function "xor"  (l, r : UNRESOLVED_float) return UNRESOLVED_float;
fn

"xnor"

lines 787–788
  function "xnor" (l, r : UNRESOLVED_float) return UNRESOLVED_float;
  -- Vector and std_ulogic functions, same as functions in numeric_std
fn

"and" 2 functions

lines 789–792
  function "and" (l : STD_ULOGIC; r : UNRESOLVED_float)
    return UNRESOLVED_float;
  function "and" (l : UNRESOLVED_float; r : STD_ULOGIC)
    return UNRESOLVED_float;
fn

"or" 2 functions

lines 793–796
  function "or" (l : STD_ULOGIC; r : UNRESOLVED_float)
    return UNRESOLVED_float;
  function "or" (l : UNRESOLVED_float; r : STD_ULOGIC)
    return UNRESOLVED_float;
fn

"nand" 2 functions

lines 797–800
  function "nand" (l : STD_ULOGIC; r : UNRESOLVED_float)
    return UNRESOLVED_float;
  function "nand" (l : UNRESOLVED_float; r : STD_ULOGIC)
    return UNRESOLVED_float;
fn

"nor" 2 functions

lines 801–804
  function "nor" (l : STD_ULOGIC; r : UNRESOLVED_float)
    return UNRESOLVED_float;
  function "nor" (l : UNRESOLVED_float; r : STD_ULOGIC)
    return UNRESOLVED_float;
fn

"xor" 2 functions

lines 805–808
  function "xor" (l : STD_ULOGIC; r : UNRESOLVED_float)
    return UNRESOLVED_float;
  function "xor" (l : UNRESOLVED_float; r : STD_ULOGIC)
    return UNRESOLVED_float;
fn

"xnor" 2 functions

lines 809–813
  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 functions
fn

"and"

lines 814–814
  function "and"  (l : UNRESOLVED_float) return STD_ULOGIC;
fn

"nand"

lines 815–815
  function "nand" (l : UNRESOLVED_float) return STD_ULOGIC;
fn

"or"

lines 816–816
  function "or"   (l : UNRESOLVED_float) return STD_ULOGIC;
fn

"nor"

lines 817–817
  function "nor"  (l : UNRESOLVED_float) return STD_ULOGIC;
fn

"xor"

lines 818–818
  function "xor"  (l : UNRESOLVED_float) return STD_ULOGIC;
fn

"xnor"

lines 819–821
  function "xnor" (l : UNRESOLVED_float) return STD_ULOGIC;

  -- Note: "sla", "sra", "sll", "slr", "rol" and "ror" not implemented.
fn

Copysign

lines 827–830
  -- 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**n
fn

Scalb 2 functions

lines 831–848
  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 x
fn

Logb 2 functions

lines 849–852
  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 y
fn

Nextafter

lines 853–859
  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.
fn

Unordered

lines 860–860
  function Unordered (x, y : UNRESOLVED_float) return BOOLEAN;
fn

Finite

lines 861–861
  function Finite (x       : UNRESOLVED_float) return BOOLEAN;
fn

Isnan

lines 862–864
  function Isnan (x        : UNRESOLVED_float) return BOOLEAN;

  -- Function to return constants.
fn

zerofp

lines 865–868
  function zerofp (
    constant exponent_width : NATURAL := float_exponent_width;  -- exponent
    constant fraction_width : NATURAL := float_fraction_width)  -- fraction
    return UNRESOLVED_float;
fn

nanfp

lines 869–872
  function nanfp (
    constant exponent_width : NATURAL := float_exponent_width;  -- exponent
    constant fraction_width : NATURAL := float_fraction_width)  -- fraction
    return UNRESOLVED_float;
fn

qnanfp

lines 873–876
  function qnanfp (
    constant exponent_width : NATURAL := float_exponent_width;  -- exponent
    constant fraction_width : NATURAL := float_fraction_width)  -- fraction
    return UNRESOLVED_float;
fn

pos_inffp

lines 877–880
  function pos_inffp (
    constant exponent_width : NATURAL := float_exponent_width;  -- exponent
    constant fraction_width : NATURAL := float_fraction_width)  -- fraction
    return UNRESOLVED_float;
fn

neg_inffp

lines 881–884
  function neg_inffp (
    constant exponent_width : NATURAL := float_exponent_width;  -- exponent
    constant fraction_width : NATURAL := float_fraction_width)  -- fraction
    return UNRESOLVED_float;
fn

neg_zerofp

lines 885–889
  function neg_zerofp (
    constant exponent_width : NATURAL := float_exponent_width;  -- exponent
    constant fraction_width : NATURAL := float_fraction_width)  -- fraction
    return UNRESOLVED_float;
  -- size_res versions
fn

zerofp

lines 890–892
  function zerofp (
    size_res : UNRESOLVED_float)        -- variable is only use for sizing
    return UNRESOLVED_float;
fn

nanfp

lines 893–895
  function nanfp (
    size_res : UNRESOLVED_float)        -- variable is only use for sizing
    return UNRESOLVED_float;
fn

qnanfp

lines 896–898
  function qnanfp (
    size_res : UNRESOLVED_float)        -- variable is only use for sizing
    return UNRESOLVED_float;
fn

pos_inffp

lines 899–901
  function pos_inffp (
    size_res : UNRESOLVED_float)        -- variable is only use for sizing
    return UNRESOLVED_float;
fn

neg_inffp

lines 902–904
  function neg_inffp (
    size_res : UNRESOLVED_float)        -- variable is only use for sizing
    return UNRESOLVED_float;
fn

neg_zerofp

lines 905–908
  function neg_zerofp (
    size_res : UNRESOLVED_float)        -- variable is only use for sizing
    return UNRESOLVED_float;

String and textio functions

  --===========================================================================
  -- string and textio Functions
  --===========================================================================
pr

WRITE

lines 913–920
  -- 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 ignored
pr

READ 2 procedures

lines 921–924
  procedure READ (L    : inout LINE; VALUE : out UNRESOLVED_float);
  procedure READ (L    : inout LINE; VALUE : out UNRESOLVED_float;
                  GOOD : out   BOOLEAN);
al

BREAD, BWRITE, BINARY_READ, BINARY_WRITE 6 aliases

lines 925–931
  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];
pr

OWRITE

lines 932–938
  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 used
pral

OREAD, OCTAL_READ, OCTAL_WRITE 2 procedures and 3 aliases

lines 939–946
  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 separators
pr

HWRITE

lines 947–953
  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 used
pral

HREAD, HEX_READ, HEX_WRITE 2 procedures and 3 aliases

lines 954–961
  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"
fnal

to_string, TO_BSTRING, TO_BINARY_STRING function and 2 aliases

lines 962–966
  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 padding
fnal

to_hstring, TO_HEX_STRING function and alias

lines 967–970
  function to_hstring (value : UNRESOLVED_float) return STRING;
  alias TO_HEX_STRING is to_hstring [UNRESOLVED_float return STRING];

  -- Returns and octal string, with padding
fnal

to_ostring, TO_OCTAL_STRING function and alias

lines 971–973
  function to_ostring (value : UNRESOLVED_float) return STRING;
  alias TO_OCTAL_STRING is to_ostring [UNRESOLVED_float return STRING];
fnal

from_string, from_bstring, from_binary_string function and 2 aliases

lines 974–982
  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];
fnal

from_ostring, from_octal_string function and alias

lines 983–990
  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];
fnal

from_hstring, from_hex_string function and alias

lines 991–998
  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];
fnal

from_string, from_bstring, from_binary_string function and 2 aliases

lines 999–1007
  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];
fnal

from_ostring, from_octal_string function and alias

lines 1008–1014
  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];
fnal

from_hstring, from_hex_string function and alias

lines 1015–1021
  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;