Energy-Driven Optimization Of Hardware And Software For Distributed Embedded Systems