Easiest way to generate Arctan function using LUT?

Guest
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
 
<paragon.john@gmail.com> wrote in message
news:bba91ec7-58f9-46e0-b5a8-dbd09063c82b@v17g2000hsa.googlegroups.com...
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.
 
On Jan 23, 9:11 am, paragon.j...@gmail.com wrote:
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
 
Add a return(RetVal) statement after the 'end loop' in previously
posted code.

KJ
 

Welcome to EDABoard.com

Sponsor

Back
Top