Sine Wave Generation

S

SneakerNet

Guest
Hi all

I need some help with regards to generating a sine wave. I thought abt this
problem and some thoughts that came to mind are as follows:
1. Generate sine values using spreadsheet
2. Store these values either in ROM or make a table withing VHDL
3. Write VHDL code and output these values.

My question is:
Is it better to store these values in ROM (eg. LUT) or directly hardcode the
values.
Is there a website that will explain or give more explanation in this area.

Cheers
 
Depends on the number of phase angles you need to have. For example, if you
sample the sine so that its frequency is 1/4 the sample rate, you only have 1,0,
and -1 for values. If your sample rate is not phase locked to the sine,
however, you may need a very large number of phase angles. In that case, it may
be better to use a computed sine using either CORDIC or one of several other
approximation methods.

SneakerNet wrote:

Hi all

I need some help with regards to generating a sine wave. I thought abt this
problem and some thoughts that came to mind are as follows:
1. Generate sine values using spreadsheet
2. Store these values either in ROM or make a table withing VHDL
3. Write VHDL code and output these values.

My question is:
Is it better to store these values in ROM (eg. LUT) or directly hardcode the
values.
Is there a website that will explain or give more explanation in this area.

Cheers
--
--Ray Andraka, P.E.
President, the Andraka Consulting Group, Inc.
401/884-7930 Fax 401/884-7950
email ray@andraka.com
http://www.andraka.com

"They that give up essential liberty to obtain a little
temporary safety deserve neither liberty nor safety."
-Benjamin Franklin, 1759
 
If you need more than a few points, a ROM would be a better idea. I did this
to generate a sine wave (via a D/A) for an all digital LVDT synchronous
demodulation circuit. The beauty of using ROM is you can store many points,
including multiple frequencies by using the upper address lines to select a
different set of values.

BTW, I used C and/or Visual Basic to generate the values, writing them
directly to a binary file, then using the file to program the ROM.

--
Greg
readgc.invalid@hotmail.com.invalid
(Remove the '.invalid' twice to send Email)


"SneakerNet" <nospam@nospam.org> wrote in message
news:pdzWb.41614$9k7.859740@news.xtra.co.nz...
Hi all

I need some help with regards to generating a sine wave. I thought abt
this
problem and some thoughts that came to mind are as follows:
1. Generate sine values using spreadsheet
2. Store these values either in ROM or make a table withing VHDL
3. Write VHDL code and output these values.

My question is:
Is it better to store these values in ROM (eg. LUT) or directly hardcode
the
values.
Is there a website that will explain or give more explanation in this
area.

Cheers
 
You could use a single digital output to produce a square wave at the
fundamental frequency, then filter out the harmonics to produce a sinewave.

It wouldn't be the most flexible solution, i.e. Frequency variation is
dependant on the filter, but it would save you a lot of hardware on your
FPGA.

Ray Andraka wrote:
Depends on the number of phase angles you need to have. For example, if you
sample the sine so that its frequency is 1/4 the sample rate, you only have 1,0,
and -1 for values. If your sample rate is not phase locked to the sine,
however, you may need a very large number of phase angles. In that case, it may
be better to use a computed sine using either CORDIC or one of several other
approximation methods.

SneakerNet wrote:


Hi all

I need some help with regards to generating a sine wave. I thought abt this
problem and some thoughts that came to mind are as follows:
1. Generate sine values using spreadsheet
2. Store these values either in ROM or make a table withing VHDL
3. Write VHDL code and output these values.

My question is:
Is it better to store these values in ROM (eg. LUT) or directly hardcode the
values.
Is there a website that will explain or give more explanation in this area.

Cheers


--
--Ray Andraka, P.E.
President, the Andraka Consulting Group, Inc.
401/884-7930 Fax 401/884-7950
email ray@andraka.com
http://www.andraka.com

"They that give up essential liberty to obtain a little
temporary safety deserve neither liberty nor safety."
-Benjamin Franklin, 1759

--
Andrew Greensted Department of Electronics
Bio-Inspired Engineering University of York, UK

Tel: +44(0)1904 432379 Mailto: ajg112@ohm.york.ac.uk
Fax: +44(0)1904 433224 Web: www.bioinspired.com
 
There is a synthesisable sine wave generator on our website here :
http://www.doulos.com/knowhow/vhdl_models/sine_wave_generator/

It includes a perl script to generate a sine wave lookup table of arbitrary
dimensions/precision. The code will probably want modifying slightly so it
uses LUT based ROM or BRAMs. If I have time, I might add an FPGA optimisd
version...

