Intel 64 and IA-32 Architectures Software Developers Manual Volume 3B, System Programming Guide Part 2

Table Of Contents
Vol. 3 18-107
DEBUGGING AND PERFORMANCE MONITORING
events. The compare, complement, threshold, and edge fields control the filtering of
counter increments by input value.
If the compare flag is set, then a “greater than” or a “less than or equal to” compar-
ison of the input value vs. a threshold value can be made. The complement flag
selects “less than or equal to” (flag set) or “greater than” (flag clear). The threshold
field selects a threshold value of from 0 to 15. For example, if the complement flag is
cleared and the threshold field is set to 6, than any input value of 7 or greater on the
4 inputs to the counter will cause the counter to be incremented by 1, and any value
less than 7 will cause an increment of 0 (or no increment) of the counter. Conversely,
if the complement flag is set, any value from 0 to 6 will increment the counter and
any value from 7 to 15 will not increment the counter. Note that when a threshold
condition has been satisfied, the input to the counter is always 1, not the input value
that is presented to the threshold filter.
The edge flag provides further filtering of the counter inputs when a threshold
comparison is being made. The edge flag is only active when the compare flag is set.
When the edge flag is set, the resulting output from the threshold filter (a value of 0
or 1) is used as an input to the edge filter. Each clock cycle, the edge filter examines
the last and current input values and sends a count to the counter only when it
detects a “rising edge” event; that is, a false-to-true transition. Figure 18-44 illus-
trates rising edge filtering.
The following procedure shows how to configure a CCCR to filter events using the
threshold filter and the edge filter. This procedure is a continuation of the setup
procedure introduced in Section 18.18.6.1, “Selecting Events to Count.
7. (Optional) To set up the counter for threshold filtering, use the WRMSR
instruction to write values in the CCCR compare and complement flags and the
threshold field:
Set the compare flag.
Set or clear the complement flag for less than or equal to or greater than
comparisons, respectively.
Enter a value from 0 to 15 in the threshold field.
8. (Optional) Select rising edge filtering by setting the CCCR edge flag.
This setup procedure is continued in the next section, Section 18.18.6.3, “Starting
Event Counting.