Turn on suggestions

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

Showing results for

- Intel Community
- FPGAs and Programmable Solutions
- FPGA Intellectual Property
- Is There A Megafunction For Arctan ?

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

Altera_Forum

Honored Contributor I

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

07-14-2010
07:24 AM

2,305 Views

Is There A Megafunction For Arctan ?

hi everyone,

is there any megafunctşon that implements arctan ? is there anyone know about this? thanks..Link Copied

26 Replies

Altera_Forum

Honored Contributor I

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

07-14-2010
11:56 AM

88 Views

Altera_Forum

Honored Contributor I

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

07-14-2010
01:16 PM

88 Views

Don't know about pre built blocks.

By the way, if you have low number of input bit you can just store the function values in a Look Up Table. How many input bits you have?
Altera_Forum

Honored Contributor I

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

07-15-2010
07:00 AM

88 Views

Altera_Forum

Honored Contributor I

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

07-15-2010
07:22 AM

88 Views

With 18bits a LUT is no feasible.

There are many options on the literature. One is Cordic as previosuly reported. Another option is a mix of ROM and linear (or quadratic interpolation). Unfortunately it is not a simple task and a good approximation requires a careful analysis of the literature. My group published many papers on these topics. As example:
Altera_Forum

Honored Contributor I

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

07-15-2010
08:02 AM

88 Views

thanks a lot. but your links can not fonud. may be this can be a result of my browser.

so can I ask one more question? have you any idea aboul kalman filter design with verilog ?
Altera_Forum

Honored Contributor I

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

07-15-2010
08:54 AM

88 Views

The links cannot work.

You've to search on IEEExplore website but you can download the papers only if your institution pays the IEEE. With reference to Kalman... sorry, it's not my expertise. I can't help.
Altera_Forum

Honored Contributor I

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

07-15-2010
08:56 AM

88 Views

Those links effectively do not work.

If you search for the titles on the web you will find them at IEEE, so you need access rights ($$$). Cordic is a proven approach, well documented on the web (free) and in fact a simple algorithm. Back in 2004 I made my own specific implementation in AHDL. I recompiled it today for 10 and 16 bits precision (16 bits is the maximum I projected at the time), if I extrapolate the LC usage an 18 bit cordic would use about 1150 LC (Cyclone I) and run at about 250 MHz in pipelined mode. Making it combinatorial will use about the same amount of LCs but will be a lot slower( est. 70 ns delay). I used a Cyclone EP1C4F324C6 device for the test compilations.
Altera_Forum

Honored Contributor I

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

07-15-2010
09:09 AM

88 Views

Altera_Forum

Honored Contributor I

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

07-18-2010
08:08 AM

88 Views

Universities pay the fee.

I come from an University and come to this forum to exchange ideas with people experts in the field. I can assure you that in the Universities not everybody is an expert on Altera FPGA design. As a consequence web resources and forums are very much used to improve the quality of the work. Further, I think that many University people, such as young master thesis students, come to this forums to seek advices for their projects. These students usually have access to many on-line journals such as IEEE.
Altera_Forum

Honored Contributor I

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

07-18-2010
09:01 AM

88 Views

I don't want to start a polemic here (I sincerely hope I didn't).

A lot of people visiting this forum are not at a university or working in a large(r) company, yet are very experienced and have solved real-life projects. I think it is a matter of politeness that if you bring an argument into a discussion that other parties can explore that argument and eventually learn from it.
Altera_Forum

Honored Contributor I

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

07-18-2010
03:24 PM

88 Views

Another way is to directly use the math libraries that your HDL supports. Usually this already comes with Quartus. For example, in VHDL you could simply add the math_real library, and call arctan(). Probably the Cordic method provides better/faster results, but I guess this is the simplest way if you just want to add an arctan function.

```
use ieee.math_real.all;
...
variable x:real:=0.0;
variable n:integer:=0;
...
/* some manipulation on x */
...
n:=integer(arctan(x));
```

Altera_Forum

Honored Contributor I

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

07-18-2010
03:32 PM

88 Views

Altera_Forum

Honored Contributor I

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

07-19-2010
07:33 AM

88 Views

The arctan() function in the library expects a real as input where Angela specified 18 bits, which I presume to be a std_logic_vector or a constrained integer type.

Second, if the compiler will synthesize the library function, we end up with combinatorial implementation which may be too slow. But the library function can do double duty: first serve as a guidance into Cordic and second to use in the testbench.
Altera_Forum

Honored Contributor I

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

07-19-2010
08:24 AM

88 Views

Altera_Forum

Honored Contributor I

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

07-19-2010
08:43 AM

88 Views

**not** synthesizable. As ieee.math_real exclusively contains operation with the real type, it's not suited for synthesis as well.

Altera_Forum

Honored Contributor I

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

07-19-2010
09:00 AM

88 Views

FvM was quicker than me to state that the type real is not synthesizable. (I needed to check first ...)

Any function described by a for loop will ultimately end up being combinatorial (and thus usually too slow), pipelining to speed it up is however plain manual labor. New VHDL constructs to make this easier would be very interesting -> System-VHDL?
Altera_Forum

Honored Contributor I

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

07-19-2010
09:57 AM

88 Views

Yes, that was why I recasted the result back to integer, a synthesizable type. I agree that real itself isn't synthesizable, but it's allowed for calculations. I assumed a real input to go into the arctan() function, but if it's a std_logic_vector, we need some kind of conversion to real first.

The arctan() function just serves as the calculation, where it will give a real result (which isn't synthesizable). But we can re-cast this result to integer (or others) that would make it synthesizable?
Altera_Forum

Honored Contributor I

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

07-19-2010
10:14 AM

88 Views

Unfortunately casting won't help. The actual operand presented to the synthesis would still be a real, which is not synthesizable.

Writing an integer equivalent for the arctan() function as given in the ieee_math_real is not that difficult. I'll might give it a shot later tonight (after finishing my other work duties).
Altera_Forum

Honored Contributor I

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

07-19-2010
10:19 AM

88 Views

cool... tell us about it. :)

I just tried the arctan() function, and Quartus compiles without errors. I believe Quartus should throw an error if something if not synthesizable right? Or at least a warning? I saw (in RTL Viewer) that some logic was generated from this (mostly muxes), but have not done P&R nor verified it working on a board yet. Here, I assigned a bunch of output ports directly to "integer". There's a catch when using this method though. Your input to arctan() should be a "constant real", means not something that can be varied during runtime. The code I submitted previously assumes that x is a constant and doesn't change during runtime (which is unlikely). Does anyone know of a workaround for this (Quartus can't synthesize non-constant reals)?
Altera_Forum

Honored Contributor I

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

07-19-2010
11:29 AM

34 Views

Topic Options

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

For more complete information about compiler optimizations, see our Optimization Notice.