We offer training classes and eBooks on DSP, and in Media Processing (TriMedia) Company logo

Introduction to DSP - Programming DSPs: real time

Both the naive FIR filter program and its more efficient version assume we can access the whole array of past input values repeatedly:

FIR filter program

But this is not the case in real time. Real time systems face a continuing stream of input data: often, they have to operate on one input sample at a time and generate one output sample for each input sample:

Real time processing

A similar restriction is likely if the filter program is implemented as a subroutine or function call. Only the current input and output are available to the filter so the filter function itself has to maintain some history of the data and update this history with each new input sample. Management of the history takes up some processing time.

The filter needs to know the most recent [N] input samples. So the real time filter has to maintain a history array, which is updated with each new input sample by shifting all the history data one location toward 0:

History array

The necessary updating of the history array involves simply adding two extra lines to the C program, to implement the array shifting:

Updating history array

The pointer to previous input samples, *x_ptr, is replaced by a pointer to the history array, *hist_ptr.A new pointer, *hist1_ptr, is initialised to point one further down the history array and is used in the shifting of data down the array.

The two extra lines of C code represent extra computation: actually, the filter now takes two lines of C code instead of one for the inner loop.

backward/forward go back to start of module go back to previous page go to next page go to next module