Velocity Reviews > VHDL > square root of a number in vhdl

# square root of a number in vhdl

vibeni
Junior Member
Join Date: Jul 2007
Posts: 2

 11-02-2007
hi

i have to find the square root of 36 bit data at 30MHz rate using vhdl and store it into the fifo at 5 Mhz. can some one help me with the code for finding the square root of the number. please it is very important.

scottcarl
Member
Join Date: May 2007
Location: USA
Posts: 51

 11-05-2007
vibeni,

Here's a sneaky formula for finding square roots.

G = (g + n/g)/2

Where n = 36-bit input number and g = your 1st guess.

Then after you calculate the 1st square_root (G) result, you must put this result back into the formula as 'g' and reiterate to get the next square_root result. You must do this multiple times until you are satisfied with the precision of the result. I would suggest setting up a spreadsheet to see how many iterations it will take to get a precise answer depending on what you choose as your 1st guess. You can reduce your iterations by making an intelligent input as to your first guess (this would include evaluating where your MSB is in your 36-bit input number and determining the order of the expected result).

If you really want to get tricky here's the code for finding higher order roots of any number.

G = ((m-1)*g + n/g^(m-1))/m where m=root_order

Scott C

vipinlal
Member
Join Date: Feb 2010
Posts: 39

 03-18-2010
here is code for square root function for unsigned numbers..
vhdlguru.blogspot.com/2010/03/vhdl-function-for-finding-square-root.html

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Christian VHDL 5 03-18-2010 02:14 PM sathyashrayan C Programming 4 04-22-2006 08:08 PM priyam.trivedi@gmail.com C Programming 32 03-06-2006 10:54 AM alghazo@siu.edu VHDL 0 05-27-2004 06:23 AM Luca VHDL 1 04-29-2004 02:51 PM