Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Real Type

Altera_Forum
Honored Contributor II
1,733 Views

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!
0 Kudos
10 Replies
Altera_Forum
Honored Contributor II
1,012 Views

library ieee; 

use ieee.std_logic_1164.math_real.all; 

 

http://www.csee.umbc.edu/help/vhdl/stdpkg.html 

 

This should help.
0 Kudos
Altera_Forum
Honored Contributor II
1,012 Views

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.

0 Kudos
Altera_Forum
Honored Contributor II
1,012 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
1,012 Views

http://opencores.org/?do=project&who=cordic 

 

Example of what the link above talks about.
0 Kudos
Altera_Forum
Honored Contributor II
1,012 Views
0 Kudos
Altera_Forum
Honored Contributor II
1,012 Views

Yes, also Altera has floating point MegaFunctions. But they don't use VHDL real type rather than IEEE or custom specific floating point types.

0 Kudos
Altera_Forum
Honored Contributor II
1,012 Views

Thanks everyone!

0 Kudos
Altera_Forum
Honored Contributor II
1,012 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
1,012 Views

I have implemented in this forums. But I cannot use floating point (real) . It error only. 

Please help.
0 Kudos
Altera_Forum
Honored Contributor II
1,012 Views

you cannot use real types in designs. They are for simulation only.

0 Kudos
Reply