Sine Wave Generator
- Updated2025-01-28
- 7 minute(s) read
Generates a point-by-point sine wave using direct digital synthesis. The synthesis runs continuously from the top-level FPGA target clock to produce an accurate real-time frequency. Each execution of this VI returns the most recent sample produced by the underlying synthesis engine.
During run time, you can use the Normalize Signal Generation Parameters VI to convert frequency, phase, and duty cycle parameters to fixed-point units normalized to the clock rate.

Dialog Box Options
| Option | Description |
|---|---|
| Sine Parameters | Contains the following options:
|
| Implementation | Contains the following options:
|
| Power Spectrum Preview | Displays a preview of the configured signal power spectrum. The peak corresponding to the configured frequency is normalized to 0 dB. The next highest peak in the spectrum gives an estimate of the spurious free dynamic range resulting from the configured implementation parameters. Refer to the support document at ni.com for information about the spurious free dynamic range. |
Inputs/Outputs
reset
—
Sets the VI to the initial state determined by phase offset (periods). The VI resets automatically when it first runs.
frequency (periods/tick)
—
(Optional) Specifies the frequency, in number of periods per tick of the FPGA clock, of the sine wave. The output frequency depends on the top-level FPGA target clock rate. Verify the top-level FPGA target clock rate is set in the Top-Level Clock FPGA Target Properties page before you configure the Sine Wave Generator Express VI. The default corresponds to the value of Frequency (Hz) you enter in the Configure Sine Wave Generator dialog box. The step size through a 32-bit accumulator determines the frequency. The upper n bits specify the address of the sine point in a 2n element look-up table. Place a checkmark in the Show frequency terminal checkbox in the Configure Sine Wave Generator dialog box to add this parameter to the VI connector pane on the block diagram. The value you wire to this terminal must be an unsigned fixed-point data type with a 32-bit word length and a 0-bit integer word length. If you wire a data type with a different configuration to this terminal, LabVIEW coerces the configuration to be <+,32,0>.
phase offset (periods)
—
(Optional) Specifies the initial phase, in number of periods, of the sine wave according to the following formula. phase offset (periods) = Phase offset (deg) / 360 The default corresponds to the value of Phase offset (deg) that you enter in the Configure Sine Wave Generator dialog box. Place a checkmark in the Show offset terminal checkbox in the Configure Sine Wave Generator dialog box to add this parameter to the VI connector pane on the block diagram. The value you wire to this terminal must be an unsigned fixed-point data type with a 32-bit word length and a 0-bit integer word length. If you wire a data type with a different configuration to this terminal, LabVIEW coerces the configuration to be <+,32,0>.
sine out
—
Returns a signed 8-, 16-, or 32-bit integer containing the sine output point.
cosine out
—
(Optional) Returns a signed 8-, 16-, or 32-bit integer containing the sine output point offset by 90 degrees. |
If you run the FPGA VI on a development computer, the Sine Wave Generator Express VI outputs every point of the generated sine wave, regardless of the rate at which LabVIEW calls the VI. To produce the same data when you run the FPGA VI on a development computer as when you run the FPGA VI on an FPGA target, change frequency (periods/tick) to take into account the rate at which the FPGA VI calls the Sine Wave Generator VI. The following equation determines the correction for running the FPGA VI on a development computer.
frequency (periods/tick) (on development computer) = frequency (periods/tick) (on FPGA target) * FPGA loop time (ticks)Examples
Refer to the following example files included with LabVIEW FPGA Module.
- labview\examples\CompactRIO\FPGA Fundamentals\FPGA Math and Analysis\Generation\Sine Wave\Sine Wave.lvproj
- labview\examples\R Series\FPGA Fundamentals\FPGA Math and Analysis\Generation\Sine Wave\Sine Wave.lvproj
reset
—
frequency (periods/tick)
—
sine out
—