axipmon
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Macros Groups Pages
xaxipmon_ocm_example.c File Reference

Overview

Measures OCM traffic metrics using the AXI Performance Monitor driver.

This file contains a design example that shows how to use the AXI Performance Monitor driver APIs. The example measures the following metrics captured at OCM of Zynq MP:

  • Write Transaction Count
  • Write Byte Count
  • Read Transaction Count
  • Read Byte Count
MODIFICATION HISTORY:
Ver   Who    Date     Changes


1.00a bss 04/01/15 First release 6.5 sg 11/02/16 Updated device ID to OCM PSU APM ID ms 01/23/17 Modified xil_printf statement in main function to ensure that "Successfully ran" and "Failed" strings are available in all examples. This is a fix for CR-965028. 6.10 ht 06/23/23 Added support for system device-tree flow. 6.14 vlt 01/27/26 Fixed codespell issues 6.15 vn 07/30/26 Fix Doxygen warnings 6.15 vn 09/08/26 Align Doxygen comments with AMD standards 6.15 vn 09/30/26 Update Doxygen comments to AMD standards

#include "xaxipmon.h"
#include "xil_cache.h"
#include "xparameters.h"

Macros

#define SAMPLE_INTERVAL   0x100
 Sampling interval. More...
 
OCM test addresses
#define OCM_WRITE_ADDRESS   0xFFFE0000
 OCM write test address. More...
 
#define OCM_READ_ADDRESS   0xFFFF0000
 OCM read test address. More...
 

Functions

int ApmCheck (u32 *BufferPtr, u16 Wtx, u16 Wbc, u16 Rtx, u16 Rbc)
 Checks the metrics passed to this function are same as collected by APM. More...
 
void OcmTransaction ()
 Generates write and read transactions to OCM and reads metrics captured by APM. More...
 
int ApmMetricConfig (XAxiPmon *InstancePtr, u8 slot, u8 Metric1, u8 Metric2)
 Sets Counter 0 and Counter 1 for collecting the passed metrics. More...
 
void ReadMetrics (XAxiPmon *InstancePtr, u32 *BufferPtr, u8 Counter1, u8 Counter2)
 Reads metrics from APM counters to buffer. More...
 
int main (void)
 Invokes the AXI Performance Monitor OCM example. More...
 

Variables

u32 MetricsBuffer [6]
 Buffer for the collected metrics. More...
 

Macro Definition Documentation

#define OCM_READ_ADDRESS   0xFFFF0000

OCM read test address.

Referenced by OcmTransaction().

#define OCM_WRITE_ADDRESS   0xFFFE0000

OCM write test address.

Referenced by OcmTransaction().

#define SAMPLE_INTERVAL   0x100

Sampling interval.

Referenced by ApmMetricConfig().

Function Documentation

int ApmCheck ( u32 *  BufferPtr,
u16  Wtx,
u16  Wbc,
u16  Rtx,
u16  Rbc 
)

Checks the metrics passed to this function are same as collected by APM.

Parameters
[in]BufferPtrPointer to buffer containing captured metrics.
[in]WtxWrite transaction count value to be checked.
[in]WbcWrite byte count value to be checked.
[in]RtxRead transaction count value to be checked.
[in]RbcRead byte count value to be checked.
Returns
  • XST_SUCCESS if metrics passed are equal to metrics collected by APM.
  • XST_FAILURE if any of the metrics passed is not equal to metrics collected by APM.

Referenced by main().

int ApmMetricConfig ( XAxiPmon *  InstancePtr,
u8  slot,
u8  Metric1,
u8  Metric2 
)

Sets Counter 0 and Counter 1 for collecting the passed metrics.

Parameters
[in]InstancePtrPointer to APM instance.
[in]slotAPM slot.
[in]Metric1Metric to be captured by Counter 1.
[in]Metric2Metric to be captured by Counter 2.
Returns
  • XST_SUCCESS on success.
  • XST_FAILURE on failure.

References SAMPLE_INTERVAL, XAPM_METRIC_COUNTER_0, XAPM_METRIC_COUNTER_1, XAxiPmon_EnableMetricsCounter(), XAxiPmon_ResetGlobalClkCounter(), XAxiPmon_ResetMetricCounter(), XAxiPmon_SetMetrics(), and XAxiPmon_StartCounters().

Referenced by OcmTransaction().

int main ( void  )

Invokes the AXI Performance Monitor OCM example.

Returns
  • XST_SUCCESS if the example has completed successfully.
  • XST_FAILURE if the example has failed.

References ApmCheck(), XAxiPmon_Config::BaseAddress, MetricsBuffer, OcmTransaction(), XAxiPmon_CfgInitialize(), XAxiPmon_DisableMetricsCounter(), and XAxiPmon_LookupConfig().

void OcmTransaction ( )

Generates write and read transactions to OCM and reads metrics captured by APM.

References ApmMetricConfig(), MetricsBuffer, OCM_READ_ADDRESS, OCM_WRITE_ADDRESS, ReadMetrics(), XAPM_METRIC_COUNTER_0, XAPM_METRIC_COUNTER_1, XAPM_METRIC_SET_0, XAPM_METRIC_SET_1, XAPM_METRIC_SET_2, and XAPM_METRIC_SET_3.

Referenced by main().

void ReadMetrics ( XAxiPmon *  InstancePtr,
u32 *  BufferPtr,
u8  Counter1,
u8  Counter2 
)

Reads metrics from APM counters to buffer.

Parameters
[in]InstancePtrPointer to APM instance.
[out]BufferPtrPointer to buffer.
[in]Counter1Counter number.
[in]Counter2Counter number.

References XAxiPmon_GetMetricCounter(), and XAxiPmon_StopCounters().

Referenced by OcmTransaction().

Variable Documentation

u32 MetricsBuffer[6]

Buffer for the collected metrics.

Referenced by main(), and OcmTransaction().