Peak Detector (peak_detector)
Design
The Peak Detector worker utilizes the OCPI iqstream protocol for both input and output ports. The iqstream protocol defines an interface of 16-bit complex signed samples. The worker calculates the maximum and minimum peaks of the I/Q data arriving at its input port, and passes the input data through to the output port. The Peak Detector worker uses two local variables to keep track of the maximum and minimum peak amplitudes. To ensure the peaks are detected correctly, the variable used to keep track of the maximum peak is initialized to the most negative value represented in a signed 16-bit number (-32768), and the minimum peak is initialized to the most positive value represented in a signed 16-bit number (32767). Upon completion, the Peak Detector returns the most positive I or Q sample value with the max_peak property and the most negative with the min_peak property. This is not the value of the vector represented by I and Q, but simply the max/min value of the I and Q samples taken independently.
Interface
<?xml version="1.0"?>
<!-- This is the spec file (OCS) for: peak_detector
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="min_peak" type="short" volatile="true" description="Minimum peak value"/>
<property name="max_peak" type="short" volatile="true" description="Maximum peak value"/>
<port name="in" protocol="iqstream_protocol" producer="false"/>
<port name="out" protocol="iqstream_protocol" producer="true"/>
</componentspec>
Opcode Handling
None
Properties
min_peak: Minimum peak value.Type:
shortAccess:
Parameter:
FalseWritable:
FalseInitial:
FalseVolatile:
True
Default value:
None
max_peak: Maximum peak value.Type:
shortAccess:
Parameter:
FalseWritable:
FalseInitial:
FalseVolatile:
True
Default value:
None
Ports
Inputs:
in: signed complex samples.Protocol:
iqstream_protocolOptional:
False
Outputs:
out: signed complex samples.Protocol:
iqstream_protocolOptional:
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="peak_detector" name="in"/>
</connection>
<instance component="ocpi.tutorial.peak_detector" 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 peak detector component. An input file is generated generate.py containing complex signed 16-bit samples with a tone at 13 Hz. The input data is passed through the
worker, so the output file should be identical to the input file. The worker measures the minimum and maximum
amplitudes found within the complex data stream. These values, reported as properties, are compared with
min/max calculations performed during verification verify.py.
Figure 254: Time Domain and Frequency Domain Plots
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 the minimum and maximum values are calculated from the file and then compared with the UUT reported values.
Testing
Tested platforms: None