EDAboard.com | EDAboard.eu | EDAboard.de | EDAboard.co.uk | RTV forum PL | NewsGroups PL

VHDL and Sin

Ask a question - edaboard.com

elektroda.net NewsGroups Forum Index - VHDL Language - VHDL and Sin

Goto page 1, 2  Next

tommy
Guest

Thu Feb 03, 2011 5:48 pm   



hello all guys
I really need help to write a behavioral and RTL for:

e^sin(x) with |x| < 2

any help is appreciate thanks!

Oliver Mattos
Guest

Thu Feb 03, 2011 7:20 pm   



What resolution/performance do you need?

I'd start with some kind of ROM as a lookup table. To do better than that you'll need to do lots of maths to come up with an iterative algorithm that can come up with the exact result using only basic functions (* + -).

Chris Maryan
Guest

Thu Feb 03, 2011 8:43 pm   



In order of ease of use: The first thing you should look at is LUTs. Then polynomial or spline approximation. Then specialized algorithms for the exact function you are trying to create (i.e. CORDIC).

Chris

Jonathan Bromley
Guest

Thu Feb 03, 2011 10:39 pm   



On Thu, 03 Feb 2011 17:48:37 +0100, tommy wrote:

See the other responses.

I love the subject line. Sin in VHDL, repent in Verilog?
--
Jonathan Bromley

rickman
Guest

Fri Feb 04, 2011 8:33 am   



On Feb 3, 4:39 pm, Jonathan Bromley <s...@oxfordbromley.plus.com>
wrote:
Quote:
On Thu, 03 Feb 2011 17:48:37 +0100, tommy wrote:

See the other responses.

I love the subject line.  Sin in VHDL, repent in Verilog?
--
Jonathan Bromley

LOL!

noobie
Guest

Fri Feb 04, 2011 10:58 am   



On Feb 3, 9:48 pm, tommy <pherak_tele...@alice.it> wrote:
Quote:
hello all guys
I really need help to write a behavioral and RTL for:

e^sin(x) with |x| < 2

any help is appreciate thanks!

Choose either LUT or Taylor series method depending upon the follwoing
situations:

1)You want the result in one clock cycle - Use LUT's.
2)You can wait several clock cycles for the output(and you want a high
precision for the output) - Use Taylor series.

See Taylor series expansion in the following wiki link:
http://en.wikipedia.org/wiki/Taylor_series

--Vipin Lal

Andy
Guest

Mon Feb 07, 2011 8:39 pm   



On Feb 3, 3:39 pm, Jonathan Bromley <s...@oxfordbromley.plus.com>
wrote:
Quote:
On Thu, 03 Feb 2011 17:48:37 +0100, tommy wrote:

See the other responses.

I love the subject line.  Sin in VHDL, repent in Verilog?
--
Jonathan Bromley

Well, there's original sin(), concurrent sin(), sequential (serial?)
sin(), procedural sin(), functional sin()

Let's not forget monadic err... unary sin() and dyadic sin().

Or just "Go Forth and sin() no more."

Andy

Jonathan Bromley
Guest

Mon Feb 07, 2011 10:42 pm   



On Mon, 7 Feb 2011 10:39:38 -0800 (PST), Andy wrote:

Quote:
dyadic sin()

That's co-sin, right?

Jonathan Bromley

KJ
Guest

Tue Feb 08, 2011 12:24 am   



On Feb 7, 4:42 pm, Jonathan Bromley <s...@oxfordbromley.plus.com>
wrote:
Quote:
On Mon, 7 Feb 2011 10:39:38 -0800 (PST), Andy wrote:
dyadic sin()

That's co-sin, right?

Jonathan Bromley

You two really should get off this tangent.

KJ

tommy
Guest

Tue Feb 08, 2011 11:20 am   



Il 07/02/2011 19:39, Andy ha scritto:
Quote:
On Feb 3, 3:39 pm, Jonathan Bromley<s...@oxfordbromley.plus.com
wrote:
On Thu, 03 Feb 2011 17:48:37 +0100, tommy wrote:

See the other responses.

I love the subject line. Sin in VHDL, repent in Verilog?
--
Jonathan Bromley

Well, there's original sin(), concurrent sin(), sequential (serial?)
sin(), procedural sin(), functional sin()

Let's not forget monadic err... unary sin() and dyadic sin().

Or just "Go Forth and sin() no more."

