dsphdl.NCO
Generate real or complex sinusoidal signals
Description
The NCO System object™ generates real or complex sinusoidal signals, while providing hardware-friendly control signals. A numerically-controlled oscillator (NCO) accumulates a phase increment and uses the quantized output of the accumulator as the index to a lookup table that contains the sine wave values. The wrap around of the fixed-point accumulator and quantizer data types provide periodicity of the sine wave, and quantization reduces the necessary size of the table for a given frequency resolution.
For an example of how to generate a sine wave using this System object, see Design a HDL-Compatible NCO Source. For more information on configuration and implementation, refer to the Algorithms section.
The NCO System object provides these features.
Optional frame-based output.
A lookup table compression option to reduce the lookup table size. This compression results in less than one LSB loss in precision. See Lookup Table Compression for more information.
An optional input argument for external dither.
An optional reset argument that resets the phase accumulator to its initial value.
An optional output argument for the current NCO phase.
To generate real or complex sinusoidal signals:
Create the
dsphdl.NCO
object and set its properties.Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?
Note
You can also generate HDL code for this hardware-optimized algorithm, without creating a MATLAB® script, by using the DSP HDL IP Designer app. The app provides the same interface and configuration options as the System object.
Creation
Syntax
Description
creates a numerically
controlled oscillator (NCO) System object, hdlnco
= dsphdl.NCOhdlnco
, that generates a real or complex sinusoidal
signal. The amplitude of the generated signal is always 1.
sets properties using one or more name-value arguments. For example,
hdlnco
= dsphdl.NCO(Name=Value
)
hdlnco = dsphdl.NCO(NumQuantizerAccumulatorBits=12, ... AccumulatorWL=16);
creates an NCO with the hdlnco
= dsphdl.NCO(Inc
,'PhaseIncrementSource','Property')PhaseIncrement
property set to
Inc
, an integer scalar. To use the PhaseIncrement property, set the PhaseIncrementSource property to 'Property'
. You can add
other Name,Value
pairs before or after
PhaseIncrementSource
.
Properties
Usage
Syntax
Description
The object returns the waveform value, Y
, as a sine value, a cosine
value, a complex exponential value, or a [Sine,Cosine
] pair of values,
depending on the Waveform
property.
[
returns a waveform, Y
,ValidOut
]
= hdlnco (ValidIn
)Y
, using waveform parameters from properties
rather than input arguments.
To use this syntax, set the PhaseIncrementSource, PhaseOffsetSource, and DitherSource
properties to 'Property'
. These properties are independent of each
other. For example:
hdlnco = dsphdl.NCO(PhaseIncrementSource='Property', ... PhaseIncrement=phIncr,... PhaseOffset=phOffset,... NumDitherBits=4)
[
returns a waveform, Y
,ValidOut
]
= hdlnco(Inc
,Offset
,Dither
,ValidIn
)Y
, with phase increment,
Inc
, phase offset, Offset
, and dither,
Dither
.
This syntax applies when you set the PhaseIncrementSource, PhaseOffsetSource, and DitherSource
properties to 'Input port'
. These properties are independent of each
other. You can mix and match the activation of these arguments.
PhaseIncrementSource
is 'Input port'
by default.
For example:
hdlnco = dsphdl.NCO(PhaseOffsetSource='Input port',... DitherSource='Input port') for k = 1:1/Ts y(k) = hdlnco(phIncr,phOffset,ditherBits,true); end
[___] = hdlnco(___,
resets the accumulator value, but does not reset the output samples in the pipeline. If
ResetAccum
,ValidIn
)ValidIn
is true
, then the object continues to
generate the output waveform starting from the reset accumulator value.
To use this syntax, set the ResetAction
property to 1
(true
). This syntax can include any of
the arguments from other syntaxes.
Input Arguments
Output Arguments
Object Functions
To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named obj
, use
this syntax:
release(obj)
Examples
Algorithms
References
[1] Cordesses, L., "Direct Digital Synthesis: A Tool for Periodic Wave Generation (Part 1)." IEEE Signal Processing Magazine. Volume 21, Issue 4, July 2004, pp. 50–54.