SpinalHDL
1 / 1
Description
Moving Average
Design a hardware module for the Moving Average problem.
Given an input stream and a window size n, output the integer moving average for each contiguous window of length n.
Use floor division for the average.
Hardware I/O Encoding
streamis a one-dimensional stream of unsigned 13-bit integersnis a scalar unsigned 5-bit integer- the output is a one-dimensional stream of unsigned 13-bit integers
- output element
iis the average of input elementsithroughi + n - 1
Examples
Example 1
- input
stream = [10, 20, 30, 40, 50],n = 3 - output:
[20, 30, 40]
Example 2
- input
stream = [8, 4, 2],n = 2 - output:
[6, 3]
Input
stream
Stream of 13-bit Unsigned Integer (up to 300 elements)Input sample stream.
n
5-bit Unsigned IntegerWindow size.
Output
Stream of 13-bit Unsigned Integer
Floor of the average over each contiguous window of size n.