Carrier Generator (carrier_generator)

A numerically controlled oscillator (NCO) for generating complex sinusoidal signals.

Design

This component is the equivalent of carrier_generator_xs component within OpenCPI SDR Components Library (ocpi.comp.sdr) .

Generates a complex stream of shorts which are the sine and cosine waves, with both the amplitude and frequency of the output wave settable.

The mathematical representation of the implementation is given in (1).

(1)\[y[n] = A \cos{\left(2 \pi \frac{\delta}{2^{32}} n \right)} + j A \sin{\left(2 \pi \frac{\delta}{2^{32}} n \right)}\]
\[\]

In (1):

  • \(x[n]\) is the input values.

  • \(y[n]\) is the output values.

  • \(A\) is the output amplitude.

  • \(\delta\) controls the frequency of the output wave, and is set by the step_size property.

The relation between the output frequency and \(\delta\) is given by (2).

The mathematical representation of the implementation is given in (1).

(2)\[ \delta = \frac{2^{32} f}{F_s}\]

In (1):

  • \(f\) is the desired output frequency

  • \(F_s\) is the sample rate of the system.

  • \(\delta\) is the value same as set in (1).

Interface

<componentspec>
  <property name="enable" type="bool" writable="true" default="true" description="When true an output carrier wave is generated. When false the component output is disabled."/>
  <property name="step_size" type="long" writable="true" default="0" description="Sets the step size of the carrier generator which determines the output frequency. step_size = (desired_freq*2^32)/sample_rate"/>
  <property name="carrier_amplitude" type="ushort" writable="true" default="19872" description="Sets the amplitude of the output carrier signal. Set to floor(desired_amplitude/1.646760258)."/>
  <property name="discontinuity_on_step_size_change" type="bool" writable="true" default="false" description="Sends a discontinuity message at the point the step size changes at the output."/>
  <property name="discontinuity_on_carrier_amplitude_change" type="bool" writable="true" default="false" description="Sends a discontinuity message at the point the carrier amplitude changes at the output."/>
  <property name="message_length" type="ushort" writable="false" initial="true" default="512" description="Sets the output message length. Must not be 0."/>
  <port name="output" producer="true" protocol="complex_short_timed_sample-prot"/>
</componentspec>

Ports

Inputs:

None.

Outputs:

  • output: Primary output samples port.

    • Protocol: complex_short_timed_sample-prot

    • Optional: False

Properties

  • enable: When true an output carrier wave is generated. When false the component output is disabled.

    • Type: bool

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: true

  • step_size: Sets the step size of the carrier generator which determines the output frequency. step_size = (desired_freq*2^32)/sample_rate.

    • Type: long

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: 0

  • carrier_amplitude: Sets the amplitude of the output carrier signal. Set to floor(desired_amplitude/1.646760258). Should not be set to greater than 19,872, as this has a safety margin under the maximum of the short output values - this value maps to near full range output on a 16-bit signed value.

    • Type: ushort

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: 19872

  • discontinuity_on_step_size_change: Sends a discontinuity message at the point the step size changes at the output. The discontinuity is sent directly after the last output sample generated using the previous step size is sent.

    • Type: bool

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: false

  • discontinuity_on_carrier_amplitude_change: Sends a discontinuity message at the point the carrier amplitude changes at the output. The discontinuity is sent directly after the last output sample generated using the previous carrier amplitude values is sent.

    • Type: bool

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: false

  • message_length: Sets the output message length. Must not be 0.

    • Type: ushort

    • Access:

      • Parameter: False

      • Writable: False

      • Initial: True

      • Volatile: False

    • Default value: 512

Implementations

Example Application

<?xml version="1.0"?>
<application done="file_write">
  <instance component="ocpi.comp.sdr.generator.carrier_generator" connect="file_write">
    <property name="enable" value="true"/>
    <property name="step_size" value="150000"/>
    <property name="carrier_amplitude" value="19872"/>
  </instance>
  <instance component="ocpi.core.file_write">
    <property name="filename" value="output.bin"/>
  </instance>
</application>

Dependencies

The dependencies to other elements in OpenCPI are:

There is also a dependency on:

  • ieee.std_logic_1164

  • ieee.numeric_std

  • ieee.math_real

Limitations

Limitations of carrier_generator_xs are:

  • Setting of carrier_amplitude above 19,872 is untested behaviour and will result in unpredictable behaviour. At low carrier amplitude values (100 or less) the error from a true carrier becomes a significant proportion of the output signal magnitude.

  • Setting of message_size above ocpi_max_bytes_output/sample_size_bytes is unsupported behaviour.