Forum Discussion
Altera_Forum
Honored Contributor
15 years agomultiplication in fixed_pkg
sir/mam i am using fixed_pkg_c.vhdl for multiply 0.46 with a wc which is std_logic_vector of 14 bits.i represent 0.46 using sfixed command,but can't understand how to convert std_logic_vector t...
Altera_Forum
Honored Contributor
15 years agoto convert std_logic_Vector there is a function called
function to_sfixed (
arg : STD_ULOGIC_VECTOR; -- shifted vector
constant left_index : INTEGER;
constant right_index : INTEGER)
return UNRESOLVED_sfixed;
or there is this version:
function to_sfixed (
arg : STD_ULOGIC_VECTOR; -- shifted vector size_res : UNRESOLVED_sfixed) -- for size only return UNRESOLVED_sfixed;
where you can use another signal for sizing information so for example, to convert a 14 bit slv to an sfixed with 6 integer bits and 8 fractional, use the function like this: output <= to_sfixed(my_slv, 5, -8); or you can do this: output <= to_sfixed(my_slv, output);