Can an ARRAY variable be both read and write?

I finally solved the problem and completed the SAXPY IP project.

Thank you again @cathalmccabe for pointing out that a could be a very small value (almost bordering 0) and that is what happen. The equation of saxpy is y = ax +y.

With a almost zero, the equation becomes y[i] ~= y[i]. That is why I thought that array y has the same value.

The culprit? a = int(scalar_a). For example: if scalar_a = 4.0, then a = 4. But, when it is passed to the HLS (which is defined as float a), it is receiving a value of 0x00000004 which in float ( IEEE-754) is an underflow (number so small it is approaching 0).

So, the solution is to translate the floating to its IEEE-754 representation. Again, @cathalmccabe has pointed the routine from stack overflow and modified by @bartokon to make it integer (instead of hex).

The function looks like this:

import struct
def float_to_int(f):
return int(struct.unpack(‘<I’, struct.pack(‘<f’, f))[0])

So, a = float_to_int(scalar_a)

The rest of the code listed above remains the same.

So, I guess that solves the mystery of the “array variable can be both read and write”.

As a takeaway, simply converting float to integer using the int() function won’t work!

1 Like