45 Time Synchronization Library 47 Writing Hypersim Patterns
Model Builder User's Guide  /  VII Extending Simics  / 

46 Integrating with Other Applications

Simics provides support to cooperate with other applications, either by linking Simics in the other application, or by making the other application a part of Simics.

46.1 Linking Simics into Another Application

Simics has been built so it can be embedded into another application: it consists in a small simics binary and several libraries, such as libsimics-common, which contains the core functionality. The main binary can be replaced so that, by integrating the Simics libraries, all Simics functionality can be included as a part of another application.

The Simics Base package contains the source code of a Simics binary replacement located in src/misc/simple-simics/. The following files are included:

The simple-simics illustrates the main steps to integrated Simics:

  1. Call SIM_init_environment().
  2. Create a list of init_arg_t structures, filling it with initialization arguments and their values. Make sure the last entry has NULL fields. The structure is described in the API Reference Manual.
  3. Call SIM_init_simulator2() with the list as parameter.

Once there, there are two ways of controlling the simulation.

Simics can run its own main loop, which can be done by calling SIM_init_command_line() followed by SIM_main_loop(). Once this is done, Simics will not return control to the caller, so other means of communication must be put into place if the calling application needs to react to simulation events. For example, a dedicated Simics extension might be taking over.

Simics can also accept commands one at a time, with SIM_run_command(). In that case, the interface stays in control of the calling application.

There are a few caveats that needs to be taken into account when embedding Simics:

46.2 Integrating Another Application into Simics

To integrate another application into Simics you need to be able to build the application as a Simics module or at least as a shared library you can load from a Simics module. If this is not possible see chapter 44 for how to connect your application to Simics.

The communication between Simics and the application needs to use the Simics APIs. The exact nature of the communication depends on what the embedded application does.

If your application runs its own simulation which needs to be integrated with the Simics simulation you should use the Simics Device API and the Model-to-Model and Model-to-Simulator interfaces to integrate with Simics. This basically makes the module containing the application a normal model module, as described in the Model Builder User's Guide.

If the application simulates one or more processors which you want to appear as processors in the Simics simulation use the Processor API, documented in the Processor Model Integration Guide, instead.

Your application can also integrate with Simics as an extension module using the Simulator API and Simulator-to-Simulator interfaces as described earlier in this document.

Of course, these categories of applications are not rigid. An application may need to use parts of the Simulator API to do its work, for example it may need to use SIM_register_work or SIM_thread_safe_callback even though it is mostly a model.

45 Time Synchronization Library 47 Writing Hypersim Patterns