📄 fixed_pkg_c.vhdl
字号:
constant right_index : INTEGER; -- size of fraction constant overflow_style : fixed_overflow_style_type := fixed_overflow_style; constant round_style : fixed_round_style_type := fixed_round_style; constant guard_bits : NATURAL := fixed_guard_bits) return UNRESOLVED_sfixed; function to_sfixed ( arg : REAL; -- real size_res : UNRESOLVED_sfixed; -- for size only constant overflow_style : fixed_overflow_style_type := fixed_overflow_style; constant round_style : fixed_round_style_type := fixed_round_style; constant guard_bits : NATURAL := fixed_guard_bits) return UNRESOLVED_sfixed; -- signed to sfixed function to_sfixed ( arg : SIGNED; -- signed constant left_index : INTEGER; -- size of integer portion constant right_index : INTEGER := 0; -- size of fraction constant overflow_style : fixed_overflow_style_type := fixed_overflow_style; constant round_style : fixed_round_style_type := fixed_round_style) return UNRESOLVED_sfixed; function to_sfixed ( arg : SIGNED; -- signed size_res : UNRESOLVED_sfixed; -- for size only constant overflow_style : fixed_overflow_style_type := fixed_overflow_style; constant round_style : fixed_round_style_type := fixed_round_style) return UNRESOLVED_sfixed; -- signed to sfixed (output assumed to be size of signed input) function to_sfixed ( arg : SIGNED) -- signed return UNRESOLVED_sfixed; -- Conversion from ufixed to sfixed function to_sfixed ( arg : UNRESOLVED_ufixed) return UNRESOLVED_sfixed; -- signed fixed point to signed function to_signed ( arg : UNRESOLVED_sfixed; -- fixed point input constant size : NATURAL; -- length of output constant overflow_style : fixed_overflow_style_type := fixed_overflow_style; constant round_style : fixed_round_style_type := fixed_round_style) return SIGNED; -- signed fixed point to signed function to_signed ( arg : UNRESOLVED_sfixed; -- fixed point input size_res : SIGNED; -- used for length of output constant overflow_style : fixed_overflow_style_type := fixed_overflow_style; constant round_style : fixed_round_style_type := fixed_round_style) return SIGNED; -- signed fixed point to real function to_real ( arg : UNRESOLVED_sfixed) -- fixed point input return REAL; -- signed fixed point to integer function to_integer ( arg : UNRESOLVED_sfixed; -- fixed point input constant overflow_style : fixed_overflow_style_type := fixed_overflow_style; constant round_style : fixed_round_style_type := fixed_round_style) return INTEGER; -- Because of the fairly complicated sizing rules in the fixed point -- packages these functions are provided to compute the result ranges -- Example: -- signal uf1 : ufixed (3 downto -3); -- signal uf2 : ufixed (4 downto -2); -- signal uf1multuf2 : ufixed (ufixed_high (3, -3, '*', 4, -2) downto -- ufixed_low (3, -3, '*', 4, -2)); -- uf1multuf2 <= uf1 * uf2; -- Valid characters: '+', '-', '*', '/', 'r' or 'R' (rem), 'm' or 'M' (mod), -- '1' (reciprocal), 'a' or 'A' (abs), 'n' or 'N' (unary -) function ufixed_high (left_index, right_index : INTEGER; operation : CHARACTER := 'X'; left_index2, right_index2 : INTEGER := 0) return INTEGER; function ufixed_low (left_index, right_index : INTEGER; operation : CHARACTER := 'X'; left_index2, right_index2 : INTEGER := 0) return INTEGER; function sfixed_high (left_index, right_index : INTEGER; operation : CHARACTER := 'X'; left_index2, right_index2 : INTEGER := 0) return INTEGER; function sfixed_low (left_index, right_index : INTEGER; operation : CHARACTER := 'X'; left_index2, right_index2 : INTEGER := 0) return INTEGER; -- Same as above, but using the "size_res" input only for their ranges: -- signal uf1multuf2 : ufixed (ufixed_high (uf1, '*', uf2) downto -- ufixed_low (uf1, '*', uf2)); -- uf1multuf2 <= uf1 * uf2; -- function ufixed_high (size_res : UNRESOLVED_ufixed; operation : CHARACTER := 'X'; size_res2 : UNRESOLVED_ufixed) return INTEGER; function ufixed_low (size_res : UNRESOLVED_ufixed; operation : CHARACTER := 'X'; size_res2 : UNRESOLVED_ufixed) return INTEGER; function sfixed_high (size_res : UNRESOLVED_sfixed; operation : CHARACTER := 'X'; size_res2 : UNRESOLVED_sfixed) return INTEGER; function sfixed_low (size_res : UNRESOLVED_sfixed; operation : CHARACTER := 'X'; size_res2 : UNRESOLVED_sfixed) return INTEGER; -- purpose: returns a saturated number function saturate ( constant left_index : INTEGER; constant right_index : INTEGER) return UNRESOLVED_ufixed; -- purpose: returns a saturated number function saturate ( constant left_index : INTEGER; constant right_index : INTEGER) return UNRESOLVED_sfixed; function saturate ( size_res : UNRESOLVED_ufixed) -- only the size of this is used return UNRESOLVED_ufixed; function saturate ( size_res : UNRESOLVED_sfixed) -- only the size of this is used return UNRESOLVED_sfixed; --=========================================================================== -- Translation Functions --=========================================================================== -- maps meta-logical values function to_01 ( s : UNRESOLVED_ufixed; -- fixed point input constant XMAP : STD_ULOGIC := '0') -- Map x to return UNRESOLVED_ufixed; -- maps meta-logical values function to_01 ( s : UNRESOLVED_sfixed; -- fixed point input constant XMAP : STD_ULOGIC := '0') -- Map x to return UNRESOLVED_sfixed; function Is_X (arg : UNRESOLVED_ufixed) return BOOLEAN; function Is_X (arg : UNRESOLVED_sfixed) return BOOLEAN; function to_X01 (arg : UNRESOLVED_ufixed) return UNRESOLVED_ufixed; function to_X01 (arg : UNRESOLVED_sfixed) return UNRESOLVED_sfixed; function to_X01Z (arg : UNRESOLVED_ufixed) return UNRESOLVED_ufixed; function to_X01Z (arg : UNRESOLVED_sfixed) return UNRESOLVED_sfixed; function to_UX01 (arg : UNRESOLVED_ufixed) return UNRESOLVED_ufixed; function to_UX01 (arg : UNRESOLVED_sfixed) return UNRESOLVED_sfixed; -- straight vector conversion routines, needed for synthesis. -- These functions are here so that a std_logic_vector can be -- converted to and from sfixed and ufixed. Note that you can -- not convert these vectors because of their negative index. function to_slv ( arg : UNRESOLVED_ufixed) -- fixed point vector return STD_LOGIC_VECTOR;-- alias to_StdLogicVector is to_slv [UNRESOLVED_ufixed-- return STD_LOGIC_VECTOR];-- alias to_Std_Logic_Vector is to_slv [UNRESOLVED_ufixed-- return STD_LOGIC_VECTOR]; function to_slv ( arg : UNRESOLVED_sfixed) -- fixed point vector return STD_LOGIC_VECTOR;-- alias to_StdLogicVector is to_slv [UNRESOLVED_sfixed-- return STD_LOGIC_VECTOR];-- alias to_Std_Logic_Vector is to_slv [UNRESOLVED_sfixed-- return STD_LOGIC_VECTOR]; function to_suv ( arg : UNRESOLVED_ufixed) -- fixed point vector return STD_ULOGIC_VECTOR;-- alias to_StdULogicVector is to_suv [UNRESOLVED_ufixed-- return STD_ULOGIC_VECTOR];-- alias to_Std_ULogic_Vector is to_suv [UNRESOLVED_ufixed-- return STD_ULOGIC_VECTOR]; function to_suv ( arg : UNRESOLVED_sfixed) -- fixed point vector return STD_ULOGIC_VECTOR;-- alias to_StdULogicVector is to_suv [UNRESOLVED_sfixed-- return STD_ULOGIC_VECTOR];-- alias to_Std_ULogic_Vector is to_suv [UNRESOLVED_sfixed-- return STD_ULOGIC_VECTOR]; function to_ufixed ( arg : STD_ULOGIC_VECTOR; -- shifted vector constant left_index : INTEGER; constant right_index : INTEGER) return UNRESOLVED_ufixed; function to_ufixed ( arg : STD_ULOGIC_VECTOR; -- shifted vector size_res : UNRESOLVED_ufixed) -- for size only return UNRESOLVED_ufixed; function to_sfixed ( arg : STD_ULOGIC_VECTOR; -- shifted vector constant left_index : INTEGER; constant right_index : INTEGER) return UNRESOLVED_sfixed; function to_sfixed ( arg : STD_ULOGIC_VECTOR; -- shifted vector size_res : UNRESOLVED_sfixed) -- for size only return UNRESOLVED_sfixed; -- As a concession to those who use a graphical DSP environment, -- these functions take parameters in those tools format and create -- fixed point numbers. These functions are designed to convert from -- a std_logic_vector to the VHDL fixed point format using the conventions -- of these packages. In a pure VHDL environment you should use the -- "to_ufixed" and "to_sfixed" routines. -- unsigned fixed point function to_UFix ( arg : STD_ULOGIC_VECTOR; width : NATURAL; -- width of vector fraction : NATURAL) -- width of fraction return UNRESOLVED_ufixed; -- signed fixed point function to_SFix ( arg : STD_ULOGIC_VECTOR; width : NATURAL; -- width of vector fraction : NATURAL) -- width of fraction return UNRESOLVED_sfixed; -- finding the bounds of a number. These functions can be used like this: -- signal xxx : ufixed (7 downto -3); -- -- Which is the same as "ufixed (UFix_high (11,3) downto UFix_low(11,3))" -- signal yyy : ufixed (UFix_high (11, 3, "+", 11, 3) -- downto UFix_low(11, 3, "+", 11, 3)); -- Where "11" is the width of xxx (xxx'length), -- and 3 is the lower bound (abs (xxx'low)) -- In a pure VHDL environment use "ufixed_high" and "ufixed_low" function UFix_high (width, fraction : NATURAL; operation : CHARACTER := 'X'; width2, fraction2 : NATURAL := 0) return INTEGER; function UFix_low (width, fraction : NATURAL; operation : CHARACTER := 'X'; width2, fraction2 : NATURAL := 0) return INTEGER; -- Same as above but for signed fixed point. Note that the width -- of a signed fixed point number ignores the sign bit, thus -- width = sxxx'length-1 function SFix_high (width, fraction : NATURAL; operation : CHARACTER := 'X'; width2, fraction2 : NATURAL := 0) return INTEGER; function SFix_low (width, fraction : NATURAL; operation : CHARACTER := 'X'; width2, fraction2 : NATURAL := 0) return INTEGER;-- rtl_synthesis off-- pragma synthesis_off --===========================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -