📄 float_pkg_c.vhdl
字号:
arg : UNRESOLVED_float; -- floating point input XMAP : STD_LOGIC := '0') return UNRESOLVED_float; function Is_X (arg : UNRESOLVED_float) return BOOLEAN; function to_X01 (arg : UNRESOLVED_float) return UNRESOLVED_float; function to_X01Z (arg : UNRESOLVED_float) return UNRESOLVED_float; function to_UX01 (arg : UNRESOLVED_float) return UNRESOLVED_float; -- 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 UNSIGNED; expon : out 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 ufixed; -- a number between 1.0 and 2.0 expon : out 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 function normalize ( fract : UNSIGNED; -- fraction, unnormalized expon : 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 : ufixed; -- unsigned fixed point expon : 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 : UNSIGNED; -- unsigned expon : 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 : ufixed; -- unsigned fixed point expon : 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; -- 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; 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; 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; 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; 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; 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 function "=" (l : UNRESOLVED_float; r : REAL) return BOOLEAN; function "/=" (l : UNRESOLVED_float; r : REAL) return BOOLEAN; function ">=" (l : UNRESOLVED_float; r : REAL) return BOOLEAN; function "<=" (l : UNRESOLVED_float; r : REAL) return BOOLEAN; function ">" (l : UNRESOLVED_float; r : REAL) return BOOLEAN; function "<" (l : UNRESOLVED_float; r : REAL) return BOOLEAN; function "=" (l : REAL; r : UNRESOLVED_float) return BOOLEAN; function "/=" (l : REAL; r : UNRESOLVED_float) return BOOLEAN; function ">=" (l : REAL; r : UNRESOLVED_float) return BOOLEAN; function "<=" (l : REAL; r : UNRESOLVED_float) return BOOLEAN; function ">" (l : REAL; r : UNRESOLVED_float) return BOOLEAN; function "<" (l : REAL; r : UNRESOLVED_float) return BOOLEAN; function "=" (l : UNRESOLVED_float; r : INTEGER) return BOOLEAN; function "/=" (l : UNRESOLVED_float; r : INTEGER) return BOOLEAN; function ">=" (l : UNRESOLVED_float; r : INTEGER) return BOOLEAN; function "<=" (l : UNRESOLVED_float; r : INTEGER) return BOOLEAN; function ">" (l : UNRESOLVED_float; r : INTEGER) return BOOLEAN; function "<" (l : UNRESOLVED_float; r : INTEGER) return BOOLEAN; function "=" (l : INTEGER; r : UNRESOLVED_float) return BOOLEAN; function "/=" (l : INTEGER; r : UNRESOLVED_float) return BOOLEAN; function ">=" (l : INTEGER; r : UNRESOLVED_float) return BOOLEAN; function "<=" (l : INTEGER; r : UNRESOLVED_float) return BOOLEAN; function ">" (l : INTEGER; r : UNRESOLVED_float) return BOOLEAN; function "<" (l : INTEGER; r : UNRESOLVED_float) return BOOLEAN; function \?=\ (l : UNRESOLVED_float; r : REAL) return STD_ULOGIC; function \?/=\ (l : UNRESOLVED_float; r : REAL) return STD_ULOGIC; function \?>\ (l : UNRESOLVED_float; r : REAL) return STD_ULOGIC; function \?>=\ (l : UNRESOLVED_float; r : REAL) return STD_ULOGIC; function \?<\ (l : UNRESOLVED_float; r : REAL) return STD_ULOGIC; function \?<=\ (l : UNRESOLVED_float; r : REAL) return STD_ULOGIC; function \?=\ (l : REAL; r : UNRESOLVED_float) return STD_ULOGIC; function \?/=\ (l : REAL; r : UNRESOLVED_float) return STD_ULOGIC; function \?>\ (l : REAL; r : UNRESOLVED_float) return STD_ULOGIC; function \?>=\ (l : REAL; r : UNRESOLVED_float) return STD_ULOGIC; function \?<\ (l : REAL; r : UNRESOLVED_float) return STD_ULOGIC; function \?<=\ (l : REAL; r : UNRESOLVED_float) return STD_ULOGIC; function \?=\ (l : UNRESOLVED_float; r : INTEGER) return STD_ULOGIC; function \?/=\ (l : UNRESOLVED_float; r : INTEGER) return STD_ULOGIC; function \?>\ (l : UNRESOLVED_float; r : INTEGER) return STD_ULOGIC; function \?>=\ (l : UNRESOLVED_float; r : INTEGER) return STD_ULOGIC; function \?<\ (l : UNRESOLVED_float; r : INTEGER) return STD_ULOGIC; function \?<=\ (l : UNRESOLVED_float; r : INTEGER) return STD_ULOGIC; function \?=\ (l : INTEGER; r : UNRESOLVED_float) return STD_ULOGIC; function \?/=\ (l : INTEGER; r : UNRESOLVED_float) return STD_ULOGIC; function \?>\ (l : INTEGER; r : UNRESOLVED_float) return STD_ULOGIC; function \?>=\ (l : INTEGER; r : UNRESOLVED_float) return STD_ULOGIC; function \?<\ (l : INTEGER; r : UNRESOLVED_float) return STD_ULOGIC; function \?<=\ (l : INTEGER; r : UNRESOLVED_float) return STD_ULOGIC; -- minimum and maximum overloads function maximum (l : UNRESOLVED_float; r : REAL) return UNRESOLVED_float; function minimum (l : UNRESOLVED_float; r : REAL) return UNRESOLVED_float; function maximum (l : REAL; r : UNRESOLVED_float) return UNRESOLVED_float; function minimum (l : REAL; r : UNRESOLVED_float) return UNRESOLVED_float; function maximum (l : UNRESOLVED_float; r : INTEGER) return UNRESOLVED_float; function minimum (l : UNRESOLVED_float; r : INTEGER) return UNRESOLVED_float; function maximum (l : INTEGER; r : UNRESOLVED_float) return UNRESOLVED_float; function minimum (l : INTEGER; r : UNRESOLVED_float) return UNRESOLVED_float;---------------------------------------------------------------------------- -- logical functions ---------------------------------------------------------------------------- function "not" (l : UNRESOLVED_float) return UNRESOLVED_float; function "and" (l, r : UNRESOLVED_float) return UNRESOLVED_float; function "or" (l, r : UNRESOLVED_float) return UNRESOLVED_float; function "nand" (l, r : UNRESOLVED_float) return UNRESOLVED_float; function "nor" (l, r : UNRESOLVED_float) return UNRESOLVED_float; function "xor" (l, r : UNRESOLVED_float) return UNRESOLVED_float; function "xnor" (l, r : UNRESOLVED_float) return UNRESOLVED_float; -- Vector and std_ulogic functions, same as functions in numeric_std function "and" (l : STD_ULOGIC; r : UNRESOLVED_float) return UNRESOLVED_float; function "and" (l : UNRESOLVED_float; r : STD_ULOGIC) return UNRESOLVED_float; function "or" (l : STD_ULOGIC; r : UNRESOLVED_float) return UNRESOLVED_float; function "or" (l : UNRESOLVED_float; r : STD_ULOGIC) return UNRESOLVED_float; function "nand" (l : STD_ULOGIC; r : UNRESOLVED_float) return UNRESOLVED_float; function "nand" (l : UNRESOLVED_float; r : STD_ULOGIC) return UNRESOLVED_float; function "nor" (l : STD_ULOGIC; r : UNRESOLVED_float) return UNRESOLVED_float; function "nor" (l : UNRESOLVED_float; r : STD_ULOGIC) return UNRESOLVED_float; function "xor" (l : STD_ULOGIC; r : UNRESOLVED_float) return UNRESOLVED_float; function "xor" (l : UNRESOLVED_float; r : STD_ULOGIC) return UNRESOLVED_float; 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 function and_reduce (l : UNRESOLVED_float) return STD_ULOGIC; function nand_reduce (l : UNRESOLVED_float) return STD_ULOGIC; function or_reduce (l : UNRESOLVED_float) return STD_ULOGIC; function nor_reduce (l : UNRESOLVED_float) return STD_ULOGIC; function xor_reduce (l : UNRESOLVED_float) return STD_ULOGIC; function xnor_reduce (l : UNRESOLVED_float) return STD_ULOGIC; -- Note: "sla", "sra", "sll", "slr", "rol" and "ror" not implemented. ----------------------------------------------------------------------------- -- Recommended Functions from the IEEE 754 Appendix ----------------------------------------------------------------------------- -- 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 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 : 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 function Logb (x : UNRESOLVED_float) return INTEGER; function Logb (x : UNRESOLVED_float) return SIGNED; -- returns the next representable neighbor of x in the direction toward y 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. function Unordered (x, y : UNRESOLVED_float) return BOOLEAN; function Finite (x : UNRESOLVED_float) return BOOLEAN; function Isnan (x : UNRESOLVED_float) return BOOLEAN; -- Function to return constants. function zerofp ( constant exponent_width : NATURAL := float_exponent_width; -- exponent constant fraction_width : NATURAL := float_fraction_width) -- fraction return UNRESOLVED_float; function nanfp ( constant exponent_width : NATURAL := float_exponent_width; -- exponent constant fraction_width : NATURAL := float_fraction_width) -- fraction return UNRESOLVED_float; function qnanfp ( constant exponent_width : NATURAL := float_exponent_width; -- exponent constant fraction_width : NATURAL := float_fraction_width) -- fraction return UNRESOLVED_float; function pos_inffp ( constant exponent_width : NATURAL := float_exponent_width; -- exponent constant fraction_width : NATURAL := float_fraction_width) -- fraction return UNRESOLVED_float; function neg_inffp ( constant exponent_width : NATURAL := float_exponent_width; -- exponent constant fraction_width : NATURAL := float_fraction_width) -- fraction return UNRESOLVED_float; 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 function zerofp ( size_res : UNRESOLVED_float) -- variable is only use for sizing return UNRESOLVED_float;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -