I am running a led toggle sub-routine in infinite loop for Cortex M33 on MPS2+ FPGA Board, want to calculate cycle count in one iteration.
LDR R0, =0x40302000 ;FPGAIO Base Address(0x40302000) + LED_OFFSET(0) MOV R2,#3
Loop LDR R1, [R0] EOR R1,R1,R2 STR R1,[R0] B Loop ENDP
Please assist me to do this
Thanks a lot.
First hint: https://developer.arm.com/docs/103489824/latest/number-of-instructions-executed-by-the-processor-in-a-given-time-interval
2nd hint: developer.arm.com/.../dwt-programmers-model
The Arm Architecture does not specify how many cycles each instruction should take to execute. This is implementation defined.
Some of the M-profile processors (implementations) list instruction cycle timing in the relevant Technical Reference Manual. For example, the Cortex-M3 Technical Reference Manual lists how many cycles each instruction is expected to take (assuming certain criteria, e.g., zero wait-state memory):
Also, Cortex-M23 cycle timing information is documented:
For processors like Cortex-M7 and Cortex-M33 it's not so easy to document such information due to timing variation in the processor pipeline.
As mentioned by 42Bastin Schick, the architecture does provide debug features for profiling, e.g., measuring performance. For example, the Data Watchpoint and Trace Unit (DWT) in Armv7-M and Armv8-M with the Main Extension provides a Cycle Count Register (DWT_CYCCNT) that can be used for profiling how many processor cycles have elapsed for particular sequences of code running on the target.
If your device doesn't include debug then the built-in SysTick timer, which can be configured to align with the processor's clock frequency, could be used for profiling, e.g., sample the timer at the beginning and the end of the procedures you'd like to profile.
In terms of simulators, there are a couple of options:
View all questions in Cortex-M / M-Profile forum