Max Filter
/*
This example is a simple hardware module that determines the maximum of
three inputs. This example shows the supported use of if statements
in ROCCC.
*/
void MAX(int A0_in, int A1_in, int A2_in, int& max_out)
{
int tmp1 ;
if (A0_in > A1_in)
{
tmp1 = A0_in ;
}
else
{
tmp1 = A1_in ;
}
if (tmp1 > A2_in)
{
max_out = tmp1 ;
}
else
{
max_out = A2_in ;
}
}
Description
The C code for the Max filter is shown above. If, else if, and else statements can be used to control the flow of logic just like it is done in the C language. As long as the conditional expression is purely a boolean expression that may use the bitwise AND and OR operators, (& and | respectively), then ROCCC will compile the desired behavior into VHDL.