This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PMU (Performance monitor Unit)

Hi,

How can I use PMU(Performance Monitor Unit) in ARM11 to calculate execution clock cycles of an assembly code.

I am using raspberry pi Model B. I am programming it in assembly language (running assembly program as OS). And want to calculate number of clock cycles it takes to execute my code.

Parents
  • Hello,

    according to the ARM1176JZZFS TRM. the following procedures would be taken the number of execution cycles of a target codes.

      /* Enable PMU */
      mov r0,#1
      MCR p15, 0, r0, c15, c12, 0 ; Write Performance Monitor Control Register
      /* Reset Cycle Counter */
      mov r0,#5
      MCR p15, 0, r0, c15, c12, 0 ; Write Performance Monitor Control Register
      /* Meaure */
      MRC p15, 0, r0, c15, c12, 1 @ Read Cycle Counter Register
      <your code>
      MRC p15, 0, r1, c15, c12, 1 @ Read Cycle Counter Register
      sub r0.r1.r0                @ Cycle Count of <your code
    

    Best regards,

    Yasuhiko Koumoto.

Reply
  • Hello,

    according to the ARM1176JZZFS TRM. the following procedures would be taken the number of execution cycles of a target codes.

      /* Enable PMU */
      mov r0,#1
      MCR p15, 0, r0, c15, c12, 0 ; Write Performance Monitor Control Register
      /* Reset Cycle Counter */
      mov r0,#5
      MCR p15, 0, r0, c15, c12, 0 ; Write Performance Monitor Control Register
      /* Meaure */
      MRC p15, 0, r0, c15, c12, 1 @ Read Cycle Counter Register
      <your code>
      MRC p15, 0, r1, c15, c12, 1 @ Read Cycle Counter Register
      sub r0.r1.r0                @ Cycle Count of <your code
    

    Best regards,

    Yasuhiko Koumoto.

Children