2
\$\begingroup\$

Regarding something I read in a Xilinx manual saying this:

Because floating-point operations use considerable resources relative to integer/fixed point operations, the Vivado HLS tool utilizes those resources as efficiently as possible.

I was thinking about the following option:

If that is true about floating-point cores utilizing more resources, why can't we convert every float we have to u32 with a union like this:

union converter{
     float f32;
     unsigned int u32;
}

do the operations always with the u32 and then in the end convert everything back to float?

I saw some examples of people doing this in really small designs, but never in big ones with lots of float operations.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ What sort of operations would you perform on such a union? \$\endgroup\$ – Nick Johnson Jun 12 '15 at 14:38
7
\$\begingroup\$

Just because they use the same number of bits, doesn't mean that you can perform operations on them in the same way.

Look at how a float is actually constructed internally - how the bits are used (sign, exponent, fraction) and then think about what would happen if you simply did integer operations on it.

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ Yeap, I was confusing operations with conversions only. Sorry guys and ty \$\endgroup\$ – João Pereira Jun 12 '15 at 14:51
  • 2
    \$\begingroup\$ Of course, if you do manage to design a working floating-point algorithm based on simple integer operations, the results can be mind-blowing. \$\endgroup\$ – Jeff Bowman Jun 12 '15 at 18:27
5
\$\begingroup\$

You can, but if you do, you cannot perform any floating point operations, so it wouldn't help you in calculations. Floating point calculations are time consuming. Load/Store operations aren't.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.