Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - DSP newbie

 
Thread Tools Search this Thread
Old 02-28-2008, 04:38 AM   #1
Default DSP newbie


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




FPGA
  Reply With Quote
Old 02-28-2008, 04:50 AM   #2
FPGA
 
Posts: n/a
Default Re: DSP newbie
On Feb 27, 11:38*pm, FPGA <FPGA.unkn...@gmail.com> wrote:
> 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


FPGA
  Reply With Quote
Old 02-28-2008, 10:19 AM   #3
Tricky
 
Posts: n/a
Default Re: DSP newbie
On Feb 28, 4:50 am, FPGA <FPGA.unkn...@gmail.com> wrote:
> On Feb 27, 11:38 pm, FPGA <FPGA.unkn...@gmail.com> wrote:
>
>
>
> > 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


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.


Tricky
  Reply With Quote
Old 02-28-2008, 01:53 PM   #4
FPGA
 
Posts: n/a
Default Re: DSP newbie
On Feb 28, 5:19*am, Tricky <Trickyh...@gmail.com> wrote:
> On Feb 28, 4:50 am, FPGA <FPGA.unkn...@gmail.com> wrote:
>
>
>
>
>
> > On Feb 27, 11:38 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

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

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


FPGA
  Reply With Quote
Old 02-28-2008, 03:02 PM   #5
Dave
 
Posts: n/a
Default Re: DSP newbie
On Feb 28, 8:53 am, FPGA <FPGA.unkn...@gmail.com> wrote:
> On Feb 28, 5:19 am, Tricky <Trickyh...@gmail.com> wrote:
>
>
>
> > On Feb 28, 4:50 am, FPGA <FPGA.unkn...@gmail.com> wrote:

>
> > > On Feb 27, 11:38 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

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

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


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


Dave
  Reply With Quote
Old 02-28-2008, 03:57 PM   #6
FPGA
 
Posts: n/a
Default Re: DSP newbie
On Feb 28, 8:53*am, FPGA <FPGA.unkn...@gmail.com> wrote:
> On Feb 28, 5:19*am, Tricky <Trickyh...@gmail.com> wrote:
>
>
>
>
>
> > On Feb 28, 4:50 am, FPGA <FPGA.unkn...@gmail.com> wrote:

>
> > > On Feb 27, 11:38 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

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

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



FPGA
  Reply With Quote
Old 02-28-2008, 06:33 PM   #7
FPGA
 
Posts: n/a
Default Re: DSP newbie
On Feb 28, 10:57*am, FPGA <FPGA.unkn...@gmail.com> wrote:
> On Feb 28, 8:53*am, FPGA <FPGA.unkn...@gmail.com> wrote:
>
>
>
>
>
> > On Feb 28, 5:19*am, Tricky <Trickyh...@gmail.com> wrote:

>
> > > On Feb 28, 4:50 am, FPGA <FPGA.unkn...@gmail.com> wrote:

>
> > > > On Feb 27, 11:38 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

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

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


The sine wave function in math_real uses the CORDIC algorithm


FPGA
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie; what is the best software to convert DVD (Vob) file to avi - divx ? Laura25 DVD Video 4 07-12-2006 03:03 PM
NEWBIE - DVD burn problem - need help Vic Baron DVD Video 6 09-29-2005 10:56 PM
Another newbie question Jerold Pearson DVD Video 1 12-11-2004 02:25 AM
Newbie Question: DVD Capacities Chris Kotchey DVD Video 3 09-29-2004 03:49 PM
Heeeeeeelp... Newbie with avi to dvd (or svcd) please. Mike DVD Video 11 08-14-2004 09:04 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46