DSP newbie

F

FPGA

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 <= ((amp_sin*sin(phase_temp)));
phase_temp := phase_temp + incr_sin;
wait for period_sin;
end loop l1;
end process two;


The problem I am facing is, I get sine wave for some values and for
some I just get triangulr wave. Is there any limitation to the sin
function in math_real. Should I be able to generate any type of
frequencies with this function. Please help
 
F

FPGA

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 <= ((amp_sin*sin(phase_temp)));
                phase_temp := phase_temp + incr_sin;
                wait for period_sin;
        end loop l1;
end process two;

The problem I am facing is, I get sine wave for some values and for
some I just get triangulr wave. Is there any limitation to the sin
function in math_real. Should I be able to generate any type of
frequencies with this function. Please help

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
 
T

Tricky

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

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.
 
F

FPGA

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.- Hide quoted text -

- Show quoted text -

I am required to design this using the CORDIC algorithm.
 
F

FPGA

I am required to design this using the CORDIC algorithm.- Hide quoted text -

- Show quoted 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 := (2.0*MATH_PI)/(real(samples_sin)); -- 2pi/
samples per period
incr_time_sin : time := time(period_sin/samples_sin); --
period/samples per period
 
F

FPGA

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 := (2.0*MATH_PI)/(real(samples_sin));       -- 2pi/
samples per period
incr_time_sin : time := time(period_sin/samples_sin);                 --
period/samples per period- Hide quoted text -

- Show quoted text -

The sine wave function in math_real uses the CORDIC algorithm
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top