A unified energy framework with integrated hardware-software optimizations