Is Floor function from math_real package synthesizable.
I have to do floor((index-1)*0.5), where index is a signal of integer type. I would like to know whether FLOOR function from math_real package is synthesizable, if not then i will have to think for an alternate solution. I use Quartus II version 11.1 synthesis tool. In addition to this i got a general question, does the functions in math_real package used only for simulation purpose or does it have any functions which can be synthesized ? Thank you.
Forget math_real for synthesizeable code. Also forget about multiplying with 0.5, divide by 2 instead.
If (index-1) can't be negative you can just write (index-1)/2.
If (index-1) can be negative, you should write a function to do it, with integer argument and return value.
I am doing multiplication with 0.5 to avoid division operator because division is a slow process and consumes lot of hardware. I need the integer part of the answer. So, all I wanted to know is, whether floor is a synthesizable vhdl statement. By the way the index is not negative.
most compilers and synthesis tools will convert division by a power of two into a right shift operator. VHDL has a definition for division where (-a)/b = -(a/b), so for signed types, it cannot infer a simple shift from a division by a power of two.
math.real has limited use in synthesizable code. It is mostly used to generate integer constants.
You can use math_real to to initialisation (like setting up initial values, constants, or generate statements) but cannot use used any anything that generates logic.
so floor((index-1)*0.5) is fine, as long as it defines a constant or initial value, but you cannot assign it to a signal or variable inside a process.