Forum Discussion
Altera_Forum
Honored Contributor
15 years agoMultiplication by 0,6
Hi i have an input of 8 bits and i need to make a multiplication by 0,6. I doesn't has to be precise so i thaught to do : INPUT * 19 /32 This is not a working code but is displays wh...
Altera_Forum
Honored Contributor
15 years ago --- Quote Start --- Yea thaught so. I would be nicer to write a code in one line. Thx anyway! --- Quote End ---
Library IEEE;
use IEEE.Std_Logic_1164.all;
use IEEE.numeric_std.all;
. . .
dn <= to_integer( unsigned( CAM_DATA )) ;
Q <= std_logic_vector( to_unsigned( dn * 16 + dn * 2 +dn , 13))(12 downto 5) ;
-- or in 1 line
Q <= std_logic_vector( to_unsigned( to_integer( unsigned( CAM_DATA )) * 16 + to_integer( unsigned( CAM_DATA )) * 2 + to_integer( unsigned( CAM_DATA )) , 13))(12 downto 5) ;