Forum Discussion
Altera_Forum
Honored Contributor
15 years agoNumber Scaling
Hi, What is the most efficient way to scale numbers into the range of -1, 1 in Verilog using Cyclone II? That is the fastest code with least resources? are there any free IP cores from Altera o...
Altera_Forum
Honored Contributor
15 years agoApologies to Dave
if I understood the original post, you want 0~579 represented as -1 ~ +1 onto 16 bits signed. Here is my magic formula: y = x*113 - 32767 ... thats all Explanation: y = x * (2^16-1)/579 - 32767.5 = x*113 - 32767 accuracy is affected by value 113 and losing .5 of 32767.5 but can be improved by multiplying by larger than 113 then shift dividing.