UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Explorer
Explorer
200 Views
Registered: ‎03-29-2017

How to write XSDK code for AXI performance monitor for Zynq UltraScale MPSoC [ZCU102]

How to write the XSDK code to program the AXI performance monitor core for event counting and event logging in advanced mode.

In AXI performance monitor, I have used Axi streaming interface in advanced mode. 

I have followed the APM documentation https://www.xilinx.com/support/documentation/ip_documentation/axi_perf_mon/v5_0/pg037_axi_perf_mon.pdf

Through the APM documentation, i have tried the below code, but result`s are printing Zero`s. Please anyone guide me.

 

#include <stdio.h>
#include <stdlib.h>
#include "xaxipmon.h"
#include "xil_cache.h"


#define AXIPMON_DEVICE_ID_0		XPAR_AXIPMON_0_DEVICE_ID
#define AXIPMON_DEVICE_ID_1		XPAR_AXIPMON_1_DEVICE_ID

static XAxiPmon monitor;
static XAxiPmon monitor1;

void initpmon()
{
	XAxiPmon_Config *ConfigPtr;
	XAxiPmon_Config *ConfigPtr1;
	u32 Status;

	  /* Initialize the Device Configuration Interface driver */
	ConfigPtr = XAxiPmon_LookupConfig(AXIPMON_DEVICE_ID_0);
	if (ConfigPtr == NULL) {
		return XST_FAILURE;
	}

	Status = XAxiPmon_CfgInitialize(&monitor, ConfigPtr, ConfigPtr->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	ConfigPtr1 = XAxiPmon_LookupConfig(AXIPMON_DEVICE_ID_1);
		if (ConfigPtr1 == NULL) {
			return XST_FAILURE;
		}

		Status = XAxiPmon_CfgInitialize(&monitor1, ConfigPtr1, ConfigPtr1->BaseAddress);
		if (Status != XST_SUCCESS) {
			return XST_FAILURE;
		}

	// Enable Metric Counters
	XAxiPmon_EnableMetricsCounter(&monitor);

	// Set Sample Interval
	XAxiPmon_SetSampleInterval(&monitor, 400000000); // Equals 2 second
	xil_printf("Initialized pmon\r\n");


}


void readpmon()
{
	u32 Intr;

	// Reset Metric Counters
	XAxiPmon_ResetMetricCounter(&monitor);

	// Load Sample Interval Counter and start Countdown
	XAxiPmon_LoadSampleIntervalCounter(&monitor);

    XAxiPmon_EnableMetricsCounter(&monitor);

	XAxiPmon_EnableSampleIntervalCounter(&monitor);

	// Poll Sample Interval Counter Overflow Interrupt Bit
	while ((Intr & XAPM_IXR_SIC_OVERFLOW_MASK) == 0)
		Intr = XAxiPmon_IntrGetStatus(&monitor);


	//XAxiPmon_DisableMetricsCounter(&monitor);

	// Clear Sample Interval Counter Overflow Interrupt Bit
	XAxiPmon_IntrClear(&monitor, XAPM_IXR_SIC_OVERFLOW_MASK);

	// Read out Metric Counters
	u32 ReadByteCount = XAxiPmon_GetSampledMetricCounter(&monitor, XAPM_METRIC_COUNTER_3);
	u32 WriteByteCount = XAxiPmon_GetMetricCounter(&monitor, XAPM_METRIC_COUNTER_0);

	xil_printf("Read byte count HP0 = %d per sec\r\n", ReadByteCount/2);
	xil_printf("Write byte count HP0 = %d per sec\r\n", WriteByteCount/2);

	ReadByteCount = XAxiPmon_GetSampledMetricCounter(&monitor, XAPM_METRIC_COUNTER_9);
	WriteByteCount = XAxiPmon_GetMetricCounter(&monitor, XAPM_METRIC_COUNTER_6);

	xil_printf("Read byte count HP1 = %d per sec\r\n", ReadByteCount/2);
	xil_printf("Write byte count HP1 = %d per sec\r\n", WriteByteCount/2);

}
int main()
{
	xil_printf("Hello");
	initpmon();
	while(1)
	{
		getchar();
		readpmon();
	}
}
BD.png
0 Kudos
1 Reply
Highlighted
Xilinx Employee
Xilinx Employee
134 Views
Registered: ‎10-04-2016

Re: How to write XSDK code for AXI performance monitor for Zynq UltraScale MPSoC [ZCU102]

Hi @thaus_015,

You mentioned that the Performance Monitor is in Advance Mode. I'm not seeing where you set up the metrics for any counters in the initpmon() function. I'd expect to see a few calls to XAxiPmon_SetMetrics. 

Your initialization sequence should look pretty similar to this example:

https://github.com/Xilinx/embeddedsw/blob/master/XilinxProcessorIPLib/drivers/axipmon/examples/xaxipmon_polled_example.c

Regards,

Deanna

-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------
0 Kudos