Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

NCO HDL Optimized

Generate real or complex sinusoidal signals—optimized for HDL code generation

  • Library:
  • DSP System Toolbox / Signal Operations

    DSP System Toolbox / Sources

    DSP System Toolbox HDL Support / Signal Operations

    DSP System Toolbox HDL Support / Sources

Description

The NCO HDL Optimized block generates real or complex sinusoidal signals, while providing hardware-friendly control signals. It uses the same phase accumulation and lookup table technology as implemented in the NCO block. It provides the following features:

  • A lookup table compression option to reduce the lookup table size with less than one LSB loss in precision. See Lookup Table Algorithm for more detail.

  • An option to synthesize the lookup table to a ROM when using HDL Coder™ with an FPGA target. To enable this feature, right-click the block, select HDL Code > HDL Block Properties and set LUTRegisterResetType to none.

  • An optional input port for external dither.

  • An optional reset port that triggers a reset of the phase to its initial value during the sinusoid output generation.

  • An optional output port for the current NCO phase.

Given a desired output frequency F0, calculate the phase_increment input value using

phase increment=(F02NFs)

where N is the accumulator word length and

Fs=1Ts=1sample time

You can specify the phase increment using a property or an input argument.

The frequency resolution of an NCO is defined by

Δf=1Ts2NHz

Given a desired phase offset (in radians), calculate the phase_offset input value using

phase offset=2Ndesired phase offset2π

You can specify the phase offset using a property or an input argument.

Ports

Note

  • This block appears in the Sources libraries with Phase increment source parameter set to Property. The only input port is validIn.

  • This block appears in the Signal Operations libraries with Phase increment source parameter set to Input port. This configuration shows the optional input port inc.

This icon shows all the possible ports of the NCO HDL Optimized block.

Input

expand all

Phase increment, specified as a scalar integer. double and single are allowed for simulation but not for HDL code generation.

Dependencies

To enable this port, set Phase increment source to Input port.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixdt([],N,0)

Phase offset, specified as a scalar integer. double and single are allowed for simulation but not for HDL code generation.

Dependencies

To enable this port, set Phase offset source to Input port.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixdt([],N,0)

Dither, specified as a scalar integer. double and single are allowed for simulation but not for HDL code generation.

Dependencies

To enable this port, set Dither source to Input port.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixdt([],N,0)

Reset signal, as a boolean. When this signal is true, the block resets the accumulator to 0.

Dependencies

To enable this port, select Enable reset input port.

Data Types: Boolean

When this signal is true, the block increments the phase. When this signal is false, the block holds the phase.

Dependencies

To enable this port, select Enable validIn input port.

Data Types: Boolean

Output Arguments

expand all

Generated waveform, returned as a scalar fixdt or floating-point type. double and single are allowed for simulation but not for HDL code generation.

Dependencies

By default, the output is a sine wave, sin. The port labels change based on your selection for Type of output signal.

Current phase of NCO, returned as a scalar of type fixdt(1,M,-Z), where M is the number of quantized accumulator bits, and Z is the accumulator word length. The object returns Phase as floating point if the input to the object is floating point. Floating point is allowed for simulation but not for HDL code generation.

Dependencies

To enable this port, select Show phase port.

Data Types: single | double | fixdt(1,NumQuantizerAccumulatorBits,-AccumulatorWL)

Whether the data output is valid or not. When validOut is true, the data output is valid. When validOut is false, the data output is not valid.

Data Types: Boolean

Parameters

expand all

Main

Note

This block supports double input for simulation but not for HDL code generation. When a data input is fixed point, or when no data input ports are enabled, the block computes the output waveform based on the fixed-point mask settings. When a data input is floating-point, the block ignores Number of dither bits, Quantize phase, Number of quantizer accumulator bits, Enable look up table compression method, and the Data Types tab, and computes a double-precision output waveform.

When you switch to using a floating-point phase increment, you must adjust the value of the increment to account for the lack of phase quantization. See .

You can set the phase increment with an input port or you can enter a value for the parameter. If you select Property, the Phase increment parameter appears.

Phase increment for generating the waveform, specified as a scalar integer. double and single are allowed for simulation but not for HDL code generation.

Dependencies

This parameter is visible when you set Phase increment source to Property.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | fixdt([],N,0)

You can set the phase offset from an input port or from a parameter. If you select Input port, the offset port appears on the block icon.

Phase offset for the generated waveform, specified as a scalar integer. double and single are allowed for simulation but not for HDL code generation.

Dependencies

This parameter is visible when you set Phase offset source to Property.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | fixdt([],N,0)

You can set the dither from an input port or from a parameter. If you select Property, the Number of dither bits parameter appears. If you select Input port, a port appears on the block. If you select None, the block does not add dither.

Number of dither bits, specified as a positive integer.

Dependencies

This option is visible when you set Dither source to Property.

When this option is enabled, the NCO output is calculated by quantizing the result of the phase accumulator to a fixed bit- width. This quantized value is used to select a waveform value from the lookup table. Select the resolution of the lookup table using the Number of quantizer accumulator bits property.

The frequency resolution of an NCO is defined by

Δf=1Ts2NHz

When you disable this option,

Number of quantizer accumulator bits, specified as an integer scalar greater than 1 and less than the accumulator word length. The lookup table of sine values has 2NumQuantizerAccumBits entries.

Dependencies

This parameter is visible when you select Quantize phase.

By default, the object implements a compressed lookup table. The Sunderland compression method reduces the size of the lookup table with less than one LSB loss in precision. The spurious free dynamic range (SFDR) is empirically 1-3dB lower than the non-compressed case. With a compressed lookup table, you can increase the word length of the accumulator, and the number of quantize bits, to improve the performance. For detail of the compression method, see Algorithms.

When this option is disabled, the output matches the output of the dsp.NCO System object™.

When selected, the reset port is present on the block icon. When reset is high, the block resets the accumulator to zero.

When selected, the validIn port is present on the block icon. When validIn is true, the block increments the phase. When validIn is false, the phase is held.

If you select Complex exponential, the output is of the form sine + j*cosine and the port is labeled exp. If you select Sine and cosine, the block shows two ports, sin and cos.

Output the current phase of the accumulator when selected.

Data Types

Overflow mode for fixed-point operations. Overflow mode is a constant property. Fixed-point numbers wrap around on overflow.

Rounding mode for fixed-point operations. Rounding Mode is a constant property with value Floor.

Accumulator data type description. This property is a constant with value Binary point scaling. The accumulator sign, word length, and fraction length are taken from the following three properties.

This property is a constant. All output is signed format.

Accumulator word length, in bits, specified as a scalar integer.

Accumulator fraction length, in bits, specified as a scalar integer.

Specify the output signal data type. If you select Binary point scaling, the output sign, word length, and fraction length are taken from the following three properties.

This property is a constant. All output is signed format.

Output word length, in bits, specified as a scalar integer.

Output fraction length, in bits, specified as a scalar integer.

Algorithms

expand all

See Also

|

Introduced in R2013a

Was this topic helpful?