2.5 Getting existing CADI simulations

If the caller connects to a running CADI simulation, it must retrieve information on this simulation by calling the GetSimulationInfos() method of the CADI broker. This call returns an internal list of available simulations that the broker maintains.

The number of elements that are retrieved depends on:

  • The size of the buffer that is used to fetch the list.
  • The number of simulations that are available.
  • The specified start index into the internal buffer in the broker.

The list of simulations that the broker holds can change dynamically. Consider updating this list regularly to detect the creation or destruction of CADI simulations.

Figure 2-6 Getting information on existing CADI simulations
To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.


Based on the acquired information, the caller uses SelectSimulation() to select a simulation to attach to. To specify a simulation, its ID (as part of the simulation info) must be used.

SelectSimulation() can receive pointers to a CADIErrorCallback object and a CADISimulationCallback object. These objects are automatically registered to the requested simulation. The caller must provide these objects.

Note:

It is not required that a specific simulation ID matches the corresponding index for the simulation within the internal list that the broker holds.
Figure 2-7 Getting an existing CADI simulation
To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.


The result of SelectSimulation() is a CADISimulation pointer to the requested simulation. The ObtainInterface() method and the static_cast scheme must be applied to check validity.

A typical implementation for getting an existing CADI simulation
// Having already obtained a pointer to the CADIBroker before
// which is called cadi_broker.
MyCADIErrorCallback errorCallbackObject;
MyCADISimulationCallback simulationCallbackObject;
char simulationCallbacksEnable[eslapi::CADI_SIM_CB_Count];
memset(simulationCallbacksEnable,
       1, eslapi::CADI_SIM_CB_Count * sizeof(char)); // Enable all callbacks.
uint32_t desiredNumberOfSimulations = 10;
uint32_t startSimulationInfoIndex = 0;
uint32_t actualNumberOfSimulations = 0;
eslapi::CADISimulationInfo_t* simulationList = new
              eslapi::CADISimulationInfo_t[desiredNumberOfSimulations]();
eslapi::CADIReturn_t status;
status = cadi_broker->GetSimulationInfos(startSimulationInfoIndex,
                                         desiredNumberOfSimulations,
                                         simulationList,
                                         &actualNumberOfSimulations);
if (status != eslapi::CADI_STATUS_OK)
{
     // GetSimulationInfos() failed.
}
// ...
// decide which simulation to connect to, 
// for this example using the second one (index '\1'!!)
// ...
CADISimulation* cadi_simulation
               = cadi_broker->SelectSimulation(simulationList[1].id,
                                               &errorCallbackObject,
                                               &simulationCallbackObject,
                                               simulationCallbacksEnable);
if (cadi_simulation == NULL)
{
     // Connection to simulation failed.
}
// Check compatibility.
eslapi::if_name_t ifNameSimulation = "eslapi.CADISimulation2";
eslapi::if_rev_t minRevSimulation = 0;
eslapi::if_rev_t actualRevSimulation = 0;
if (cadi_simulation->ObtainInterface(ifNameSimulation,
                                     minRevSimulation,
                                     &actualRevSimulation) == NULL)          

Note:

The size of eslapi::CADISimulationInfo_t is 8kB. When allocating arrays of this object on the stack, do not to exceed the stack allocation limits.
Non-ConfidentialPDF file icon PDF version100963_0200_03_en
Copyright © 2014–2018 Arm Limited or its affiliates. All rights reserved.