HTH

Ian

--
Ian Poole, Consultant

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.


"SneakerNet" <nospam@nospam.org> wrote in message
news:pdzWb.41614$9k7.859740@news.xtra.co.nz...
Hi all

I need some help with regards to generating a sine wave. I thought abt
this
problem and some thoughts that came to mind are as follows:
1. Generate sine values using spreadsheet
2. Store these values either in ROM or make a table withing VHDL
3. Write VHDL code and output these values.

My question is:
Is it better to store these values in ROM (eg. LUT) or directly hardcode
the
values.
Is there a website that will explain or give more explanation in this
area.

Cheers
 
The OP did not mention the sample rate relative to clock rate, the phase
relationship of the sine to the sample interval if any, or the required
precision. Without these, it is not possible to offer a 'best' solution. ROM
is fine as long as the number of phase angles supported is small enough to fit
in the address space of the ROM. It may be more efficient however to compute
the sine on the fly using CORDIC, or to use a table plus correction (one design
I did a while back did a linear approx, that was corrected by a small table, and
then that result was corrected by a second small table).

"Gregory C. Read" wrote:

If you need more than a few points, a ROM would be a better idea. I did this
to generate a sine wave (via a D/A) for an all digital LVDT synchronous
demodulation circuit. The beauty of using ROM is you can store many points,
including multiple frequencies by using the upper address lines to select a
different set of values.

BTW, I used C and/or Visual Basic to generate the values, writing them
directly to a binary file, then using the file to program the ROM.

--
Greg
readgc.invalid@hotmail.com.invalid
(Remove the '.invalid' twice to send Email)

"SneakerNet" <nospam@nospam.org> wrote in message
news:pdzWb.41614$9k7.859740@news.xtra.co.nz...
Hi all

I need some help with regards to generating a sine wave. I thought abt
this
problem and some thoughts that came to mind are as follows:
1. Generate sine values using spreadsheet
2. Store these values either in ROM or make a table withing VHDL
3. Write VHDL code and output these values.

My question is:
Is it better to store these values in ROM (eg. LUT) or directly hardcode
the
values.
Is there a website that will explain or give more explanation in this
area.

Cheers
--
--Ray Andraka, P.E.
President, the Andraka Consulting Group, Inc.
401/884-7930 Fax 401/884-7950
email ray@andraka.com
http://www.andraka.com

"They that give up essential liberty to obtain a little
temporary safety deserve neither liberty nor safety."
-Benjamin Franklin, 1759
 
Ray Andraka wrote:

The OP did not mention the sample rate relative to clock rate, the phase
relationship of the sine to the sample interval if any, or the required
precision. Without these, it is not possible to offer a 'best' solution. ROM
is fine as long as the number of phase angles supported is small enough to fit
in the address space of the ROM.
(big snip)

I seem to remember ones that had two ROMs, where the second was
a linear interpolation. Adders were then used to combine the
results from the ROMs. There may be some FPGA cases where
that method could still be used.

-- glen
 
SneakerNet wrote:

Hi all

I need some help with regards to generating a sine wave. I thought abt this
problem and some thoughts that came to mind are as follows:
1. Generate sine values using spreadsheet
2. Store these values either in ROM or make a table withing VHDL
3. Write VHDL code and output these values.

My question is:
Is it better to store these values in ROM (eg. LUT) or directly hardcode the
values.
Is there a website that will explain or give more explanation in this area.

Cheers
1) write a sample counter. when the msb of the counter is '0', take all
lsb. when the msb of the counter is '1', invert all lsb.
The result is a triangular wawe.

2) Cut the top and bottom of your triangular wawe using comparators

3) used a filter to remove harmonics

Laurent Gauch
www.amontec.com
 
There's a fairly nice arbitrary frequency sine and cosine generator core
available from Xilinx that has a whole host of options. We're playing with
it on a current project. It even has a multiplex mode where you can reuse
the LUTs for up to 16 different signals.

YMMV
-Marty

"Ian Poole" <ian.poole@doulos.delete-this-bit.com> wrote in message
news:c0fmn5$ap8$1$8300dec7@news.demon.co.uk...
There is a synthesisable sine wave generator on our website here :
http://www.doulos.com/knowhow/vhdl_models/sine_wave_generator/

It includes a perl script to generate a sine wave lookup table of
arbitrary
dimensions/precision. The code will probably want modifying slightly so it
uses LUT based ROM or BRAMs. If I have time, I might add an FPGA optimisd
version...

HTH

Ian
 

Welcome to EDABoard.com

Sponsor

Back
Top