57
32000D–04/2011
AVR32
7.
Performance counters
7.1
Overview
A set of performance counters let users evaluate the performance of the system. This is useful
when scheduling code and performing optimizations. Two configurable event counters are pro-
vided in addition to a clock cycle counter. These three counters can be used to collect
information about for example cache miss rates, branch prediction hit rate and data hazard stall
cycles.
The three counters are implemented as 32-bit registers accessible through the system register
interface. They can be configured to issue an interrupt request in case of overflow, allowing a
software overflow counter to be implemented.
A performance counter control register is implemented in addition to the three counter registers.
This register controls which events to record in the counter, counter overflow interrupt enable
and other configuration data.
7.2
Registers
7.2.1
Performance clock counter - PCCNT
This register counts CPU clock cycles. When it reaches 0xFFFF_FFFF, it rolls over. The over-
flow flag is set and an exception is generated if configured by PCCR. The register can be reset
by writing to the C bit in PCCR. PCCNT can be preset to a value by writing directly to it. PCCNT
is written to zero upon reset.
7.2.2
Performance counter 0,1 - PCNT0, PCNT1
These counters monitor events as configured by PCCR. When they reach 0xFFFF_FFFF, they
roll over. The overflow flag is set and an exception is generated if configured by PCCR. The reg-
isters can be reset by writing the R bit in PCCR. The registers can be preset to a value by writing
directly to them. PCNT0 and PCNT1 are written to zero upon reset.
7.2.3
Performance counter control register - PCCR
This register controls the behaviour of the entire performance counter system, see
Figure 7-1 onpage 57. This register is read and written by the mtsr and mfsr instructions. PCCR is written to
zero upon reset.
Figure 7-1.
Performance counter control register
E
R
C
S
IE
-
F
-
CONF0
CONF1
-
0
1
2
3
4
6
8
10
12
17
18
23
24
31