cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
11,190 Views
Registered: ‎01-28-2011

Floating Point with Fixed Point FPGA


Good day.

I want to implement trigonometry functions on a Fixed Point FPGA.

Can you please assist me with some tips as to how to go about this.

I figured a lookup table may work.

Does anybody have any tips or examples?
Thank you in advance

Kind regards
0 Kudos
Reply
14 Replies
Mentor
Mentor
11,188 Views
Registered: ‎11-29-2007

There's no such thing as a "fixed point FPGA". Is your intention to a implement trig. functions using a set of fixed point IP cores? Please provide more details.

 

 

Adrian



Please google your question before asking it.
If someone answers your question, mark the post with "Accept as solution". If you see a particularly good and informative post, consider giving it Kudos (the star on the left).
Instructor
Instructor
11,185 Views
Registered: ‎07-21-2009

Your request is a bit broad for an FPGA user technical support forum, don't you think?

 

OK, let's play this out.  Suggestions:

 

1. Read a book on computer arithmetic, specifically gate-level floating point arithmetic design.  There are lots of books on computer arithmetic.

 

2.  Read a book on trigonometric (sometimes called transcendental) functions.

 

3.  Learn how to incorporate a PPC or MicroBlaze processor in your FPGA design, and write (or adapt) math C language routines for processor execution.

 

Are you new to FPGA design?  If this is your first FPGA design, you are well advised to learn FPGAs and the design tools (and digital logic design) before you take on a project as challenging as high-level math implementation.  FPGA design is not a software project, it's a hardware design project.  If you don't understand the hardware, you run the risk of disappointment and discouragement.

 

If you walked into your very first machine shop class, it would be premature to ask your fellow students - on your first day - how cars are built from steel ingots.  This is the sort of question you have posed.

 

- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
11,182 Views
Registered: ‎01-28-2011

As to my understanding some FPGAs support Floating point and some not.

 

If you therefore want to use floating point values in a design.

Say for example hypothetically:

 

cos_data <= cos_function(x);

 

How can I design this in VHDL when I only have Fixed value support?

 

 

0 Kudos
Reply
11,180 Views
Registered: ‎01-28-2011

I am not a newbie to FPGAs or VHDL.

 

I did my Masters Degree in Engineering using the Virtex5.

 

I know the tools, code etc.

0 Kudos
Reply
Instructor
Instructor
11,177 Views
Registered: ‎07-21-2009

As to my understanding some FPGAs support Floating point and some not.

Sadly, this is not the case.  FPGAs provide low-level logic functions and a few types of arithmetic building blocks, which designers assemble into higher-level functions and systems.

cos_data <= cos_function(x);

This is not a native FPGA function.  It can be realised only by a library or macro or module which has already been written or designed.  In most cases such as this, there are multiple levels of libraries or modules between a trig function and an FPGA's fundamental capabilities.

 

When you buy a floating point capable processor from Intel or Freescale or AMD, its FP math capabilities have been carefully design and crafted.  The math functions did not magically appear with the press of a mouse-click.

 

- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Reply
Instructor
Instructor
11,176 Views
Registered: ‎07-21-2009

I am not a newbie to FPGAs or VHDL.

I did my Masters Degree in Engineering using the Virtex5.

I know the tools, code etc.

From where did you get the impression that "floating point math" is a synthesisable class of VHDL (or Verilog) constructs or expressions?

 

Floating point math functions CAN be synthesised...  but you must spell out to the synthesis tool how to perform the synthesis.  In other words, you create the math functions library.

 

If you want to learn floating point data path design from the gate level, you have a non-trivial project ahead of you.  If you are less interested in the design process, and more interested in using such math functions, then the previous suggestion for instantiating a processor (and providing the math functions as executed SW routines) is by far a quicker and more reliable approach than gate level hardware design.

 

- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Reply
11,151 Views
Registered: ‎01-28-2011

I know very well that Floating point math is not synthesisable with an FPGA. (Thats why I posted this thread)

 

I also know that the function is not impossible to implement. There are ways around the logic cells of the FPGA.

 

End.

 

 

If anyone has any experience with or examples of this, please assist.

I will update this thread when I find the solution

 

Thanx in advance

0 Kudos
Reply
Mentor
Mentor
11,141 Views
Registered: ‎11-29-2007

 


