Instant SoC Class Library  3.1
FC_IO_StreamSlave Class Reference

AXI4 Stream Slave. More...

Inheritance diagram for FC_IO_StreamSlave:
FC_Base

Public Member Functions

 FC_IO_StreamSlave (int width, int fifo_depth=1)
 Construct a new fc io streamslave object. More...
 
int NumValid ()
 Number of words ready to be read in the receive FIFO. More...
 
bool Read (U32 &d)
 Read one word from the FIFO. More...
 
U32 Read ()
 

Detailed Description

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.

// 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);
}
}
}

Constructor & Destructor Documentation

◆ FC_IO_StreamSlave()

FC_IO_StreamSlave::FC_IO_StreamSlave ( int  width,
int  fifo_depth = 1 
)
inline

Construct a new fc io streamslave object.

Parameters
widthThe stream word width in bits
fifo_depthThe receive FIFO depth in number of words. Typically power of 2: 8, 16, 32, etc.

Member Function Documentation

◆ NumValid()

int FC_IO_StreamSlave::NumValid ( )
inline

Number of words ready to be read in the receive FIFO.

Returns
int

◆ Read()

bool FC_IO_StreamSlave::Read ( U32 &  d)
inline

Read one word from the FIFO.

Parameters
dThe word read if successful
Returns
true Read ok
false Read failed. No words in the FIFO.
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