# Housekeeping operations in filters

I have to implement a second order filter in DF1 or DF2. I should avoid housekeeping operations by suitable addressing strategies.

I don't understand what "housekeeping operations" means. Anyone could help me or propose a source i can find more information?

EDIT :

I use DF2 for the second-order filter: As pichenettes proposes with Housekeeping the code in matlab is something like:

%x=input sample
%state=containing old input values
%compute output value
y=b(1)*x+state(2)

%Update states
state(2)=b(2)*x-a(2)*y+state(1)
state(1)=b(3)*x-a(3)*y


Without Housekeeping is going to be like:

%compute output value
y=b(1)*x+state(pointer+1);
pointer=rem(pointer+1,N-1); %increment pointer in modulo form, N number of taps

%Update states
state(pointer+1)=b(2)*x-a(2)*y+state(pointer+1);
pointer=rem(pointer+1,N-1);

%Overwrite oldest sum with b(N-1).x
state(pointer+1)=b(3)*x-a(3)*y;
pointer=rem(pointer+1,N-1);%Increment pointer modulo-(N-1)


Is that right?Any mistakes?

• I don't think that's it. Your second example uses a circular buffer that really isn't required. Your first example is already "housekeeping" free since it doesn't contain a statement like state(2) = state(1), that implements the delay line by shuffling variables. In practice you would NOT implement the state as an array but as individual variables that are kept in registers – Hilmar Apr 16 '13 at 22:57

First, maybe you could give us more context (is that homework?).

I think that what is meant by "housekeeping operations" are the data transfers between registers / state variables ("delay propagation") that naturally arise when naively implementing filters. For example, a naive implementation of a 4-tap FIR would look like this:

output = h * input + h * x + h * x + h * x
// "Housekeeping" operations
x = x
x = x
x = input


The data transfers operations can be avoided on some hardware architectures (especially DSP) by using modulo addressing. I think this is what is meant by "suitable addressing strategies".

• Thank you, i think i understand the concept. If the edit i make is correct... – 20317 Apr 16 '13 at 19:06
• It looks like you're on the right track (I haven't checked the details) - It's a strange exercise though to do this kind of things in matlab. You should see the benefits more clearly when writing this in the assembly language of a DSP of your choice - in which each data access / multiplication / accumulation is done in a single instruction, with all the modulo arithmetic handled automatically by the address generation unit (AGU) rather than performed explicitly by the ALU. – pichenettes Apr 16 '13 at 21:25