Agc real (agc_real)

agc_real is an asset in the ocpi.assets.util_comps component library. Implementations include agc_real HDL Worker (agc_real.hdl). Tested platforms include e310, xsim, zed.

Design

The Automatic Gain Control (AGC) Real component inputs real signed samples, drives the amplitude of the input data to a reference level, and outputs real signed samples.

image

A block diagram representation of the implementation is given in Figure 157:

agc_real block diagram.

Figure 157: agc_real block diagram.

Theory

The circuit is based upon Richard G. Lyons’ “Understanding Digital Signal Processing, Third Edition” Automatic Gain Control (AGC) circuit found on Page 783. The text may also be found online here: DSP-Tricks-AGC 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

<!-- This is the spec file (OCS) for: agc_real
     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" producer="false" protocol="rstream_protocol"></Port>
    <Port name="out" producer="true" protocol="rstream_protocol"></Port>
</ComponentSpec>

Properties

None.

Ports

Inputs:

  • in

    • Protocol: rstream_protocol

    • Optional: False

Outputs:

  • out

    • Protocol: rstream_protocol

    • Optional: False

Implementations

Dependencies

The dependencies to other elements in OpenCPI are:

  • assets/components/util_comps/agc_real.hdl/agc_real.vhd

  • assets/hdl/primitives/util_prims/util_prims_pkg.vhd

  • assets/hdl/primitives/util_prims/agc/src/agc.vhd

Limitations

Limitations of agc_real are:

  • None.

Testing

A single test case is implemented to validate the AGC Real 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 real waveform is then scaled to fixed-point signed 16-bit integers. Time and frequency domain plots may be viewed in Figure 158: and Figure 159: below, respectively.

Time Domain Tone

Figure 158: Time Domain Tone

Frequency Domain Tone

Figure 159: Frequency Domain Tone

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 real 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. Figure 160: and Figure 161: depict the output of the AGC Real worker.

Time Domain Tones with AGC

Figure 160: Time Domain Tones with AGC

Frequency Domain Tones with AGC

Figure 161: Frequency Domain Tones with AGC