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).

(3)\[y[n] = \frac{\sum_{i=0}^{\alpha-1}x[n+i]}{\alpha}\]

In (3):

  • \(\alpha\) is the length property 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: long

    • Access:

      • Parameter: False

      • Writable: False

      • Initial: True

      • Volatile: False

    • Default value: 32

Ports

Inputs:

  • input

    • Protocol: short_timed_sample-prot

    • Optional: False

Outputs:

  • output_average

    • Protocol: short_timed_sample-prot

    • Optional: False

  • output_sample

    • Protocol: short_timed_sample-prot

    • Optional: True

Implementations

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.