I'm currently doing some tutorials and reading some books on how to write VHDL. As I'm curious and learn better with hands-on tutorials I'm going to start implementing my projects that will serve me well in the future.
For my first real project I'm trying to implement an arctg
function followed by an aggregation operator function.
I don't want to reinvent the wheel and I don't want to be further confused and so I'm asking here the following questions:
- The integer to float and vice-versa with the bits of the mantissa, exponent and integer is necessary right? Isn't there any website where people have already implemented this kind of things and share with the community?
I've seen somewhere that the package
math_real
already has anARCTAN
function which accepts aREAL
which I guess is a float. So:2.1. Is this synthesizable? If not why is it even coded?
2.2. If everything needs to be converted from float to integer in order to be passed between functions, why does
ARCTAN
acceptREAL
and not an integer?
-
\$\begingroup\$ Real math / types are not synthesizable. Unless you have some vendor-specific smart synthesis tool which is made capable of it. It was coded like many non-synthesizable stuff - for simulation and testing. \$\endgroup\$Eugene Sh.– Eugene Sh.2015年11月10日 16:40:06 +00:00Commented Nov 10, 2015 at 16:40
-
2\$\begingroup\$ Yes and no. The no part - it's also for simulating the parts of the system which are not yet implemented, but supposed to do some real math. \$\endgroup\$Eugene Sh.– Eugene Sh.2015年11月10日 16:45:42 +00:00Commented Nov 10, 2015 at 16:45
-
1\$\begingroup\$ "opencores" has a library you may find useful. \$\endgroup\$pjc50– pjc502015年11月10日 16:46:16 +00:00Commented Nov 10, 2015 at 16:46
-
1\$\begingroup\$ Perhaps a fixed point math would be sufficient for your needs. \$\endgroup\$Eugene Sh.– Eugene Sh.2015年11月10日 16:49:46 +00:00Commented Nov 10, 2015 at 16:49
-
1\$\begingroup\$ If you're starting to do something new, and think 'I need to provide all this infrastructure from scratch', then probably you're not using the right tool for the job, or have chosen the wrong first project for the tool. I call it the 'are you riding the horse in the direction it's going?' question, it's much easier to ride it that way than sideways or backwards. FPGAs excel at digital logic, comparisons, storage, and integer maths. DPS ICs tend to be used for maths with reals. For ARCTAN function, look up CORDIC (wikipedia), that's the natural FPGA implementation, and works with integers. \$\endgroup\$Neil_UK– Neil_UK2015年11月10日 16:54:06 +00:00Commented Nov 10, 2015 at 16:54
1 Answer 1
VHDL-2008 has synthesisable fixed-point and floating-point libraries, in addition to ieee.math_real
which is strictly for simulation. You can instantiate the float package with any width of mantissa and exponent, or use the pre-defined float types (roughly IEEE P754). The fixed point package is a better choice for DSP, and usually produces smaller hardware.
These libraries should handle question (1) for you.
For question 2)
- The
math_real
ARCTAN is used in simulation, not for synthesis. - Question makes no sense as you can pass reals to and from functions.