Hello Mats,

I guess what you need is the implementation of the arctan function in VHDL.

As you probably know the angle calculation is simple the arctan(dy/dx),

where dy = y2-y1 and dx = x2-x1. I guess, if the division can be implemented

considering the hardware cost, you can have a lookup table of the arctan

function depending on different dy/dx values (a dy/dx -> arctan mapping). If

you do generate the table for the first quadrant (or even octant) with a

certain resolution (eg .5 of a degree) then, depending on the orientation of

the line you can calculate it for the other quadrants (or octants - slightly

more complex) without to much extra hardware cost.

Another way would be to implement the arctan function in hardware (see books

of aplied mathematics) but I think this would be less cost effective

(although of higher accuracy).

There may be other ways of doing this but I am not aware of any such.

Best Regards,

Alex.

Quote:

> > hi,

> > I already looked at the sites recommended in the FAQ of this newsgroup

> > but couldn't find any valuable hint. I have to convert two 12 bit

> > integers from rect to polar. I found already a good method for the

> > magnitude calculation, but i have no idea for calculating (or

> > estimating) the angle. Has anybody a hint for a good method, or even a

> > vhdl code example?

> > Thank you

> > heinz

> > Sent via Deja.com http://www.deja.com/

> > Before you buy.

> Hi Heinz!

> The CORDIC algorithm should be a good choise for you. We successfully

> use a CORDIC at four different

> places in a digital receiver that we are designing. The main benefits

> compared to a table-based

> algorithm is that it's scaleble both in width and deep. In our CORDIC

> I've put generics for those two parameters as well as some others, such

> as operation mode and architecture type. That makes it easy to re-use

> and optimize it for different situations.

> Unfortunalely, I can't give you the code because it's propriety

> information. But the paper

> http://users.ids.net/~randraka/files/crdcsrvy.pdf from Andraka

> Consulting group is a very good

> help to start with.

> If you want a hint on how to code it in VHDL, take a look in the

> ieee.math_pkg package where a non-synthesizable CORDIC is implemented.

> The principals should be the same as with a synthesizable

> version, just change the REAL arithmetic to SIGNED.

> Regards,

> // Mats