Moving Average (moving_average_s)
Calculates the average from the input data over a moving window of values.
Design
A window of size length is used to calculated the average of an incoming data stream.
The mathematical representation of the implementation is given in (3).
In (3):
\(\alpha\) is the
lengthproperty value.\(x[n]\) is the input values.
\(y[n]\) is the output values.
Interface
<?xml version="1.0"?>
<componentspec>
<port name="input" protocol="short_timed_sample-prot"/>
<port name="output_average" protocol="short_timed_sample-prot" producer="true"/>
<port name="output_sample" protocol="short_timed_sample-prot" producer="true" optional="true"/>
<property name="length" type="long" initial="true" default="32"
description="Number of samples to average."/>
</componentspec>
Opcode Handling
All opcodes excluding samples are passed directly through the worker.
Properties
length: Number of samples to average.Type:
longAccess:
Parameter:
FalseWritable:
FalseInitial:
TrueVolatile:
False
Default value:
32
Ports
Inputs:
inputProtocol:
short_timed_sample-protOptional:
False
Outputs:
output_averageProtocol:
short_timed_sample-protOptional:
False
output_sampleProtocol:
short_timed_sample-protOptional:
True
Implementations
moving_average_s(HDL)
Example Application
<?xml version="1.0"?>
<application done="file_write">
<instance component="ocpi.core.file_read" connect="moving_average_s">
<property name="filename" value="input.bin"/>
</instance>
<instance component="ocpi.examples.components.moving_average_s" connect="file_write">
<property name="length" value="32"/>
</instance>
<instance component="ocpi.core.file_write">
<property name="filename" value="output.bin"/>
</instance>
</application>
Dependencies
The dependencies to other elements in OpenCPI are:
None
There is also a dependency on:
ieee.std_logic_1164
ieee.numeric_std
Limitations
Limitations of moving_average_s are:
None
Testing
Tested platforms: None
Component testing not completed.