CodeSpriteEmbedded software consultancy
specializing in
ARM Powered systems
HomeSite MapClientsContact
Search this site 
powered by FreeFind

Optimization Case Studies

Notch Filter

The raw code supplied to CodeSprite was a notch filter written in ARM assembly language. It was fully functional, and was a distinct improvement on the equivalent code written in C. However, it took 22 microseconds out of a total interrupt-interval budget of approximately 55 microseconds.

We noticed that the filter spent a lot of time shuffling input history values out of and into memory, although there was a high level of data re-use between stages of the filter. The first step was to create a data-movement map to track all the values going into the filter, and to watch where generated values were placed back into the history list.

When the data movement map was complete, we were able to devise a register-usage scheme that kept all the history values in registers, reusing retired history value registers to hold generated values. The most difficult part of this scheme was to ensure that at the end of all four oversampling stages, the data in the registers was in the correct order to be written back into memory with a single Store Multiple register instruction.

Additional optimizations, including use of some of the more esoteric instructions available in ARM architecture 5TE allowed us to bring the total execution time for the function down to less than 5 microseconds.

The newly-available processing time allowed the filter to be extended to another stage of oversampling, and the addition of feed-forward functionality from one notch to the next, without putting an undue burden on the total processing budget.