Forum Discussion
Real Type
Hey everyone!
I have a problem and I hope everyone can help me: now I don't known that operation of real type in vhdl. for example: if I calculation 3.5/4.5 then result=?. one more problem is function sin, cos, tan in vhdl. thanks!10 Replies
- Altera_Forum
Honored Contributor
you cannot use real types in designs. They are for simulation only.
- Altera_Forum
Honored Contributor
I have implemented in this forums. But I cannot use floating point (real) . It error only.
Please help. - Altera_Forum
Honored Contributor
If you are trying to use Floating point numbers (real) inside an FPGA, there is probably something wrong with the origional spec. Floating point math is horrible and eats up alot of logic.
Try and re-spec the design to used fixed point math instead. It fits right in with what FPGAs do. and then also look at using this package from the IEEE: http://www.vhdl.org/fphdl/vhdl.html Its fully synthesisable in quartus, but dont try and use the floating point parts of it, unless you want to clock the design extremly slowly (or use the altera FP units instead. In addition, its normally best to implement sin/cos functions using a ROM as it is alot more practical. And remember, keep it fixed point. - Altera_Forum
Honored Contributor
Thanks everyone!
- Altera_Forum
Honored Contributor
Yes, also Altera has floating point MegaFunctions. But they don't use VHDL real type rather than IEEE or custom specific floating point types.
- Altera_Forum
Honored Contributor
- Altera_Forum
Honored Contributor
Example of what the link above talks about. - Altera_Forum
Honored Contributor
I guess that shows how much I have used those functions. I thought about checking that before i posted, but now i just feel retarded. That being said, Altera provides floating point math units as megacores. Or opencores.org may have something useful. Trig functions, depending on precision a LUT may be helpful, or if you google "implement sine hardware" you may come up with some results. Besides that I don't have a clue really. Sorry for not being too useful.
ece.gmu.edu/courses/ECE645/projects_S06/talks/CORDIC.pdf an interesting result. - Altera_Forum
Honored Contributor
You should consider, that real and respective math functions are only available for simulation and compile time calculations, e.g. generation of ROM tables. But they aren't synthesizable.
- Altera_Forum
Honored Contributor
library ieee;
use ieee.std_logic_1164.math_real.all; http://www.csee.umbc.edu/help/vhdl/stdpkg.html This should help.