Performance counter core, Core overview, Functional description – Altera Embedded Peripherals IP User Manual
Page 301: Section counters, Performance counter core -1, Core overview -1, Functional description -1, Section counters -1

Performance Counter Core
31
2014.24.07
UG-01085
Core Overview
The performance counter core with Avalon
®
interface enables relatively unobtrusive, real-time profiling
of software programs. With the performance counter, you can accurately measure execution time taken
by multiple sections of code. You need only add a single instruction at the beginning and end of each
section to be measured.
The main benefit of using the performance counter core is the accuracy of the profiling results. Alterna‐
tives include the following approaches:
• GNU profiler,
gprof
—
gprof
provides broad low-precision timing information about the entire
software system. It uses a substantial amount of RAM, and degrades the real-time performance. For
many embedded applications,
gprof
distorts real-time behavior too much to be useful.
• Interval timer peripheral—The interval timer is less intrusive than
gprof
. It can provide good results
for narrowly targeted sections of code.
The performance counter core is unobtrusive, requiring only a single instruction to start and stop
profiling, and no RAM. It is appropriate for high-precision measurements of narrowly targeted
sections of code.
.
The core is designed for use in Avalon-based processor systems, such as a Nios
®
II processor system.
Altera
®
device drivers enable the Nios II processor to use the performance counters.
Functional Description
The performance counter core is a set of counters which track clock cycles, timing multiple sections of
your software. You can start and stop these counters in your software, individually or as a group. You can
read cycle counts from hardware registers.
The core contains two counters for every section:
• Time: A 64-bit clock cycle counter.
• Events: A 32-bit event counter.
Section Counters
Each 64-bit time counter records the aggregate number of clock cycles spent in a section of code. The 32-
bit event counter records the number of times the section executes.
©
2014 Altera Corporation. All rights reserved. ALTERA, ARRIA, CYCLONE, ENPIRION, MAX, MEGACORE, NIOS, QUARTUS and STRATIX words and logos are
trademarks of Altera Corporation and registered in the U.S. Patent and Trademark Office and in other countries. All other words and logos identified as
trademarks or service marks are the property of their respective holders as described at
www.altera.com/common/legal.html
. Altera warrants performance
of its semiconductor products to current specifications in accordance with Altera's standard warranty, but reserves the right to make changes to any
products and services at any time without notice. Altera assumes no responsibility or liability arising out of the application or use of any information,
product, or service described herein except as expressly agreed to in writing by Altera. Altera customers are advised to obtain the latest version of device
specifications before relying on any published information and before placing orders for products or services.
www.altera.com
101 Innovation Drive, San Jose, CA 95134