Andy

I need to write an entity for the approximate calculation of e^sin (x)
where x is a number representation in fixed point 2's complement, and |
x | <3.14 / 2.

my entity will be like this:

exp_sin_x entity is
port (x: in signed (15 downto 0), y: out signed (15 downto 0),
clk: in std_ulogic)
end entity;

where the type is defined in the package signed IEEE / numeric_std, x
must be interpreted as a fixed point number format Q3.13 (i.e. x between
-4 and +4) and y as a fixed point number format with Q3.13 (then y lies
between -4 and +4)), clk is a clock signal to synchronize operations.

First I need a behavioral model and test it with a suitable test-bench.
Then I have to write a synthesizable RTL model is tested by comparing
the behavioral model.

I can approximate both the behavioral and structural model with:

e ^ sin (x) with the polynomial P (x) = 1 + x + x ^ 2 / 2! - 3 / 4! x
^ 4 - 8 / 5! x ^ 5 - 3 / 6! x ^ 6

(in the structural relationship, the coefficients are processed in fixed
point and the polynomial is calculated using fixed-point operations).

thanks again in advance

Gerhard Hoffmann
Guest

Tue Feb 08, 2011 12:57 pm   



Am 03.02.2011 18:20, schrieb Oliver Mattos:
Quote:
What resolution/performance do you need?

I'd start with some kind of ROM as a lookup table. To do better than that you'll need to do lots of maths to come up with an iterative algorithm that can come up with the exact result using only basic functions (* + -).


I just have confessed my sin at opencores.org under arith/sincos.
If you can afford the block ram/rom you can use that as a starter.
Filling the table is in a function and is done in Pascal/C style
with floats.

regards, Gerhard

btw:
Is ISE12.4 able to synthesize sfixed/ufixed or are there surprises?

Gerhard Hoffmann
Guest

Tue Feb 08, 2011 1:27 pm   



Ich mach mal die Ingrid:

<http://opencores.org/project,sincos>

Tricky
Guest

Tue Feb 08, 2011 6:55 pm   



On Feb 8, 10:20 am, tommy <pherak_tele...@alice.it> wrote:
Quote:
Il 07/02/2011 19:39, Andy ha scritto:



On Feb 3, 3:39 pm, Jonathan Bromley<s...@oxfordbromley.plus.com
wrote:
On Thu, 03 Feb 2011 17:48:37 +0100, tommy wrote:

See the other responses.

I love the subject line.  Sin in VHDL, repent in Verilog?
--
Jonathan Bromley

Well, there's original sin(), concurrent sin(), sequential (serial?)
sin(), procedural sin(), functional sin()

Let's not forget monadic err... unary sin() and dyadic sin().

Or just "Go Forth and sin() no more."

Andy

I need to write an entity  for the approximate calculation of e^sin (x)
where x is a number representation in fixed point 2's complement, and |
x | <3.14 / 2.

my entity will be like this:

  exp_sin_x entity is
  port (x: in signed (15 downto 0), y: out signed (15 downto 0),
  clk: in std_ulogic)
  end entity;

  where the type is defined in the package signed IEEE / numeric_std, x
must be interpreted as a fixed point number format Q3.13 (i.e. x between
-4 and +4) and y as a fixed point number format with Q3.13 (then y lies
between -4 and +4)), clk is a clock signal to synchronize operations.

First I need a behavioral model and test it with a suitable test-bench.
Then I have to write a synthesizable RTL model is tested by comparing
the behavioral model.

I can approximate both the behavioral and structural model with:

  e ^ sin (x) with the polynomial P (x) = 1 + x + x ^ 2 / 2! - 3 / 4! x
^ 4 - 8 / 5! x ^ 5 - 3 / 6! x ^ 6

(in the structural relationship, the coefficients are processed in fixed
point and the polynomial is calculated using fixed-point operations).

thanks again in advance

First of all, why not look into the new IEEE fixed point package. For
VHDL '93 compatible version, see here: http://www.vhdl.org/fphdl/

Then you can do nice things like:

