| |||
| Home > The Cycle Accurate Profiling Interface > 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.)
The CAPI class hierarchy is shown in Figure 4.2.
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:
implement a class inheriting from CAPI,
specify the information regarding the information to be profiled (such as the profiling streams and channels to be collected).
The derived CAPI class for
your component (named CompName_CAPI)
must implement an empty constructor. Calling the base class generates
calls to the CAPI constructor and the function CompNameCAPIGetProfilingStreams() that
returns the profiling stream to be collected for this component.
CompName_CAPI::CompName_CAPI(eslapi::CASIModuleIF *comp):CAPI(comp) { } CAPIReturn_tCompName_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:
Get a pointer to the CAPI interface by calling getCAPI().
CAPI * capi = CompName->getCAPI()
Get the streams metadata by:
uint32_t actualNrStreams; CAPIStreamInfo_t streamsInfo[100]; capi->CAPIGetProfilingStreams(100, &actualNrStreams, streamsInfo);
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);
The returned pointer can be used to enable profiling stream:
stream0->enabled = true;
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.