Forum Discussion
Altera_Forum
Honored Contributor
15 years agoFixed point math functions
Hello, I know that fixed point logic circuits are similar to integers. But my question is. Say I convert a 15bit integer (A) to fixed point <15bits.10bits> by just using {A[14:0],10'b...
Altera_Forum
Honored Contributor
15 years agoI think that all questions can be answered best by applying somenumerical examples, using pencil and paper or a pocket calculator.
You'll notice, that you have to discard bits on the left for all multiply operations, even for fractional signed numbers (no integer bits). To avoid overflow, saturation logic has to be apllied, set the result MININT or MAXINT respectively. Saturation is also needed, if you want to handle overflows in add und sub, and for resize to fewer bits, as in your last example. As previously suggested, the IEEE fixed point library can be used for the operations. But it's also easy to make a few VHDL functions that wrap your own code for it.