Complex Mixer Tutorial (complex_mixer)

Design

The Complex Mixer consists of a Numerically Controlled Oscillator (NCO) and a complex multiplier. Complex IQ data is received on the input port and is multiplied with the output of the NCO and put on the output port.

The Complex Mixer worker inputs complex signed samples and performs a complex multiply with a digital sine wave produced by an numerically controlled oscillator (NCO). The resulting output data is a frequency shifted version of the input data. The magnitude of the frequency shift is determined by the output frequency of the NCO, which can be calculated with the following equation:

(14)\[nco\_output\_freq = sample\_freq * \frac { phs\_inc }{ 2^{phs\_acc\_width} }\]

In (14):

  • \(phs\_inc\) is runtimem configuration and has a data type of 16 bit signed short.

  • \(phs\_acc\_width\) is fixed at 16

The input clock frequency is the sample rate of the samples. The amplitude of the NCO’s sine wave is fixed at the full range of a signed 16 bit value.

The control properties for all implementations provide the ability to enable(or bypass) the worker and set the tune frequency via phs inc.

Interface

<?xml version="1.0"?>
<!-- This is the spec file (OCS) for: complex_mixer
     Add component spec attributes, like "protocol".
     Add property elements for spec properties.
     Add port elements for i/o ports -->
<componentspec>
  <!-- Add property and port elements here -->
  <property name="enable" type="bool" writable="true" default="true" description="Enable(true) or Bypass(false) mixer"/>
  <property name="phs_inc" type="short" writable="true" default="8192" description="Phase increment of NCO"/>
  <port name="in" protocol="iqstream_protocol" producer="false"/>
  <port name="out" protocol="iqstream_protocol" producer="true"/>
</componentspec>

Opcode Handling

None

Properties

  • enable: Enable(true) or Bypass(false) mixer.

    • Type: bool

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: true

  • phs_inc: Phase increment of NCO.

    • Type: short

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: 8192

Ports

Inputs:

  • in: signed complex samples.

    • Protocol: iqstream_protocol

    • Optional: False

Outputs:

  • out: signed complex samples.

    • Protocol: iqstream_protocol

    • Optional: False

Implementations

Example Application

<?xml version="1.0"?>
  <instance component="ocpi.core.file_read" name="file_read">
    <property name="filename" value="input_samples.bin"/>
  </instance>
  <connection>
    <port instance="file_read" name="out"/>
    <port instance="complex_mixer" name="in"/>
  </connection>
  <instance component="ocpi.tutorial.components.complex_mixer" connect="file_write"/>
  <instance component="ocpi.core.file_write">
    <property name="filename" value="output.bin"/>
  </instance>
</application>

Dependencies

There is also a dependency on:

  • ieee.std_logic_1164

  • ieee.numeric_std

  • ieee.math_real.all

Limitations

The Complex Mixer HDL worker uses the clock from the Control Plane and standard Control Plane signals.

There is a startup delay for this worker. Once the input is ready and valid and the output is ready, there is a 6 clock cycle start delay (pipeline delay of complex multiplier). After this startup delay, valid output data is given 6 clock cycles after input data is taken.

Testing and Verification

Test cases are derived from the number of properties, and their respective values, as listed in the complex mixer-test.xml.

  1. Bypass (RCC & HDL): The input data is forwarded to the output port. For verification of this case, the output file is byte-wise compared to the input file.

  2. Normal mode (RCC & HDL): The NCO is configured to tune the input signal to baseband. For verification, an FFT of the output data is performed and the max value of the FFT is checked to be at DC (0 Hz).

For all cases, the input file contains a tone of 12.5 Hz sampled at 100 Hz and an amplitude of 32767.

Testing

Tested platforms: None