Maybe you can use the IEEE package math_real.

This package contains often used constants (math_e, math_pi, ..) and

functions (sqrt, exp, log, log2, sin, arccos, sinh, ..).

(not synthesisable)

ModelSim has this package.

Here an example

library ieee;

use ieee.std_logic_1164.all;

use ieee.math_real.all;

entity math is

end math;

architecture demo of math is

signal s, c, this_should_be_one : real := 0.0;

begin

stimuli

rocess

constant delta : real := 10.0E-4;

variable x : real := 0.0;

begin

x:=0.0;

while x < 4.0*MATH_PI loop

s <= sin(x);

c <= cos(x);

wait for 1 ns;

x:=x+delta;

end loop;

report "finished";

wait;

end process;

this_should_be_one <= s**2 + c**2;

end demo;

And if you use the macro file beneath you get a nice waveform.

vsim math

onerror {resume}

quietly WaveActivateNextPane {} 0

add wave -noupdate -format Analog-Step -offset -1.0 -scale 40.0 /math/s

add wave -noupdate -format Analog-Step -offset -0.58 -scale 40.0 /math/c

add wave -noupdate -format Analog-Step -offset -0.14 -scale 40.0

/math/this_should_be_one

run -all

Egbert Molenkamp

"senthil" <(E-Mail Removed)> wrote in message

news:(E-Mail Removed) om...

> hello friends,

>

> for the fft and ifft part of dsp, w.r to twiddle factor, we need the

> cosine and sine terms. for that i do my sine code w.r to sine series

> formulae.

>

> sin(x) = x - x3/3(fact) + x5/5(fact) _ ...

>

> i took only 3 terms.

>

> and my coding was given below

>

>

> term : =1

> sum := 1

>

> for n in 1 to 3 loop

>

> term := (-term)*input **2/real((2n*(2n+1)));

> sum := sum + term;

> end loop

>

> output <= input * sum;

>

> i found one problem , ie., if i give input = 3.534, i got an output =

> -0.596

> that is wrong answer.

> but actual value from the calculator, is sin(3.534) = -0.3818..

>

> what is the problem behind that.

> give some guidance.

>

> tool : modelsim 5.5 SE vhdl.