User manual
Tutorial: Using the logic estimator
/*
* Structure of variables to interface to FIR filter
*/
struct _FirStruct
{
unsigned 1 InputValid;
unsigned 1 OutputValid;
signed Input;
signed Output;
signed Coeffs[];
};
typedef struct _FirStruct FirStruct;
There are then prototypes for the FIR macro procedures:
macro proc FirFilter (FirPtr, DataWidth, Taps, CoeffList);
macro proc FirWrite (FirPtr, Data);
macro proc FirRead (FirPtr, DataPtr);
The
FirWrite and FirRead macros are shown below. The FirWrite macro passes data into the
FIR interface structure and sets the valid bit to notify the FIR that new data is available. The
FirRead
macro waits until the FIR interface indicates that valid output data is present, then it reads this data from
the interface and passes it back in
DataPtr.
macro proc FirWrite (FirPtr, Data)
{
/*
* Write data to FIR interface
*/
par
{
FirPtr->Input = Data;
FirPtr->InputValid = 1;
}
}
macro proc FirRead (FirPtr, DataPtr)
{
/*
* Read from FIR interface until we get a valid output
*/
do
{
*DataPtr = FirPtr->Output;
}while(FirPtr->OutputValid == 0);
/*
* Reset Output Valid
*/
FirPtr->OutputValid = 0;
}
www.celoxica.com
Page 102