diff --git a/libraries/base/common/src/vhdl/common_pkg.vhd b/libraries/base/common/src/vhdl/common_pkg.vhd index 2205e1b87da730ddfa3287e7cdaec16817e05810..d57813bc9a4de02174e449cce1cf367fc7049baa 100644 --- a/libraries/base/common/src/vhdl/common_pkg.vhd +++ b/libraries/base/common/src/vhdl/common_pkg.vhd @@ -387,6 +387,10 @@ PACKAGE common_pkg IS FUNCTION func_slv_extract( a_w, b_w, c_w : NATURAL; vec : STD_LOGIC_VECTOR; sel : NATURAL) RETURN STD_LOGIC_VECTOR; FUNCTION func_slv_extract( a_w, b_w : NATURAL; vec : STD_LOGIC_VECTOR; sel : NATURAL) RETURN STD_LOGIC_VECTOR; + -- Number formats, see: + -- . https://support.astron.nl/confluence/display/L2M/L3+SDP+Decision%3A+Definition+of+fixed+point+numbers + -- . https://support.astron.nl/confluence/display/L2M/L4+SDPFW+Decision%3A+Number+representation%2C+resizing+and+rounding + FUNCTION TO_UINT(vec : STD_LOGIC_VECTOR) RETURN NATURAL; -- beware: NATURAL'HIGH = 2**31-1, not 2*32-1, use TO_SINT to avoid warning FUNCTION TO_SINT(vec : STD_LOGIC_VECTOR) RETURN INTEGER; @@ -2073,6 +2077,9 @@ PACKAGE BODY common_pkg IS RETURN sel_a_b(c_pos, c_real, -c_real); END; + -- Fixed point format + -- . https://support.astron.nl/confluence/display/L2M/L3+SDP+Decision%3A+Definition+of+fixed+point+numbers + FUNCTION TO_UREAL(uvec : STD_LOGIC_VECTOR; resolution_w : INTEGER) RETURN REAL IS BEGIN -- First convert as unsigned integer, then scale to real. See TO_SREAL() @@ -2505,7 +2512,8 @@ PACKAGE BODY common_pkg IS END; ------------------------------------------------------------------------------------------------- - -- Rounding schemes: + -- Rounding schemes + -- . https://support.astron.nl/confluence/display/L2M/L4+SDPFW+Decision%3A+Number+representation%2C+resizing+and+rounding ------------------------------------------------------------------------------------------------- -- -- From https://en.wikipedia.org/wiki/Rounding it follows that there are three main