AGC Complex (agc_complex)

Automatic Gain Control (AGC)

Design

The AGC Complex component inputs complex signed samples, drives the amplitude of both I and Q input rails to a reference level, and outputs complex signed samples.

MATLAB AGC implementation

Figure 252: MATLAB AGC implementation with ref=0x1B26 and mu=0x144E

The circuit is based upon Richard G. Lyons’ “Understanding Digital Signal Processing, Third Edition” Automatic Gain Control (AGC) circuit found on Page 783. Lyons’ circuit in Figure 13-76a implements the AGC function with a feedback loop on y(n) that consists of a magnitude operation to remove the sign, a comparator against the reference level “ref”, a multiplier that uses “mu” to control the amplitude of the feedback signal (and thus the response time), and finally an accumulator. This implementation uses a peak detector in place of Lyons’ simple magnitude operation. From Lyons: “The process is a nonlinear, time-varying, signal-dependent feedback system. As such, it’s highly resistant to normal time-domain or z-domain analysis. This is why AGC analysis is empirical rather than mathematical …

Interface

<?xml version="1.0"?>
<!-- This is the spec file (OCS) for: agc_complex
     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 -->
  <port name="in" protocol="iqstream_protocol" producer="false"/>
  <port name="out" protocol="iqstream_protocol" producer="true"/>
</componentspec>

Opcode Handling

None

Properties

None.

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="agc_complex" name="in"/>
  </connection>
  <instance component="ocpi.tutorial.components.agc_complex" 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

None.

Testing and Verification

A single test case is implemented to validate the AGC Complex component. An input file is generated with a single tone at Fs/16 Hz, where Fs = 100 Hz, but applies 20% of the maximum amplitude to the first quarter of the file, 90% maximum amplitude to the second quarter of the file, 20% maximum amplitude to the third quarter of the file, and 30% maximum amplitude to the fourth quarter of the file. The complex waveform is then scaled to fixed-point signed 16-bit integers. Time and frequency domain plots may be viewed in figures below, respectively.

AGC Complex Test and Verification

Figure 253: Time Domain and Frequency Domain Plots

For verification, the output file is first checked that the data is not all zero, and is then checked for the expected length of 32,768 complex samples. Once these quick checks are made a floating-point python implementation of the AGC is performed on the input data, which is then compared sample-by-sample to the output data. Figures 4 and 5 depict the output of the AGC Complex worker.

Testing

Tested platforms: None