# Estimate the power consumption of a C program without hardware

I have a C application running on TI CC2650 SENSORTAG microcontroller that performs gesture recognition. Is there any way I can figure out its estimated power usage probably through Raspberry Pi or something, so that I can use it to compare the actual power consumed when I synthesize it on a FPGA? This is an academic project targetted at Hardware acceleration.

• Why not just run it on the pi and measure the power consumed? Its a lot faster (and easier) than formulating some 'estimate' which you have no means of verifying anyway without a physical comparison. – JIm Dearden Aug 2 '17 at 10:40
• Is there a way to estimate power? Yes. Will it give a meaningful number? Probably not unless you put so much time and effort into it that it would be easier to build it and measure the power draw. And as Jim pointed out what use is an estimate when you have no idea how accurate it is? – Andrew Aug 2 '17 at 10:44
• One ascii character = 0.00015 Volts of power consumption – Harrichael Aug 2 '17 at 15:52
• @Harrichael That means I have to multiply 0.00015 volts with the number of ASCII characters in my program? – Shankhadeep Mukerji Aug 2 '17 at 16:23
• @ShankhadeepMukerji: Harrichael's comment is clearly trolling, because volts is not a unit of power measurement. Do yourself a favor and get in the habit of checking dimensional consistency. – Ben Voigt Aug 2 '17 at 20:04

Your equivalent question is to measure the length of a plank without a measure.

You can always eyeball it. The Mic datasheet will provide the current consumption under various conditions, with different peripherals turned on. That's your best bet.

What you are trying to do won't really work. First a "C program" doesn't consume a particular amount of power.

A particular program performing a particular task on a particular processor may cause a reasonably measurable increase in power draw by that processor, or not. The power draw of a processor will only change significantly if it would otherwise go into some kind of low power mode if the "program" wasn't running. On many small systems, not doing one thing only means doing more of other things. The only effect of running a particular piece of code might be to respond with higher latency to new events, for example.

Even if you can measure a reasonably repeatable power increase in one processor due to running a particular program, that is little indication of anything useful for the same task performed some other way using different technology. You really should not expect the power increase due to a RPi running a particular program to have a meaningful correlation to the power required to run a FPGA that performs the same function.

• Actually there is a way I have found in some literature. The Microcontroller has a instruction set where each instruction needs a specific amount of power. He can translate his program into assembler code to get all instruction. Than he knows exactly what instructions are executed and can calculate the consumed power by adding the required power for each instruction. The only problem is finding out the power consumption per Instruction. Maybe it can be found in the datasheet or he can ask the TI support for some information – S.G Aug 2 '17 at 11:23
• @S.G The main problem here is the C -> FPGA translation, estimating how much power it would take on a Raspberry Pi is likely easier. – pipe Aug 2 '17 at 11:25
• @S.G: It seems he wants to find the power required on a RPi, then use that to estimate power for the same task implemented in a FPGA. Basically, that's just plain not going to work. – Olin Lathrop Aug 2 '17 at 11:40
• @S.G: Nobody knows or cares about the power consumption of individual instructions executed. Just think about how the data processed will have a great influence. – JimmyB Aug 2 '17 at 11:51
• @S.G "the power consumption is influenced by the amount of data" - Not only the amount of data, but also the data itself. The most obvious example: if ( x == y ) { doSomething(); } - Vastly different resource use depending on whether or not x==y at runtime. More subtle differences may be found in things like x++. This may require a little more (or less?) power if x overflows for instance. – JimmyB Aug 2 '17 at 12:24