Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Community Forums
- :
- Forums
- :
- About Our Community
- :
- General Technical Discussion
- :
- Re: Square Root Calculator

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

mralam

Newbie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-29-2010 07:24 PM

11,757 Views

Registered:
03-29-2010

Square Root Calculator

Hi All,

I was wondering if i can get some help in implementing a solution to my problem. Below is the description of the problem i am having:

I need to develop a high-speed FPGA design to calculate the square root of a number according to the following specifications:

+ have two inputs ‘x’ and ‘start’.

+ Input signal ‘x’ is an unsigned positive integer.

+ The bit-width for ‘x’ is W bits, where W is a parameter specified in the PreLoadFcn function of the Simulink MDL file. W can be set to 8, 10, 20, 32

+ Input signal ‘start’ is a Boolean.

+ When input signal ‘start’ goes to HIGH for one clock cycle, calculation should begin. I will have to assume that the signal ‘start’ will not go HIGH again until calculation is completed.

+ The device will have two outputs ‘y’ and ‘valid’.

+ Output ‘y’ will store the square root of ‘x’, calculated to the second binary digit.

+ When the device finishes calculating ‘y’, it should make output signal ‘valid’ go HIGH for exactly one clock cycle.

I would like to point out that the block Square Root cannot be used in the design

I will be working on this and will be waiting for someone to direct me in the right direction.

Thanks,

George

7 Replies

john.h

Explorer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-29-2010 08:53 PM - edited 03-29-2010 08:53 PM

11,753 Views

Registered:
02-27-2010

What in the heck is a "block square root" and why do you want us to do your work for you?

Can you do a square root on paper? If not, find out how. If so, use that knowledge to figure out how to put it into hardware.

Would you like us to do your work for you after you graduate as well?

Message Edited by john.h on 03-29-2010 11:53 PM

drjohnsmith

Teacher

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-30-2010 09:42 AM

11,732 Views

Registered:
07-09-2009

HI

Have you looked at the Xilinx Cordec ? in corgen

Why simulink ?

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>

reyk

Contributor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-30-2010 11:43 AM

11,724 Views

Registered:
10-17-2008

You can do this with successive approximation - google newton's method. I've used this in the past with good success.

You need to start with a guess - table lookup - and then iterate to get the precision you want.

Reyk

mralam

Newbie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-14-2010 05:29 PM

11,585 Views

Registered:
03-29-2010

Well john.h if you dont want to help out fair enough but you dont have to go around abusing people. At the bottom of my post i clearly said that i will be working on it, i wasnt waiting for someone to give me the solution, i asked direction. So for next time keep your negative comments to yourself. If you dont know what a square root block then you dont have the right to complain.

drjohnsmith and reyk, thank you for your advise. I eneded up going with drjohnsmith's advise about using Cordic algorithm. Newton's method was good too but it was taking longer duration to perform the same calculation as compared to the one using the cording algorithm. It also used more resources. So again thanks drjohnsmith for your advise.

P.S: john.h, maybe you can learn something from drjohnsmith and be helpful instead of abusing people.

john.h

Explorer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-14-2010 06:02 PM

11,582 Views

Registered:
02-27-2010

And thank you for your kind words, mralam.

In your original post you stated a problem which appears virtually verbatim from a university assignment. You did not mention any way in which you tried to approach the problem yourself, research you had already pursued, or ideas you had on approaches that we might help you narrow down.

You asked for someone to give you what you needed with no demonstration that you were attempting *anything *on your own beyond your promise to work on it while forum users give you suggestions you should find on your own. If you had demonstrated knowledge about the subject... if you had shown that you put forth a true, solid effort... there are many - myself included - who are willing to help an honest, striving student.

If you search for the term "block square root" you'll find there is very little information on the web - at least in english - that uses that term. I was unable to determine if the method you were not permitted to use was the same as the very simple grade-school method used to determine square roots in base-10 math. The extension of this manual method is a beautiful implementation in base-2 arithmetic. I asked if you knew how to do a square root on paper. You did not say whether you had. Neither did you say if you knew of *any *method to determine square roots. Why, then, not *use your resources at your university* to solve your problems?

This forum has students and professionals, certainly. Taking up time and space with questions which are better addressed through other resources clutter this forum and make it less usable. Serious issues go unanswered because they're buried with calls for help where people don't read or even search for the available application notes, literature, or data sheets. Or they don't ask their professor. I'd like to see this forum continue to be an active aid to people who *need* help, not people who *find it convenient* to avoid doing real work (ar at least the appearance of real work). Trying to help too many people with issues devoid of substance will make this forum useful for too few.

Good luck with your studies.

The real world is harsh.

ali_flt

Adventurer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-30-2021 02:27 PM

621 Views

Registered:
08-10-2020

u4223374

Advisor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-30-2021 06:36 PM

591 Views

Registered:
04-26-2015

I'm with @john.h on this one... Straight homework assignment with no attempt to show any work already completed, or for that matter any attempt to disguise the question. The professor/lecturer wanted **you** to do the assignment, not us...

With that said - @mralam, it would make sense to tell us your level of HDL programming too. From the original post, I'm guessing "never looked at HDL before"? Because most of the text there would be trivial for anyone who has done even basic HDL (eg. managing the start and done bits). If that is the case, then diving straight into a CORDIC implementation is not likely to go well; you would be well advised to start with a simpler project that is easy to debug (eg. a basic FSM) and work up to CORDIC.