FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
6343 Discussions

what is the data type of floating??

Altera_Forum
Honored Contributor II
1,581 Views

In my program i want to calculate some floating datas , but i dont know much about the data type about Altera. whether I can define them just like I did in VC. i want some material about such field.  

thanks a lot :) 

 

 

 

sunjie
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
843 Views

You can go into the megawizard and select the altfp_add_sub, altfp_div, or altfp_mult megafunction to do your floating point. I believe they let you select the floating point format. For example, if your c/c++ was using float, choose single precision. If your c/c++ was using double, choose double precision. 

 

Be careful with floating point. It produces MUCH larger and MUCH slower circuits than a fixed point. Most people go out of their way to avoid it. 

 

Good luck with your project.
0 Kudos
Altera_Forum
Honored Contributor II
843 Views

 

--- Quote Start ---  

In my program i want to calculate some floating datas , but i dont know much about the data type about Altera. whether I can define them just like I did in VC. i want some material about such field.  

thanks a lot :) 

--- Quote End ---  

 

 

Wanting floating point "in your program" sounds as you you want it in C code running on the Nios processor. That should work just fine. The Nios compiler handles single and double precision FP. There's no floating point hardware, though, so it's all handled in library functions - if speed is an issue, you might need to check that it runs as fast as you want.
0 Kudos
Altera_Forum
Honored Contributor II
843 Views

The Nios II compiler will provide you with IEEE754 floating point math for single and double precision. This means that round to nearest (floating point math isn't exact so this is the closest you can get) will be implemented and denormal support is not available (that's when a number becomes so small it might as well be zero). The floating point megawizard functions provide similar math support.

0 Kudos
Reply