Instant SoC Class Library  3.1
FC_IO_StreamMaster Class Reference

AXI4 Stream master. More...

Inheritance diagram for FC_IO_StreamMaster:
FC_Base

Public Member Functions

 FC_IO_StreamMaster (U32 width, int fifo_depth=1)
 
U32 Status ()
 
int NumReady ()
 Number of that can be written to this stream.
 
void Write (const U32 d)
 

Detailed Description

AXI4 Stream master.

Adds to interface:
<name>_Data : out std_logic_vector(width-1 downto 0)
<name>_Valid : out std_logic
<name>_Ready : in std_logic
where <name> is c++ object name.
Any number of instances are allowed.

// This example shows how to use the FC_IO_StreamMaster and FC_IO_StreamSlave classes.
// This application calculates the moving average on 10 consecutive samples
// that is read from the stream slave. The result is streamed out to the stream master
#include "fc_io.h"
#include "fc_system.h"
int main()
{
//% hw_begin
FC_IO_Clk clk(100);
//% hw_end
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);
}
}
}
FC_IO_StreamSlave
AXI4 Stream Slave.
Definition: fc_io.h:297
FC_IO_Clk
System clock input.
Definition: fc_io.h:55
FC_IO_StreamMaster
AXI4 Stream master.
Definition: fc_io.h:265