User manual

PAL tutorial
FIRFilter (FIRPortH2S, FIRPortS2H);
DsmVideo (VideoPortS2H, VideoPortH2S, VideoPL1RAM,
PAL_ACTUAL_CLOCK_RATE);
}
DSM FIR filter tutorial: hardware side
The Handel-C code for the DSM FIR filter tutorial can be opened from Start>Programs>Celoxica>Platform
Developer's Kit>DSM>DSM Examples Workspace [DK].
FIR Filter implementation
The main task of the filter is to take input data and operate on it, and to provide results from operations
on earlier input data.
The data value is the only thing sent from the software side to the FIR filter. The software side and the
hardware side are connected together through a DSM S2H port.
The FIR filter is implemented in the
filterlib.hcl library. It is a symmetrical type filter; the
coefficients are symmetrical, so only half of them need be specified, rounded up if there are an odd
number. e.g. {1,1,0,0,1,1} would be {1,1,0}, and {1,1,0,0,0,1,1} would be {1,1,0,0}.
To use the filter, you need to include
filterlib.hch. This is done at the beginning of the source file
dsm_fir.hcc. Then the dsm_fir.h header file is included. This is shared between hardware and
software sides, and defines coefficients for the FIR filter and type of the filter. If you want to build a
highpass filter you need to define the
HIGHPASS preprocessor macro (#define HIGHPASS) in this
header file. If the macro is not defined the default is a lowpass filter.
The
FIRFilter() macro reads data from the DSM S2H port and stores it in the variable input. The
value of
Input is then written to the FIR filter and processed. The new result available from the filter is
then sent to the DSM H2S port.
The ports are read and written with the
DsmRead() and DsmWrite() macros, e.g.:
macro proc FIRFilter (PortH2S, PortS2H)
{
unsigned Input;
signed (PFirSIResultWidth (DATAWIDTH, TAPS)) Output;
par
{
/* Run the input and output FIR ports */
DsmPortS2HRun (PortS2H);
DsmPortH2SRun (PortH2S);
PFirSIRun (&myFIR, DATAWIDTH, TAPS, Coeffs, EXTRA_REGS);
while (1)
{
seq
{
/* Read sample from DSM */
DsmRead (PortS2H, &Input);
/* Enable FIR Filter */
PFirSIEnable (&myFIR);
par
{
/* Write new sample to the filter */
PFirSIWrite (&myFIR, (signed)Input<-DATAWIDTH);
PFirSIRead (&myFIR, &Output);
PFirSIDisable (&myFIR);
}
DsmWrite (PortH2S,
www.celoxica.com
Page 20