/****************************************************************************** * * Copyright (C) 2012 - 2014 Xilinx, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * Use of the Software is limited solely to applications: * (a) running on a Xilinx device, or * (b) that interact with a Xilinx device through a bus or interconnect. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Except as contained in this notice, the name of the Xilinx shall not be used * in advertising or otherwise to promote the sale, use or other dealings in * this Software without prior written authorization from Xilinx. * ******************************************************************************/ /****************************************************************************/ /** * * @file xaxipmon_polled_example.c * * This file contains a design example showing how to use the driver APIs of the * AXI Performance Monitor driver in poll mode. * * * @note * * Global Clock Counter and Metric Counters are enabled. The Application * for which Metrics need to be computed should be run and then the Metrics * collected. * * *
* * MODIFICATION HISTORY: * * Ver Who Date Changes * ----- ----- -------- ----------------------------------------------------- * 1.00a bss 02/29/12 First release * 2.00a bss 06/23/12 Updated to support v2_00a version of IP. * 3.00a bss 09/03/12 Deleted XAxiPmon_SetAgent API to support * v2_01a version of IP. * 3.01a bss 10/25/12 Deleted XAxiPmon_EnableCountersData API to support * new version of IP. ** *****************************************************************************/ /***************************** Include Files ********************************/ #include "xaxipmon.h" #include "xparameters.h" #include "xstatus.h" #include "stdio.h" /************************** Constant Definitions ****************************/ /* * The following constants map to the XPAR parameters created in the * xparameters.h file. They are defined here such that a user can easily * change all the needed parameters in one place. */ #define AXIPMON_DEVICE_ID XPAR_AXIPMON_0_DEVICE_ID /**************************** Type Definitions ******************************/ /***************** Macros (Inline Functions) Definitions ********************/ /************************** Function Prototypes *****************************/ int AxiPmonPolledExample(u16 AxiPmonDeviceId, u32 *Metrics, u32 *ClkCntHigh, u32 *ClkCntLow); /************************** Variable Definitions ****************************/ static XAxiPmon AxiPmonInst; /* System Monitor driver instance */ /****************************************************************************/ /** * * Main function that invokes the example in this file. * * @param None. * * @return * - XST_SUCCESS if the example has completed successfully. * - XST_FAILURE if the example has failed. * * @note None. * *****************************************************************************/ int main(void) { int Status; u32 Metrics; u32 ClkCntHigh = 0x0; u32 ClkCntLow = 0x0; /* * Run the AxiPmonitor polled example, specify the Device ID that is * generated in xparameters.h . */ Status = AxiPmonPolledExample(AXIPMON_DEVICE_ID, &Metrics, &ClkCntHigh, &ClkCntLow); if (Status != XST_SUCCESS) { xil_printf("AXI Performance Monitor Polled example failed\r\n"); return XST_FAILURE; } xil_printf("AXI Performance Monitor Polled example passed\r\n"); return XST_SUCCESS; } /****************************************************************************/ /** * * This function runs a test on the AXI Performance Monitor device using the * driver APIs. * This function does the following tasks: * - Initiate the AXI Performance Monitor device driver instance * - Run self-test on the device * - Sets Metric Selector to select Slave Agent Number 1 and first set of * Metrics * - Enables Global Clock Counter and Metric Counters * - Calls Application for which Metrics need to be computed * - Disables Global Clock Counter and Metric Counters * - Read Global Clock Counter and Metric Counter 0 * * @param AxiPmonDeviceId is the XPAR_