Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

VHDL code for a square root of a real number????

Status
Not open for further replies.

PRAVEEN HV

Junior Member level 2
Joined
Mar 26, 2011
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
BELAGAVI
Activity points
1,422
Hi can any body tell how a square root of a real number can be calculated using VHDL????
 

Hi Praveen,

There are many ways to calculate the square root, and the method you choose depends on several factors:
- how fast you need to do it (clock speed and latency requirements)
- how much hardware you want to use (and what resources are available in your chosen device)
- how accurate you need the answer to be

Commonly a simple look-up table is used, where the square root is pre-calculated and stored in a ROM. However, if you have a large range of input values, the size of the ROM can become prohibitive. You could reduce the size of the ROM and interpolate, at the expense of some accuracy.

Another method is to use a CORDIC. There are many VHDL implementations of the CORDIC around, if you search the web.

If you need true floating point, then things become more difficult, but it can still be done.

Finally, if you aren't too worried about speed, you could consider doing the square root in software (i.e. having a small software processor embedded in the design).

Hope this helps,
Siskin
 
Hi siskin,
Thanks for ur help, i need square root for floating pont number and also range is not specified so i have to calculate for different values.. is any CORDIC algorithm for square root of a floating pont number????
 

Yes, CORDIC can still be used for floating point, although it is not necessarily the best method.
What is the format of your FP numbers? IEEE single precision, IEEE double precision, or something else?

Again, I would say that the method you choose depends on your constraints: available resources, how quickly you need the answer, and how accurately.

You could implement a LUT-based solution for speed, at the expense of accuracy.
You could implement a Newton-Raphson method, to converge on the correct answer.
Have a look also at the Goldschmidt algorithm.

Finally, think about buying an IP core from someone who has already implemented this for you!

Siskin
 

sir i use double precision format.. Is square root operator for floating point number is available in new versions of XILINX???
If so can it be synthesisable in sparten-3????
 

Both Xilinx and Altera provide a floating point square root function:
Altera's Megacore function: Altera Floating Point Megafunctions
Xilinx's CoreGen function: **broken link removed**

But I thought you needed VHDL? If all you want is a square root for Spartan-3, then I'd suggest you go with Xilinx's core. But you'll need to check the data sheet and make sure the latency figures fir with your requirements.

Siskin
 
  • Like
Reactions: Aya2002

    Aya2002

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top