AXI4 Stream Slave.
Adds to interface:
<name>_Data : in std_logic_vector(width-1 downto 0)
<name>_Valid : in std_logic
<name>_Ready : out std_logic
where <name> is c++ object name.
Any number of instances are allowed.
#include "fc_io.h"
#include "fc_system.h"
int main()
{
const int n_avg = 10;
int buff[n_avg];
for( int i=0; i<n_avg; i++ )
buff[i] = 0;
int ix = 0;
int sum = 0;
for (;;)
{
if( ss.NumValid() > 0 && sm.NumReady() > 0 ) {
sum -= buff[ix];
buff[ix] = ss.Read();
sum += buff[ix];
ix++;
if(ix == n_avg)
ix = 0;
sm.Write(sum/n_avg);
}
}
}