4.2. The CAPI classes

The relationship between the various CAPI data structures is shown in Figure 4.1. (The eventsTrace data blocks have three data entries in this example.)

Figure 4.1. CAPI data structures and the profiling stream

The CAPI class hierarchy is shown in Figure 4.2.

Figure 4.2. CAPI class hierarchy

Note

See the CAPITypes.h file for definitions of enumerations and data structures that are used with the CAPI interface.

Supporting profiling requires that a component:

The derived CAPI class CompName_CAPI for your component (named CompName) must implement an empty constructor. Calling the base class generates calls to the CAPI constructor and the function CAPIGetProfilingStreams() that returns the profiling stream to be collected for this component.

CompName_CAPI::CompName_CAPI(eslapi::CASIModuleIF *comp):CAPI(comp)
{
}

CAPIReturn_t CompName_CAPI::CAPIGetProfilingStreams(uint32_t desiredNrStreams, 
                        uint32_t *actualNrStreams, 
                        eslapi::CAPIStreamInfo_t *streams); 

The following steps show a simplified sequence that describes how to use the CAPI interface in a model during the simulation stage:

  1. Get a pointer to the CAPI interface by calling getCAPI().

    CAPI * capi = CompName->getCAPI()
    
  2. Get the streams metadata by:

    uint32_t actualNrStreams;
    CAPIStreamInfo_t streamsInfo[100];
    capi->CAPIGetProfilingStreams(100, &actualNrStreams, streamsInfo);
    
  3. A specific stream can be obtained from the metadata by selecting a specific stream by its name. Use either the literal name for the stream or the name from the streamInfo structure:

    CAPIStream_t * stream0 = capi->CAPIFindStream(“Accesses”);
    
    
    CAPIStream_t * stream0 = capi->CAPIFindStream(streamsInfo[0].streamName);
    
  4. The returned pointer can be used to enable profiling stream:

    stream0->enabled = true;
    
  5. The pointer is also used to collect information when an event occurs:

    CAPIRecordEvent2(stream0, (uint16_t) addr, (uint8_t) COT_READ_HIT);
    

For more details on using CAPI, see Example CAPI implementation.

Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0359B
Non-Confidential