Академический Документы
Профессиональный Документы
Культура Документы
January 6, 2016
http://barrgroup.com/training-calendar
3 Copyright 2015 Barr Group. All rights reserved.
E-mail: njones@barrgroup.com
4 Copyright 2015 Barr Group. All rights reserved.
INTRODUCTION
§ Cheaper hardware.
§ Lower energy consumption.
§ Better user experience.
§ Personal satisfaction.
§ Do it in hardware
§ If you have to do it in firmware, then
§ Choose the right algorithms
§ Use the best tools
§ Configure the tools optimally
§ Use the right data types / formats
§ Use the right language constructs
§ Apply high performance coding techniques
HARDWARE CONFIGURATION
OTHER SPECIALIZED HW
ALGORITHMS
See http://embeddedgurus.com/stack-overflow/2007/04/crest-factor-square-roots-neat-algorithms/
SORTING
MIDDLE OF 3 VALUES
See http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/chap03/sort.html
MEDIAN FILTERING
See http://embeddedgurus.com/stack-overflow/2010/10/median-filtering/
INTEGER LOG
See http://embeddedgurus.com/stack-overflow/2008/05/integer-log-functions/
MEMORY MODELS
INTEGER SIZES
STRUCTURE ALIGNMENT
Above is optimal for 8 /16 bit processors. If you have a 32 bit machine with a
barrel shifter then combine the shifts: e.g.
Divide by 10: (((uint32_t)A * (uint32_t)0xCCCD) >> (16 + 3)
See
http://embeddedgurus.com/stack-overflow/2009/06/division-of-integers-by-constants/
LOOKUP TABLES
Makes code:
• More robust
• More maintainable
• Potentially faster
• Almost no downside to use
See: https://www.iar.com/Support/resources/articles/writing-
optimizer-friendly-code/
PARAMETER PASSING
INTERRUPTS
• Minimize frequency
• Don’t make function calls, including library calls
• Consider using software interrupts
• No floating point
• Maximum optimization
• Size optimization may be better than speed!
KEY TAKEAWAYS
CONCLUSION