Easiest way to generate Arctan function using LUT?

P

paragon.john

Hello all,

I am working on a design which requires an arctan to be performed in
my FPGA. I've been trying to figure out the best way to implement the
arctan as it is one of the more difficult functions to implement. It
seems to me that for smaller bit widths, the best way is to just use a
LUT approach. However, I'm having trouble figuring out the best way
to initialize the ROM.

I thought about using MATLAB to generate a package which has the
values, but this just seems clunky to me. Is there a good way to use
the ieee.math_real package to generate an array of values using the
that package's arctan function? I can't quite figure out a way to
initialize the constant array for all of the values. Any thoughts on
how to go about this? Thanks for all the help!

Regards,
John
 
S

Symon

Hello all,

I am working on a design which requires an arctan to be performed in
my FPGA. I've been trying to figure out the best way to implement the
arctan as it is one of the more difficult functions to implement. It
seems to me that for smaller bit widths, the best way is to just use a
LUT approach. However, I'm having trouble figuring out the best way
to initialize the ROM.

I thought about using MATLAB to generate a package which has the
values, but this just seems clunky to me. Is there a good way to use
the ieee.math_real package to generate an array of values using the
that package's arctan function? I can't quite figure out a way to
initialize the constant array for all of the values. Any thoughts on
how to go about this? Thanks for all the help!

Regards,
John

Hi John,
When I did the same thing for SINE, I wrote a Perl script to generate some
VHDL which initialised the LUT.
HTH., Syms.
 
K

KJ

Hello all,

I am working on a design which requires an arctan to be performed in
my FPGA.  I've been trying to figure out the best way to implement the
arctan as it is one of the more difficult functions to implement.  It
seems to me that for smaller bit widths, the best way is to just use a
LUT approach.  However, I'm having trouble figuring out the best way
to initialize the ROM.

I thought about using MATLAB to generate a package which has the
values, but this just seems clunky to me.  Is there a good way to use
the ieee.math_real package to generate an array of values using the
that package's arctan function?  I can't quite figure out a way to
initialize the constant array for all of the values.  Any thoughts on
how to go about this?  Thanks for all the help!
Create a function that returns an array and then initialize a constant
to the output of that function. Snippets below

type arr_integer is array (natural range <>) of integer;
function Create_arctan_lookup_table(int Size: integer) return
arr_integer is
variable RetVal: arr_integer(0 to Size - 1);
begin
for i in RetVal'range loop
-- Go through and compute your arctan lookup here
-- I've used ieee_math.real stuff and other 'real'
-- inside a function to perform calculations to compute
-- things and Quartus 7.2 synthesized it just fine
-- (although Quartus 5.x gagged with an error). Don't
-- know yet about XST or Synplify.
end loop;
end function Create_arctan_lookup_table;
...
constant LUT_SIZE: natural := 256; -- Or whatever size it really is
constant LUT_CONTENTS: arr_integer(0 to (LUT_SIZE-1)) :=
Create_arctan_lookup_table(LUT_SIZE);
...

Kevin Jennings
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top