port (x: in sfixed (2 downto -13), y: out sfixed(2 downto -13) etc

So the bit numbers represent the real powers of 2 in the fixed point
numbers.

Then for a behavioural model, you can do this:

use ieee.math_real.all;
....
port (clk : in std_logic;
x: in sfixed (2 downto -13);
y: out sfixed(2 downto -13));
.....
process
variable x_rl : real;
variable y_rl : real;
begin
wait until rising_edge(clk);
x_rl := to_real(x);
y_rl := math_e ** sin(x_rl);
y <= to_sfixed(y_rl, y'high, y'low);
end process;

This wont be synthesisable, but it is a nice simple behavioural model.
For a synthesisable implementation, a look up table is usually the
best approach, but at 16 bits thats a fair chunk of memory!

Mike Treseler
Guest

Wed Feb 09, 2011 1:09 am   



On 2/8/2011 3:57 AM, Gerhard Hoffmann wrote:
Quote:
Am 03.02.2011 18:20, schrieb Oliver Mattos:
What resolution/performance do you need?

I'd start with some kind of ROM as a lookup table. To do better than
that you'll need to do lots of maths to come up with an iterative
algorithm that can come up with the exact result using only basic
functions (* + -).


I just have confessed my sin at opencores.org under arith/sincos.
If you can afford the block ram/rom you can use that as a starter.
Filling the table is in a function and is done in Pascal/C style
with floats.

Nice example. Thanks for the link.
The opencores site is much improved since my last visit.

-- Mike Treseler

tommy
Guest

Wed Feb 09, 2011 9:15 am   



Il 08/02/2011 17:55, Tricky ha scritto:
Quote:
On Feb 8, 10:20 am, tommy<pherak_tele...@alice.it> wrote:
Il 07/02/2011 19:39, Andy ha scritto:



On Feb 3, 3:39 pm, Jonathan Bromley<s...@oxfordbromley.plus.com
wrote:
On Thu, 03 Feb 2011 17:48:37 +0100, tommy wrote:

See the other responses.

I love the subject line. Sin in VHDL, repent in Verilog?
--
Jonathan Bromley

Well, there's original sin(), concurrent sin(), sequential (serial?)
sin(), procedural sin(), functional sin()

Let's not forget monadic err... unary sin() and dyadic sin().

Or just "Go Forth and sin() no more."

Andy

I need to write an entity for the approximate calculation of e^sin (x)
where x is a number representation in fixed point 2's complement, and |
x |<3.14 / 2.

my entity will be like this:

exp_sin_x entity is
port (x: in signed (15 downto 0), y: out signed (15 downto 0),
clk: in std_ulogic)
end entity;

where the type is defined in the package signed IEEE / numeric_std, x
must be interpreted as a fixed point number format Q3.13 (i.e. x between
-4 and +4) and y as a fixed point number format with Q3.13 (then y lies
between -4 and +4)), clk is a clock signal to synchronize operations.

First I need a behavioral model and test it with a suitable test-bench.
Then I have to write a synthesizable RTL model is tested by comparing
the behavioral model.

I can approximate both the behavioral and structural model with:

e ^ sin (x) with the polynomial P (x) = 1 + x + x ^ 2 / 2! - 3 / 4! x
^ 4 - 8 / 5! x ^ 5 - 3 / 6! x ^ 6

(in the structural relationship, the coefficients are processed in fixed
point and the polynomial is calculated using fixed-point operations).

thanks again in advance

First of all, why not look into the new IEEE fixed point package. For
VHDL '93 compatible version, see here: http://www.vhdl.org/fphdl/

Then you can do nice things like:

port (x: in sfixed (2 downto -13), y: out sfixed(2 downto -13) etc

So the bit numbers represent the real powers of 2 in the fixed point
numbers.

Then for a behavioural model, you can do this:

use ieee.math_real.all;
...
port (clk : in std_logic;
x: in sfixed (2 downto -13);
y: out sfixed(2 downto -13));
....
process
variable x_rl : real;
variable y_rl : real;
begin
wait until rising_edge(clk);
x_rl := to_real(x);
y_rl := math_e ** sin(x_rl);
y<= to_sfixed(y_rl, y'high, y'low);
end process;

This wont be synthesisable, but it is a nice simple behavioural model.
For a synthesisable implementation, a look up table is usually the
best approach, but at 16 bits thats a fair chunk of memory!

This is nice approach but i need help for synthesisable codes... how can
I develop this ?

Goto page 1, 2  Next

elektroda.net NewsGroups Forum Index - VHDL Language - VHDL and Sin

Ask a question - edaboard.com

Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
RTV map EDAboard.com map News map EDAboard.eu map EDAboard.de map EDAboard.co.uk map Opony