Forum Discussion
Altera_Forum
Honored Contributor
16 years agoC2H fixed point mpy
I had an array of fixed point numbers, log values actually. 10 bit integer 22 bit fraction. Needed the sum of squares to calculate standard deviation. In regular C this works okay ...
lo...
Altera_Forum
Honored Contributor
16 years agoC2H infers multipliers starting in 8.1 I believe. So it will be up to Quartus II synthesis to determine whether additional bits can be stripped away. To find out if the additional bits were removed you can look at the resource utilization and determine if a full 64x64 multiplier was used.
Sometimes you can force the bit stripping to happen using masks. For example if you knew you only need a 9x9 multiplier you could do this: long result; short a, b; result = ((long)(a & 0x1FF)) * ((long)(b & 0x1FF)); Even though the inputs are 16 bit cast up to 32 bit, the data all but the lower 9 bits masked away. Synthesis should detect this and create a 9x9 multiplier and pad the upper bits to 0 before assigning the 18 bit result into 'result'. This same trick should work if you mask the output of the multiplication as well.