# How to evaluate the energy of an arithmetic operation

1. ## How to evaluate the energy of an arithmetic operation

Hi,

I have an ALU described in SV, with the corresponding Testbench that takes some input vectors, feeds them into the ALU, gets the result and then compares with the expected result.

The Testbench dumps a VCD file that, combined with the gate-level netlist, is fed to PrimeTime for time_based and average power evaluation. And I get the power waveform showing how the power varies in time. The Waveform is in FSDB format, and I can visualize it using the Synopsys Verdi tool.

Now, what I would like to do, is for each particular instruction (say addition, multiplication ...) in the testbench I would like to estimate the amount of energy spent. Since, some operations like addition would take only one cycle, but others (like sqrt/div) are iterative and they take more cycles. So I guess reasoning about energy per operation would be a more meaningful metric, say to compare the energy effeciency of several ALU architectures for example. (Am I right ?)

So my question is, is there any standard/usual/easy way to do this process?
I thought actually about coding a whole Python tool that would go throught the power waveform and integrate over time for each instruction. It could take a lot of time to build and test it. Any recommendations about that?
Is it possible to do this kind of stuff in Verdi itself? Or is PrimeTime capable of outputting the Energy values instead of time_based power?

•

2. ## Re: How to evaluate the energy of an arithmetic operation

The power report of PrimeTimePX does give us the average power consumption of a circuit. You can multiply the reported power by the total simulation time to get the amount of energy consumed by each function.

Let's say you have 7 different functions. You can write 7 different testbenches, each one tests for a single function of your circuit. They should have different simulation time (e.g. 1st function 1 cycle, 2nd function 2 cycles etc.); and you can have PrimeTimePX to report power for each simulation waveform.

•

3. ## Re: How to evaluate the energy of an arithmetic operation

Originally Posted by kungchuking
Let's say you have 7 different functions. You can write 7 different testbenches, each one tests for a single function of your circuit.
I agree that having different testbenches for each use case is the simplest way to go.

•

4. ## Re: How to evaluate the energy of an arithmetic operation

Thank you for you answers!
I actually came across something that could simplify things (since I actually have a few dozens of instructions, so running each benchmark alone will take a hell lot of time).

So apparently when using the read_vcd command in PrimeTime, it is possible to specify a boolean condition using the `-when` argument. So now, I have a full testbench that performs all the instructions and I record everything in a VCD or FSDB activity file, then I read the VCD multiple times (one for each instruction i). I have an input signal in the ALU called "op" which specifies the operation to perform. So the idea is to record the vcd when op is equal to the instruction i 's binary opcode. I find this way more 'automatable'. What do you think guys?

--[[ ]]--