  This paper presents EnergyAnalyzer, a code-level static analysis tool for
estimating the energy consumption of embedded software based on statically
predictable hardware events. The tool utilises techniques usually used for
worst-case execution time (WCET) analysis together with bespoke energy models
developed for two predictable architectures - the ARM Cortex-M0 and the Gaisler
LEON3 - to perform energy usage analysis. EnergyAnalyzer has been applied in
various use cases, such as selecting candidates for an optimised convolutional
neural network, analysing the energy consumption of a camera pill prototype,
and analysing the energy consumption of satellite communications software. The
tool was developed as part of a larger project called TeamPlay, which aimed to
provide a toolchain for developing embedded applications where energy
properties are first-class citizens, allowing the developer to reflect directly
on these properties at the source code level. The analysis capabilities of
EnergyAnalyzer are validated across a large number of benchmarks for the two
target architectures and the results show that the statically estimated energy
consumption has, with a few exceptions, less than 1% difference compared to the
underlying empirical energy models which have been validated on real hardware.
