xSTreamC default filter templates
The xSTreamC
compiler provides a default set of predefined filters that can be freely used in code.
Additionally these same filters, will be leveraged for the default definition of
a splitter, joiner or other implicit filter instances
This filter performs a roundrobin selection of all input and output queues.
For example, a filter with 2 inputs a & b and 3 output A, B & C
would work in the following way:
input queues | | output queues |
|
|
|
It can
stop asymetrically, like in the example above, if not enough
data (for input queues) or space left (for output queues) is available . (A
symetrical implementation wouldn’t have pushed the ‘4’ on the ouput queue A).
see the implementation of roundrobin splitter/joiner.
This filter clones data from the input queue by pushing it ontp all output queues
This filter selects an output queue. The remaining ones will not receive data.
It takes as argument the selected output queue.
Symetrically, this one selects one input queue for data input
It takes as argument the selected input queue.
This is the most simple filter you can think of ! It just reads from an input queue and sends the same data onto the output queue.
Here is one example, using template syntax place holders...
filter roundrobin()
{
int i,j;
init {
i=0;
j=0;
}
work {
generic data;
data = pop(i);
push(data, j);
j++;
if(j == @NB_QUEUES_OUT@)
{
j=0;
i++;
i %= @NB_QUEUES_IN@;
}
peek(0, i); /* Peek next in queue */
}
}