Easiest way to generate Arctan function using LUT?

Discussion in 'VHDL' started by paragon.john@gmail.com, Jan 23, 2008.

  1. 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
     
    , Jan 23, 2008
    #1
    1. Advertising

  2. Symon Guest

    <> wrote in message
    news:...
    > 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.
     
    Symon, Jan 23, 2008
    #2
    1. Advertising

  3. KJ Guest

    On Jan 23, 9:11 am, 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
     
    KJ, Jan 23, 2008
    #3
  4. KJ Guest

    Add a return(RetVal) statement after the 'end loop' in previously
    posted code.

    KJ
     
    KJ, Jan 23, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason
    Replies:
    0
    Views:
    377
    Jason
    Apr 10, 2004
  2. Jason
    Replies:
    2
    Views:
    530
    Rob Thorpe
    Apr 11, 2004
  3. Gerald
    Replies:
    0
    Views:
    727
    Gerald
    Dec 9, 2005
  4. Gerald
    Replies:
    5
    Views:
    464
  5. Sam Roberts
    Replies:
    0
    Views:
    98
    Sam Roberts
    Apr 3, 2005
Loading...

Share This Page