This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country 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. The block uses the same phase accumulation and lookup table algorithm as implemented in the NCO block. When you use integer or fixed-point input signals, or use the block as a source with no input signal, the block uses quantized integer accumulation to create a sinusoid signal.

The NCO HDL Optimized block provides these features:

  • 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 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 parameter or an input port.

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 parameter or an input port.

When you use floating-point input signals, the block does not quantize the accumulation. Therefore, you must choose increment and offset values to represent a fraction of 2π without quantization, see Compute Floating-Point Phase Increment for NCO HDL Optimized.

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 the optional ports of the NCO HDL Optimized block.

Input

expand all

Phase increment, specified as a scalar integer. If the increment is a fixed-point value, the block uses only the integer bits and ignores any fractional bits. double and single data types are supported for simulation but not for HDL code generation. When you use floating-point input signals, you must choose increment and offset values to represent a fraction of 2π, see Compute Floating-Point Phase Increment for NCO HDL Optimized.

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. If the offset is a fixed-point value, the block uses only the integer bits and ignores any fractional bits. double and single data types are supported for simulation but not for HDL code generation. When you use floating-point input signals, you must choose increment and offset values to represent a fraction of 2π, see Compute Floating-Point Phase Increment for NCO HDL Optimized.

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 data types are supported 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)

Control signal that resets the accumulator, specified as a scalar boolean. When this signal is true (1), the block resets the accumulator to 0.

Dependencies

To enable this port, select Enable reset input port.

Data Types: Boolean

Control signal that enables NCO operation. When this signal is true (1), the block increments the phase. When this signal is false (0), the block holds the phase.

Dependencies

To enable this port, select Enable valid input port.

Data Types: Boolean

Output

expand all

Generated waveform, returned as a scalar sin or cos value, as a scalar exp value representing sine + j*cosine, or as two values, sin and cos. If any input is floating-point type, the block returns floating-point values, otherwise the block returns fixed-point values. Floating point types are supported for simulation but not for HDL code generation.

Dependencies

By default, this output port is a sine wave, sin. The port label and format changes 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 block returns phase as floating point if the input to the block is a floating point. Floating-point types are supported for simulation but not for HDL code generation.

Dependencies

To enable this port, select Enable phase port.

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

Control signal that indicates whether the other output port values are valid or not. When validOut is true (1), the values on the sin, cos, exp, and phase ports are valid. When validOut is false (0), the values on the output ports are not valid.

Data Types: Boolean

Parameters

expand all

Main

Note

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

To use the data type override feature of Fixed-Point Designer™, you can obtain a double output value by applying double input data to one of the optional ports. 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 Compute Floating-Point Phase Increment for NCO HDL Optimized.

You can set the phase increment with an input port or by entering a value for the parameter. If you select Property, the Phase increment parameter appears for you to enter a value. If you select Input port, the inc port appears on the block.

Phase increment for the generated the waveform, specified as a scalar integer. If the increment is a fixed-point value, the block uses only the integer bits and ignores any fractional bits. double and single data types are supported for simulation but not for HDL code generation. When you use floating-point input signals, you must choose increment and offset values to represent a fraction of 2π, see Compute Floating-Point Phase Increment for NCO HDL Optimized.

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 with an input port or by entering a value for the parameter. If you select Property, the Phase offset parameter appears for you to enter a value. If you select Input port, the offset port appears on the block.

Phase offset for the generated waveform, specified as a scalar integer. If the increment is a fixed-point value, the block uses only the integer bits and ignores any fractional bits. double and single data types are supported for simulation but not for HDL code generation. When you use floating-point input signals, you must choose increment and offset values to represent a fraction of 2π, see Compute Floating-Point Phase Increment for NCO HDL Optimized.

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 parameter is visible when you set Dither source to Property.

When this parameter is enabled, the block quantizes 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 parameter.

The frequency resolution of an NCO is defined by

Δf=1Ts2NHz

When you disable this parameter, the block uses the full accumulator data type as the address of the lookup table.

Number of quantizer accumulator bits, specified as an integer scalar greater than 1 and less than the accumulator word length. This parameter must be less than or equal to 17 bits for HDL code generation. The lookup table of sine values has 2NumQuantizerAccumBits-2 entries.

Dependencies

This parameter is visible when you select Quantize phase.

By default, the block implements a compressed lookup table. The Sunderland compression method reduces the size of the lookup table, losing less than one LSB of precision. The spurious free dynamic range (SFDR) is empirically 1–3 dB lower than the noncompressed case. The hardware savings of the compressed lookup table allow room to improve performance by increasing the word length of the accumulator and the number of quantize bits. For detail of the compression method, see Algorithms.

When this option is disabled, the output of this block matches the output of the NCO block.

When selected, the reset port appears on the block. When reset is true (1), the block resets the accumulator to zero.

When selected, the validIn port appears on the block. When validIn is true (1), the block increments the phase. When validIn is false (0), the phase is held.

If you select Sine or Cosine, the block shows the applicable port, sin or cos. 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 read-only parameter. Fixed-point numbers wrap around on overflow.

Rounding mode for fixed-point operations. Rounding Mode is a read-only parameter with value Floor.

Accumulator data type description. This parameter is read-only, with value Binary point scaling. The block defines the fixed-point data type using the Accumulator Signed, Accumulator Word length, and Accumulator Fraction length parameters.

This parameter is read-only. All output is signed format.

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

If Quantize phase is disabled, this parameter must be less than or equal to 17 bits for HDL code generation.

This parameter is read-only. The accumulator fraction length is zero bits.

The accumulator operates on integers. If the phase increment is fixdt type with a fractional part, the block ignores the fractional part.

Specify the output signal data type. If you select Binary point scaling, the block defines the fixed-point data type using the Output Signed, Output Word length, and Output Fraction length parameters.

This parameter is read-only. 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.

Block Characteristics

Data Types

fixed point | integer

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Algorithms

expand all

The NCO implementation depends on whether you select Enable look up table compression method.

Without lookup table compression, the block uses the same quarter-sine lookup table as the NCO block. The size of the LUT is 2Number of quantizer accumulator bits-2×Output word length bits.

If you do not enable Quantize phase, then Number of quantizer accumulator bits=Accumulator Word length. Consider the impact on simulator memory and hardware resources when you select these parameters.

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.

Extended Capabilities

Introduced in R2013a