DSP newbie

Feb 28, 2008 8 Replies

I have written a process to generate sin wave as below.


-- sine wave constants amp_sin : real := 10.0; phase_sin : real := 0.0 -- phase in radians samples_sin : integer := 1000; -- number of samples incr_sin : real := 0.001; -- 1/samples period_sin : time := 0.001 ns; -- period of sine wave/samples



two : process variable phase_temp,result : real ; begin phase_temp := phase_sin; --phase_sin; l1 : for i in 1 to samples_sin loop --number_of_samples loop



sine_real


I have written a process to generate sin wave as below.

-- sine wave constants amp_sin : real := 10.0; phase_sin : real := 0.0 -- phase in radians samples_sin : integer :=

1000; -- number of samples incr_sin : real := 0.001; -- 1/ samples period_sin : time := 0.001 ns; -- period of sine wave/samples

two : process variable phase_temp,result : real ; begin phase_temp := phase_sin; --phase_sin; l1 : for i in 1 to samples_sin loop --number_of_samples loop

sine_real

10.0;

=3D 0.0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0--

er :=3D

=3D 0.001; =A0 =A0 =A0 =A0 =A0 =A0 =A0-- 1/

=3D 0.001

op

Also, the sine wave does not stop after it takes all the samles, I keep getting a continous sine wave. Would like to add the option of generating wave from 0 tp 2pi or 4 pi, etc. I want to make this as generic as possible

:=3D=

:=

integ=

:=

time :=

lo=

To get it to stop after 1 run through the "l1" loop, add "wait;" betwee the "end loop" and "end process".

Regarding triangular waves, that could happen be when you do not hav enough samples per period. Does "nyquist theorem" mean anything to you?

It's repeating because you havent told the process to wait when it finishes the loop. Currently the loop finishs, and then the process restarts and does the whole loop again, and this will repeat for ever. To stop this simply put "wait;" at the end of the process.

:=3D 10.0;

l :=3D 0.0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0--

nteger :=3D

:=3D 0.001; =A0 =A0 =A0 =A0 =A0 =A0 =A0-- 1/

me :=3D 0.001

s loop

xt -

I am required to design this using the CORDIC algorithm.

-

Then why aren't you using the CORDIC algorithm? Google it.

l :=3D 10.0;

eal :=3D 0.0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0--

integer :=3D

al :=3D 0.001; =A0 =A0 =A0 =A0 =A0 =A0 =A0-- 1/

time :=3D 0.001

les loop

n;

text -

-

I was able to add the wait statement and the problem was solved. I modified some of the things and not I am able to get waveforms at different frequencies. FYI, incr_phase_sin : real :=3D (2.0*MATH_PI)/(real(samples_sin)); -- 2pi/ samples per period incr_time_sin : time :=3D time(period_sin/samples_sin); -- period/samples per period

eal :=3D 10.0;

real :=3D 0.0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0--

: integer :=3D

real :=3D 0.001; =A0 =A0 =A0 =A0 =A0 =A0 =A0-- 1/

: time :=3D 0.001

mples loop

sin;

r

d text -

xt -

-- 2pi/

=A0 =A0 =A0 =A0 --

The sine wave function in math_real uses the CORDIC algorithm

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required