Forum Discussion
Me and my simple questions: Can I do this in FPGA?
Hi dear Altera friends. Sorry for the simple questions, i'm a beginner. My FPGA is DE1-SoC University, i'm learning how to use it.
My question today is the following one: Until now, with the help of the student material of Altera, I have learn how to implement simple circuits, ALU and registers. Now, Is it possible to implement in hardware complicated equations? Like 1 divided by a a big number, or square roots, I mean, to work with real numbers like 0.0031416 and so on? I know how to do this either in C and Assembler, but I don't know if this is possible to do in FPGA and VHDL. A senior friend told me, this is not possible to do in VHDL, he said I have to make of use ARM chip in my FPGA and program it fon C, since FPGA and VHDL alone is not able to perform such of calculations. What can you say about this? Example: http://www.alteraforum.com/forum/attachment.php?attachmentid=11555&stc=137 Replies
- Altera_Forum
Honored Contributor
It has a single input and a single output.
But if the data rate is half the clock rate, you can mux the input between two sources. - Altera_Forum
Honored Contributor
Thanks so much guys, I'll carefully study all your answers. My professor says I don't need to use Floating point unit for this, he says by designing a simple Adder-Multiplier-Accumulator would be enough (maybe is what Galfonz is mentioning). I will implement this on my FPGA but what i'm intending is to simulate a Chip which can perform this equation.
I have another question, this Floating Operation Module on the FPGA, Can it serves to several PE at the same time? Or it's a single module that will serve one PE one at a time? I ask this because I may need to do this equation in several PE at the same moment in paralell. - Altera_Forum
Honored Contributor
Oh. If Galfonz recommend using dsp I suggest you find docs about transformation based on fft for arithmetic operation with big integers
It is not on surface. Even googling web cannot provide fast answer - Altera_Forum
Honored Contributor
When the proper units are chosen, very few caculations in the physical world cannot be done with 64 bit (or higher) integers. DSPs were for a long time strictly integer many techniques developed then are apply to FPGAs. Look into these techniques and take another look at how your problem might be solved with them.
I don't recommend using the floating point FPGA blocks that are available. They waste FPGA resources and aren't needed with some careful analysis of the problem. The same goes for floating point in OpenCL and Vivado HLS. - Altera_Forum
Honored Contributor
y**x = 2**(x*log2 y) if y > 0.
avoid division and use rational approach 1/x = x**(-1) = 2**(-log2 x) , x>0. You can rewrite your equation fully in 2**x and log2 x function. if you need to compute sum the problem of accuracy still exists. you have to remember if you will add unsorted floating-point. Does it take place in FPGA? - Altera_Forum
Honored Contributor
Tricky right. You can
But your equation can be more optimized to parallel computation) and should be rewritten as you compute power. it depends how data stream come You have to use floating point cause you need exponent and logarithm or you can build your own for integer data type or fixedpoint - Altera_Forum
Honored Contributor
Your friend doesnt know much. Altera provides floating point cores to do floating point arithmatic. https://www.altera.com/content/dam/altera-www/global/en_us/pdfs/literature/ug/ug_altfp_mfug.pdf
While you wouldnt be using much VHDL, you are designing a circuit. The VHDL would just glue the cores together. But floating point in FPGA does have it's issues - it has high resource usage and high latency. If you have a constant data stream then the FPGA can process far more than a processor could handle (it can do it in real time - you basically build a custom co-processor). But if it's just a few calculations then it's probably easier to let an arm do the work. So the answer is "Yes it can do it". But you will need to think seriously about how to implement it.