I also know that the function is not impossible to implement.


 

Yes, floating-point arithmetic is implementable on FPGAs. But probably not in such a way that you can just call a function and your cosine core is instantiated. Well, most likely not, because it can only be in a function if it is combinational (as opposed to sequential). Good luck implementing cos() in a combinational circuit.

 

 


There are ways around the logic cells of the FPGA.

I don't understand the meaning of this. Please explain.

 

 

Before we get sidetracked by a possibly unnecessary problem: have you had a look at the cores provided by the IP core generator? Maybe you'll find what you need.

 

 

Adrian



Please google your question before asking it.
If someone answers your question, mark the post with "Accept as solution". If you see a particularly good and informative post, consider giving it Kudos (the star on the left).
11,139 Views
Registered: ‎01-28-2011

You can bypass floating point values by up scaling or down scaling values, and adjusting the values in higher level programming.

 

I had good results with this when we had to do real-time position sensor measurements in the value range of approx.    300 microns.

 

We all know cos(x) = (e*exp(ix) + e*exp(-ix))/2

 

We can easily calculate the reel and imaginary components of a cosinus function.

 

From what I have read is that these two methods can be combined in a lookup table to implement a cosinus function.

 

I do not however have experience with this second method.

 

Any ideas?

0 Kudos
Reply
Mentor
Mentor
6,255 Views
Registered: ‎11-29-2007

 


You can bypass floating point values by up scaling or down scaling values, and adjusting the values in higher level programming.

 

This sounds like you're describing fixed-point numbers?

 


We all know cos(x) = (e*exp(ix) + e*exp(-ix))/2

And how do you plan to implement the exp() function for complex arguments in a combinational circuit?

 

 


From what I have read is that these two methods can be combined in a lookup table to implement a cosinus function.

 

Of course, if you don't need a high input precision, then you can simply implement your cosine function in a large lookup-table. For example, you can get 18 bits of output precision at 11 bits of input precision with a single RAMB36. Is that what you wanted?

 

 

Adrian



Please google your question before asking it.
If someone answers your question, mark the post with "Accept as solution". If you see a particularly good and informative post, consider giving it Kudos (the star on the left).
0 Kudos
Reply
Instructor
Instructor
6,254 Views
Registered: ‎07-21-2009

Until you have developed a set of algorithms, verified them, and sized the data precision requirements; it's premature to be discussing FPGA implementations.

 

The biggest risk in conceptual design and simulation is that you might come up with a brilliant set of ideas which are completely unworkable.  However, you already have enough background in FPGA technology to steer your algorithm design ideas away from approaches which are clearly impractical.

 

For example, you already understand that a straightforward sin(x) lookup table might be impractical if x is a floating point number which exceeds the addressing range of on-chip memory.

 

Being aware of such FPGA limitations without being unduly restrained by them seems like the right time and place for creative - yet useful - design.

 

- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Reply
6,215 Views
Registered: ‎01-28-2011

Now that everybody have stated  ALL the problems and no solutions...

 

For anybody looking for a solution i suggest you look at the following:

 

1. CORDIC

 

2. Power  series

 

3. Look up tables

 

Each have different processing time and you should look into this for a time-critical calculation.

 

I will post my implementation as soon as its finished

Tags (1)
0 Kudos
Reply
Instructor
Instructor
6,211 Views
Registered: ‎07-21-2009

Now that everybody have stated  ALL the problems and no solutions...

For anybody looking for a solution i suggest you look at the following:

1. CORDIC

2. Power  series

3. Look up tables

Each have different processing time and you should look into this for a time-critical calculation.

I will post my implementation as soon as its finished

 

We knew you could figure it out!  We just didn't want to spoil the moment for you.


- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Reply
Mentor
Mentor
6,208 Views
Registered: ‎11-29-2007

 


Now that everybody have stated  ALL the problems and no solutions...

 

Well, maybe that's because your problem description was vague ("I want to implement trigonometry functions") and confusing ("on a Fixed Point FPGA").

Besides, one can't find a solution without knowing the problem. You're welcome.

 

 

Adrian



Please google your question before asking it.
If someone answers your question, mark the post with "Accept as solution". If you see a particularly good and informative post, consider giving it Kudos (the star on the left).
0 Kudos
Reply