2024-08-13 11:03 PM
I am working with an STM32F3, a ChipWhisperer and the SimpleSerial library right now and trying to follow instructions executed. While doing so, I noticed that the number of CPU cycles does not seem to match what I expected from the ARM Cortex-M4 instruction timings. For example, I took a base code, subsequently added instructions and each time measured the number of cycles. My measurements are as following:
instruction | cycles
------------------------
ldrb r9,%[z] | 102
add r4,#194 | 104
mul r8,r12 | 105
eor r5,#198 | 107
strb r11,%[z] | 108
cycles is the number of cycles measured for all instructions added. add seems to take two cycles since ldrb gets pipelined with an instruction after relevant instructions if the add is not there.
What baffles me is the eor instruction. By my measurements, it takes two cycles to complete. Contrary to that, the ARM Cortex-M4 manual explicitly states that an eor instruction only takes one cycle.
Am I overlooking something or does the STM32F3 include something not mentioned in the ARM Cortex-M4 manual that can mess with the cycles?
The attachment contains the base code with all the instructions added between the lines 59 and 258. The Instructions above are between the lines 124 and 128.
Thanks in advance
2024-08-22 06:14 PM - edited 2024-08-22 06:15 PM
Can you describe your setup for timing measurement and why you are confident that the measurements produced are cycle-accurate?