Breakpoints Embedding Simics
API Reference Manual  /  Simulator API  /  Simulator API Functions  / 

Configuration

SIM_add_configuration

Name

SIM_add_configuration — set configuration from Python

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

void
SIM_add_configuration(pre_conf_object_set_t *NOTNULL set,
                      const char *file);

Python

import simics

simics.SIM_add_configuration(...)

Description

This function creates objects from the parse objects in set and adds the initialized objects to the current configuration (creating one if necessary). When called from Python (which is the intended usage), the configuration set is a sequence (list or tuple) of pre_conf_object Python objects, or a dictionary of the form {<name> : <pre_conf_object>}.

The file argument is the name of the file that a configuration was read from, and should be set to None/NULL if not used.

Examples

The following examples are written in Python. As they do not map any devices in phys_mem, they will not work as stand-alone simulations.

Example when set is a sequence:

clock = pre_conf_object('timer', 'clock')
clock.freq_mhz = 20
space = pre_conf_object('phys_mem', 'memory-space')
space.queue = clock

SIM_add_configuration([clock, space], None)

Example when set is a dictionary:

objects = {}
objects['clock'] = pre_conf_object('timer', 'clock')
objects['clock'].freq_mhz = 20
objects['space'] = pre_conf_object('phys_mem', 'memory-space')
objects['space'].queue = objects['clock']

SIM_add_configuration(objects, None)

Exceptions

SimExc_General Thrown if Simics fails to initialize all objects.

Execution Context

Global Context

See Also

SIM_create_object, SIM_set_configuration, SIM_read_configuration

SIM_class_has_attribute

Name

SIM_class_has_attribute — check if class implements attribute

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

bool
SIM_class_has_attribute(conf_class_t *NOTNULL cls, const char *NOTNULL attr);

Python

import simics

simics.SIM_class_has_attribute(...)

Description

Returns true if the class cls implements an attribute with the name attr.

Execution Context

Cell Context

See Also

SIM_register_attribute, SIM_get_attribute

SIM_create_object

Name

SIM_create_object — create and initialize object

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

conf_object_t *
SIM_create_object(conf_class_t *NOTNULL cls, const char *name,
                  attr_value_t attrs);

Python

import simics

simics.SIM_create_object(...)

Description

Creates a new instance of the configuration class cls. name must consist of a letter followed by letters, digits or underscores (_). A unique name will be created if name is an empty string or nullptr. For backward compatibility, hyphens (-) are allowed instead of underscores but their use is deprecated.

The new object is initialized with attributes from attrs, which must be a list of (attribute-name, value) pairs, where each pair is a two-element list. All required attributes for the class cls must be present in attrs. In Python, attrs can be omitted (if no attributes are required), it can be normal lists: [['attribute1', value1], ['attribute2', value2]] or keyword arguments: attribute1=value1, attribute2=value2.

Attributes in ports of the cls class can be initialized by prefixing the attribute name with the port name, e.g. ['p.portname.attr', value].

The argument value may be modified, but the caller is still responsible for freeing it. Neither point applies when the function is called from Python.

Return Value

The new object, or NULL on error (in which case an exception is raised).

Exceptions

SimExc_General Thrown if the name is not well-formed, if an object named name already exists, or if the initialisation failed.

Execution Context

Global Context

See Also

SIM_add_configuration, SIM_set_configuration

SIM_current_checkpoint_dir

Name

SIM_current_checkpoint_dir — directory of checkpoint being loaded

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

char *
SIM_current_checkpoint_dir();

Python

import simics

simics.SIM_current_checkpoint_dir(...)

Description

If called during the loading of a checkpoint, this function returns the checkpoint (bundle) directory. Otherwise, the return value is nullptr. The directory can be absolute or relative, and may be the empty string if the checkpoint directory is the current working directory.

Execution Context

Global Context

See Also

SIM_read_configuration, SIM_add_configuration

SIM_delete_objects, SIM_delete_object

Name

SIM_delete_objects, SIM_delete_object — delete a list of objects

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

int
SIM_delete_objects(attr_value_t val);

int
SIM_delete_object(conf_object_t *NOTNULL obj);

Python

import simics

simics.SIM_delete_objects(...)
simics.SIM_delete_object(...)

Description

Delete the list of objects val (or the single object obj) passed as argument, provided that no reference to these objects is left in the rest of the configuration. Descendant objects of an object being deleted will also be deleted.

Some specific objects in Simics, such as sim, are protected against deletion and will be ignored by this function.

If Simics finds references to the objects in the rest of the configuration, a warning will be printed and the operation will be aborted. Note that in this case, the deletion process has started and the objects may already have began their clean-up routines. The safest action at this point is to fix the dangling references and to try to delete the objects once again.

Events posted by the objects in cycle queues or step queues will be automatically removed. Hap callbacks and script branches waiting on deleted objects will be interrupted as well.

Recursion

While removing the listed objects, SIM_delete_objects will call various callbacks (Core_Conf_Object_Pre_Delete and Core_Conf_Object_Delete haps, as well as pre_delete_instance and delete_instance for each object). Recursive calls to SIM_delete_objects are allowed during the pre-delete phase (Pre_Delete hap and pre_delete_instance callback), and the new objects will be added to the current list of objects to delete. Recursive calls after this stage will fail.

This limited recursion is meant to let objects that “own” other objects destroy them automatically if they themselves are to be deleted. This is used for example by the standard Simics components.

Bugs

Note that for successful deletion of objects, each class should implement the proper deletion methods called by SIM_delete_objects. If the methods are not present, SIM_delete_objects will simply remove any reference to the object, but this may leave memory and resources unrecoverable.

Return Value

Returns zero if successful. Throws an exception and returns non-zero otherwise.

Exceptions

SimExc_General Thrown if an error occurred or a reference to the objects is left in the rest of the configuration.

Execution Context

Global Context

Example

The following line at the Simics prompt:

@SIM_delete_objects(list(SIM_object_iterator(None)))

will delete all unprotected objects in the configuration, leaving the Simics session empty.

SIM_delete_snapshot

Name

SIM_delete_snapshot — delete a snapshot

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

snapshot_error_t
SIM_delete_snapshot(const char *name);

Python

import simics

simics.SIM_delete_snapshot(...)

Description

Deletes an in-memory snapshot.

Execution Context

Global Context

See Also

SIM_take_snapshot, SIM_restore_snapshot, SIM_list_snapshots

SIM_get_all_classes

Name

SIM_get_all_classes — get list of all loaded classes

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

attr_value_t
SIM_get_all_classes();

Python

import simics

simics.SIM_get_all_classes(...)

Description

Return an unordered list of the names of all configuration classes loaded into simulation.

The Python function cli.global_cmds.list_classes can be used to get class names, by default including not-loaded classes.

Return Value

List of class names.

Execution Context

Cell Context

SIM_get_all_objects

Name

SIM_get_all_objects — get list of all objects

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

attr_value_t
SIM_get_all_objects();

Python

import simics

simics.SIM_get_all_objects(...)

Description

This function is deprecated and should not be used. Please use SIM_object_iterator instead.

Return a list of all configuration objects. The order is unspecified and may vary between calls to this function.

Return Value

List of objects.

See Also

SIM_object_iterator

Execution Context

Cell Context

SIM_get_attribute, SIM_get_attribute_idx

Name

SIM_get_attribute, SIM_get_attribute_idx — get attribute

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

attr_value_t
SIM_get_attribute(conf_object_t *NOTNULL obj, const char *NOTNULL name);

attr_value_t
SIM_get_attribute_idx(conf_object_t *NOTNULL obj, const char *NOTNULL name,
                      attr_value_t *NOTNULL index);

Python

import simics

simics.SIM_get_attribute(...)
simics.SIM_get_attribute_idx(...)

Description

Extracts the attribute specified by name parameter from obj. If an error occurs, an invalid value is returned. The _idx version of the function can be used to get a single entry in a list or data attribute. The attribute must support indexing for this to work.

The caller is as usual responsible for freeing the returned value by calling SIM_attr_free.

Return Value

Attribute value. An attribute of Invalid type is returned if the attribute could not be read.

Exceptions

SimExc_AttrNotFound If the object did not have the specified attribute.

SimExc_AttrNotReadable If the attribute cannot be read.

SimExc_Type If the index has the wrong type.

SimExc_General If SIM_attribute_error or SIM_c_attribute_error was called inside the getter function.

Execution Context

Cell Context

See Also

SIM_attr_free, SIM_set_attribute, SIM_attribute_error

SIM_get_attribute_attributes

Name

SIM_get_attribute_attributes — get attribute flags

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

attr_attr_t
SIM_get_attribute_attributes(conf_class_t *NOTNULL cls,
                             const char *NOTNULL attr);

Python

import simics

simics.SIM_get_attribute_attributes(...)

Description

Returns the attribute flags of the attr attribute of the class cls.

Execution Context

Cell Context

See Also

SIM_register_attribute

SIM_get_class_attribute, SIM_get_class_attribute_idx

Name

SIM_get_class_attribute, SIM_get_class_attribute_idx — get class attribute

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

attr_value_t
SIM_get_class_attribute(conf_class_t *NOTNULL cls, const char *NOTNULL name);

attr_value_t
SIM_get_class_attribute_idx(conf_class_t *NOTNULL cls,
                            const char *NOTNULL name,
                            attr_value_t *NOTNULL index);

Python

import simics

simics.SIM_get_class_attribute(...)
simics.SIM_get_class_attribute_idx(...)

Description

Extracts the class attribute specified by name from the class cls. If an error occurs, an invalid value is returned. The _idx version of the function can be used to get a single entry in a list or data attribute. The attribute must support indexing for this to work.

The caller is as usual responsible for freeing the returned value by calling SIM_attr_free.

Return Value

Attribute value. A value of Invalid type is returned if the attribute could not be read.

Exceptions

SimExc_AttrNotFound If the class did not have the specified attribute.

SimExc_AttrNotReadable If the attribute cannot not be read.

SimExc_Type If the index has the wrong type.

SimExc_General Other errors.

Execution Context

Global Context, unless the attribute documentation says otherwise.

See Also

SIM_attr_free, SIM_set_class_attribute

SIM_get_object

Name

SIM_get_object — get object

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

conf_object_t *
SIM_get_object(const char *NOTNULL name);

Python

import simics

simics.SIM_get_object(...)

Description

Returns the object with name name.

The function does an object look-up in the order; object ID, object name, and hierarchical location for all objects in the simulation. The function returns the first match from the look-up or nullptr if there was no object match.

The object ID is a unique name that never changes and is returned by the SIM_object_id function. The object name is the name of the object, used for instance when printing log messages and is returned by the SIM_object_name function. The hierarchical location is the absolute location of the object in the component hierarchy. The object name and the hierarchical location is the same.

Please note that in Python Simics objects are available directly as attributes of the conf module. For example, one can access the sim object like this:

conf.sim

Return Value

Object, or nullptr if not found.

Exceptions

SimExc_General Thrown if the object can not be found.

Execution Context

Cell Context

See Also

SIM_object_name, SIM_object_id, SIM_object_parent, SIM_object_descendant

SIM_get_python_interface_type

Name

SIM_get_python_interface_type — get Python interface type

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

PyObject *
SIM_get_python_interface_type(const char *NOTNULL name);

Python

import simics

simics.SIM_get_python_interface_type(...)

Description

Returns the Python data type for the name interface, or nullptr if not available from Python.

If necessary, will try to load modules registering the Python translation for this interface.

SIM_get_snapshot_info

Name

SIM_get_snapshot_info — get information about a snapshot

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

attr_value_t
SIM_get_snapshot_info(const char *NOTNULL name);

Python

import simics

simics.SIM_get_snapshot_info(...)

Description

Returns a dictionary of information about a snapshot. The currently defined keys in the dictionary are:

name
The name of the snapshot
pages
The number of non-zero image pages in the snapshot
previous
The name of the latest snapshot taken or restored before this snapshot was taken. nil if there was no such snapshot, or if that snapshot has been deleted.

Execution Context

Global Context

See Also

SIM_list_snapshots, SIM_take_snapshot, SIM_restore_snapshot, SIM_delete_snapshot

SIM_is_restoring_snapshot

Name

SIM_is_restoring_snapshot — check if a snapshot is currently being restored

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

bool
SIM_is_restoring_snapshot();

Python

import simics

simics.SIM_is_restoring_snapshot(...)

Description

Returns true if an in-memory snapshot is currently being restored.

Execution Context

Cell Context

SIM_list_snapshots

Name

SIM_list_snapshots — list snapshots

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

attr_value_t
SIM_list_snapshots();

Python

import simics

simics.SIM_list_snapshots(...)

Description

Returns a list of the names of the currently taken snapshots.

Execution Context

Global Context

See Also

SIM_take_snapshot, SIM_restore_snapshot, SIM_delete_snapshot, SIM_get_snapshot_info

SIM_object_class

Name

SIM_object_class — get object class

Synopsis

C and DML

#include <simics/device-api.h> // in C
// always available in DML

FORCE_INLINE conf_class_t *
SIM_object_class(const conf_object_t *NOTNULL obj);

Python

import simics

simics.SIM_object_class(...)

Description

Returns the class of an object.

Execution Context

Cell Context

See Also

SIM_get_class

SIM_object_descendant

Name

SIM_object_descendant — return a descendant of the specified object

Synopsis

C and DML

#include <simics/device-api.h> // in C
// always available in DML

conf_object_t *
SIM_object_descendant(conf_object_t *obj, const char *NOTNULL relname);

Python

import simics

simics.SIM_object_descendant(...)

Description

This function returns the descendant object of obj which has the relative name relname, or nullptr if no such object exists.

It is legal for the relative name to contain multiple components, like “device.p.RESET”.

If obj is nullptr, then the object lookup is performed relative the object hierarchy root.

If obj is instantiated at the same time as the descendant, then the function is guaranteed to succeed if called after the alloc_object phase of object initialization; i.e., it is safe for obj to invoke the function from its init_object method.

Return Value

Object, or nullptr if the object has no hierarchical descendant with the specified relative name.

See Also

SIM_object_parent, SIM_register_port

Execution Context

Cell Context

SIM_object_is_processor

Name

SIM_object_is_processor — test if object is a processor

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

bool
SIM_object_is_processor(conf_object_t *NOTNULL obj);

Python

import simics

simics.SIM_object_is_processor(...)

Description

Returns non-zero if obj is a processor.

Execution Context

All contexts (including Threaded Context)

SIM_object_iterator

Name

SIM_object_iterator — start object iteration

Synopsis

C and DML

#include <simics/device-api.h> // in C
// always available in DML

object_iter_t
SIM_object_iterator(conf_object_t *obj);

Python

import simics

simics.SIM_object_iterator(...)

Description

The SIM_object_iterator function returns an iterator for the descendants of the object obj. If obj is nullptr, then the returned iterator will iterate over all objects in the configuration.

The iterator returns objects sorted by name, with parents before children.

Return Value

Object iterator

Example

Sample C code to find all objects implementing signal interface:

#include <simics/util/vect.h>
#include <simics/devs/signal.h>

...

VECT(conf_object_t *) v = VNULL;
object_iter_t it = SIM_object_iterator(nullptr);
conf_object_t *obj;
while ((obj = SIM_object_iterator_next(&it)) != nullptr) {
    if (SIM_C_GET_INTERFACE(obj, signal) != nullptr)
        VADD(v, obj);
}
...  // any code using 'v' vector here
VFREE(v);

Sample Python code to find all objects implementing signal interface:

v = []
for obj in SIM_object_iterator(None):
    if hasattr(obj.iface, simics.SIGNAL_INTERFACE):
        v.append(obj)

The simics.SIGNAL_INTERFACE constant from the above example holds "signal" string. Such constants are available for some interfaces. One can safely use string literals instead.

See Also

SIM_object_iterator_next, SIM_shallow_object_iterator, SIM_object_iterator_for_class, SIM_object_iterator_for_interface

Execution Context

Cell Context

SIM_object_iterator_for_class

Name

SIM_object_iterator_for_class — start class instance iteration

Synopsis

C and DML

#include <simics/device-api.h> // in C
// always available in DML

object_iter_t
SIM_object_iterator_for_class(conf_class_t *cls);

Python

import simics

simics.SIM_object_iterator_for_class(...)

Description

The SIM_object_iterator_for_class function returns an iterator for the instances of the class cls. See SIM_object_iterator for examples on how to use the iterator.

Return Value

Object iterator

See Also

SIM_object_iterator_next, SIM_object_iterator, SIM_object_iterator_for_interface

Execution Context

Cell Context

SIM_object_iterator_for_interface

Name

SIM_object_iterator_for_interface — start class instance iteration

Synopsis

C and DML

#include <simics/device-api.h> // in C
// always available in DML

object_iter_t
SIM_object_iterator_for_interface(attr_value_t ifaces);

Python

import simics

simics.SIM_object_iterator_for_interface(...)

Description

The SIM_object_iterator_for_interface function returns an iterator for the objects that implement all interfaces in ifaces (i.e. all objects if ifaces is empty), which must be a list of strings of length at most 16. See SIM_object_iterator for examples on how to use the iterator.

Return Value

Object iterator

See Also

SIM_object_iterator_next, SIM_object_iterator, SIM_object_iterator_for_class

Exceptions

SimExc_General Thrown if the ifaces argument does not conform to the above requirements.

Execution Context

Cell Context

SIM_object_iterator_next

Name

SIM_object_iterator_next — get next object

Synopsis

C and DML

#include <simics/device-api.h> // in C
// always available in DML

conf_object_t *
SIM_object_iterator_next(object_iter_t *iter);

Description

The SIM_object_iterator_next function returns the next object from an iterator obtained from SIM_object_iterator or SIM_shallow_object_iterator. If there are no more objects in the sequence, then nullptr is returned.

It is illegal to call SIM_object_iterator_next using an iterator which has reached the end of its sequence.

Return Value

Next object or nullptr.

See Also

SIM_object_iterator_next, SIM_object_iterator

Execution Context

Cell Context

SIM_object_parent

Name

SIM_object_parent — get object parent

Synopsis

C and DML

#include <simics/device-api.h> // in C
// always available in DML

conf_object_t *
SIM_object_parent(conf_object_t *NOTNULL obj);

Python

import simics

simics.SIM_object_parent(...)

Description

Returns the hierarchical parent of the specified object.

Return Value

Object, or nullptr if the object has no hierarchical parent.

See Also

SIM_object_descendant, SIM_port_object_parent

Execution Context

Cell Context

SIM_port_object_parent

Name

SIM_port_object_parent — get object parent

Synopsis

C and DML

#include <simics/device-api.h> // in C
// always available in DML

conf_object_t *
SIM_port_object_parent(conf_object_t *NOTNULL obj);

Python

import simics

simics.SIM_port_object_parent(...)

Description

Returns the parent of the specified port object.

Return Value

Object, or nullptr if the object is not a port object.

See Also

SIM_object_parent, SIM_object_descendant

Execution Context

Cell Context

SIM_printf_error, SIM_printf_error_vararg

Name

SIM_printf_error, SIM_printf_error_vararg — print error message

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

void
SIM_printf_error(const char *format, ...);

// not available in DML

void
SIM_printf_error_vararg(const char *format, va_list ap);

Python

import simics

simics.SIM_printf_error(...)

Description

This can be used to print an error message during the simulation. It is analogous to log error messages, but for non-device code. I.e. it should be used for errors that prevents the simulation from continuing.

See Also

SIM_printf_warning

SIM_printf_warning, SIM_printf_warning_vararg

Name

SIM_printf_warning, SIM_printf_warning_vararg — print warning message

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

void
SIM_printf_warning(const char *format, ...);

// not available in DML

void
SIM_printf_warning_vararg(const char *format, va_list ap);

Python

import simics

simics.SIM_printf_warning(...)

Description

This can be used to print a warning message during the simulation. It is analogous to log warning messages, but for non-device code. I.e. it should be used for problems that do not prevent the simulation from continuing.

See Also

SIM_printf_error

SIM_read_configuration

Name

SIM_read_configuration — read configuration

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

void
SIM_read_configuration(const char *NOTNULL file);

Python

import simics

simics.SIM_read_configuration(...)

Description

Read configuration from filename and create a machine accordingly.

Exceptions

SimExc_General Thrown if the file could not be opened, the machine was already initialized, or if an error in the configuration file was detected.

Execution Context

Global Context

SIM_register_context_handler

Name

SIM_register_context_handler — register mandatory interface and attribute for context handler objects

Synopsis

C and DML

#include <simics/processor-api.h> // in C
import "simics/processor-api.dml"; // in DML

int
SIM_register_context_handler(conf_class_t *NOTNULL cls,
                             const context_handler_interface_t *NOTNULL iface);

Python

import simics

simics.SIM_register_context_handler(...)

Description

Register the cls class as a class for context handler objects. This includes registering the context_handler interface (iface), in addition to which SIM_register_context_handler registers a current_context attribute which will hold the current context.

The context_handler interface will be wrapped by standard functions so that standard context change behavior is taken care off automatically. This includes, among other things, making sure that the context is valid, and triggering the correct haps on context changes. Thus the context_handler implementation need only care about the effect of the change on the context_handler object itself (virtual breakpoints present in the context, cache flushing, etc.).

Return Value

The return value is 0 if everything works, and non-zero if something fails. SIM_register_context_handler will return the error value provided by SIM_register_interface.

Exceptions

SimExc_General Thrown if the context_handler interface has already been registered for this class.

Execution Context

Global Context

See Also

SIM_register_interface

SIM_restore_snapshot

Name

SIM_restore_snapshot — restore a snapshot of the configuration state

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

snapshot_error_t
SIM_restore_snapshot(const char *name);

Python

import simics

simics.SIM_restore_snapshot(...)

Description

Restores the state of the configuration to a previously taken snapshot.

Execution Context

Global Context

See Also

SIM_take_snapshot, SIM_delete_snapshot, SIM_list_snapshots

SIM_set_attribute, SIM_set_attribute_idx

Name

SIM_set_attribute, SIM_set_attribute_idx — set attribute

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

set_error_t
SIM_set_attribute(conf_object_t *NOTNULL obj,
                  const char *NOTNULL name,
                  attr_value_t *NOTNULL value);

set_error_t
SIM_set_attribute_idx(conf_object_t *NOTNULL obj,
                      const char *NOTNULL name,
                      attr_value_t *NOTNULL index,
                      attr_value_t *NOTNULL value);

Python

import simics

simics.SIM_set_attribute(...)
simics.SIM_set_attribute_idx(...)

Description

Set the name attribute in obj to value.

The _idx version of the function can be used to get a single entry in a list or data attribute. For this to work, the attribute must support indexing.

After the call the value is still owned by the caller.

If the attribute setter function calls SIM_attribute_error or SIM_c_attribute_error and returns Sim_Set_Ok, it is treated like Sim_Set_Illegal_Value.

Return Value

The return value is from the set_error_t enum, with Sim_Set_Ok indicating success.

Exceptions

SimExc_AttrNotFound If the object did not have the specified attribute

SimExc_AttrNotWritable if the attribute cannot not be written

SimExc_Type if the index has the wrong type, the value to be set does not match the type specified by the attribute or the setter function returned Sim_Set_Illegal_Type

SimExc_IllegalValue if the setter function returned Sim_Set_Illegal_Value

SimExc_Index if the setter function returned Sim_Set_Illegal_Index

SimExc_InterfaceNotFound if the setter function returned Sim_Set_Interface_Not_Found

SimExc_General if the setter function returned something else than Sim_Set_Ok, Sim_Set_Illegal_Type, Sim_Set_Illegal_Value, Sim_Set_Illegal_Index or Sim_Set_Interface_Not_Found.

Execution Context

Global Context in general; individual attributes may be less constrained.

See Also

SIM_get_attribute, SIM_attribute_error, set_error_t

SIM_set_class_attribute, SIM_set_class_attribute_idx

Name

SIM_set_class_attribute, SIM_set_class_attribute_idx — set class attribute

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

set_error_t
SIM_set_class_attribute(conf_class_t *NOTNULL cls,
                        const char *NOTNULL name,
                        attr_value_t *NOTNULL value);

set_error_t
SIM_set_class_attribute_idx(conf_class_t *NOTNULL cls,
                            const char *NOTNULL name,
                            attr_value_t *NOTNULL index,
                            attr_value_t *NOTNULL value);

Python

import simics

simics.SIM_set_class_attribute(...)
simics.SIM_set_class_attribute_idx(...)

Description

Set the name attribute in cls to value.

The _idx version of the function can be used to set a single entry in a list or data attribute. For this to work, the attribute must support indexing.

After the call the value is still owned by the caller.

Return Value

The return value is from the set_error_t enum, with Sim_Set_Ok indicating success.

Execution Context

Global Context

See Also

SIM_get_attribute, set_error_t

SIM_set_configuration

Name

SIM_set_configuration — set configuration from data

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

void
SIM_set_configuration(attr_value_t conf);

Python

import simics

simics.SIM_set_configuration(...)

import configuration

configuration.OBJECT(name, objclass, **attrs)
class configuration.OBJ(name)

Description

It is recommended that the SIM_add_configuration function is used instead of SIM_set_configuration.

This function is an alternative to reading the configuration from a file. A configuration is an attr_value_t which should have the following structure.

(("name", "class",  ("attr_name", attr_val) ... ), ... )

That is a list of object specifiers containing name, class, and a list of attribute specifiers. An attribute specifier is a list of length 2 containing the attribute name and its value. SIM_set_configuration allows an easy way of parameterizing the configuration, especially if called from Python.

The argument value may be modified, but the caller is still responsible for freeing it. Neither point applies when the function is called from Python.

Example

The following is a Python example:

from configuration import OBJ
from simics import SIM_set_configuration

SIM_set_configuration([
 ["cpu0", "x86",
  ["queue", OBJ("cpu0")],
  ["freq_mhz", 20],
  ["physical_memory", OBJ("phys_mem0")]],

 ["phys_mem0", "memory-space",
  ["map",  [[0xa0000,    OBJ("vga0"),    1, 0, 0x20000],
            [0x00000,    OBJ("mem0"),    0, 0x00000, 0xA0000],
            [0xc0000,    OBJ("mem0"),    0, 0xc0000, 0x8000],
            [0xc8000,    OBJ("setmem0"), 0, 0, 0x28000],
            [0xf0000,    OBJ("mem0"),    0, 0xf0000, 0x10000],
            [0x100000,   OBJ("mem0"),    0, 0x100000, 0x3ff00000],
            [0xfee00000, OBJ("apic0"),   0, 0, 0x4000]]]],
    ... ])

Exceptions

SimExc_Attribute Thrown if malformed configuration list.

SimExc_General Thrown if Simics fails to initialize all objects.

Execution Context

Global Context

See Also

SIM_add_configuration, SIM_create_object

SIM_shallow_object_iterator

Name

SIM_shallow_object_iterator — start object iteration

Synopsis

C and DML

#include <simics/device-api.h> // in C
// always available in DML

object_iter_t
SIM_shallow_object_iterator(conf_object_t *obj);

Python

import simics

simics.SIM_shallow_object_iterator(...)

Description

The SIM_shallow_object_iterator function returns an iterator for the direct children of the object obj. If obj is nullptr, then the returned iterator will iterate over objects on the root level.

The iterator returns objects sorted by name.

Return Value

Object iterator

See Also

SIM_object_iterator_next, SIM_object_iterator

Execution Context

Cell Context

SIM_take_snapshot

Name

SIM_take_snapshot — take snapshot of the current configuration

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

snapshot_error_t
SIM_take_snapshot(const char *name);

Python

import simics

simics.SIM_take_snapshot(...)

Description

Takes an in-memory snapshot of the state of all objects. Objects whose class_kind_t is equal to Sim_Class_Kind_Pseudo are not saved. This also holds for attributes (in all objects) of type Sim_Attr_Pseudo.

Execution Context

Global Context

See Also

SIM_restore_snapshot, SIM_delete_snapshot, SIM_list_snapshots

SIM_write_configuration_to_file

Name

SIM_write_configuration_to_file — write configuration

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

void
SIM_write_configuration_to_file(const char *NOTNULL file, save_flags_t flags);

Python

import simics

simics.SIM_write_configuration_to_file(...)

Description

Saves all objects to filename. Objects whose class_kind_t is equal to Sim_Class_Kind_Session or Sim_Class_Kind_Pseudo are not saved. This also holds for attributes (in all objects) of type Sim_Attr_Pseudo.

The flags argument should be 0.

Execution Context

Global Context

SIM_write_persistent_state

Name

SIM_write_persistent_state — save persistent state

Synopsis

C and DML

#include <simics/simulator-api.h> // in C
import "simics/simulator-api.dml"; // in DML

void
SIM_write_persistent_state(const char *file, conf_object_t *root,
                                    save_flags_t flags);

Python

import simics

simics.SIM_write_persistent_state(...)

Description

Saves the persistent state to a file. Persistent data typically includes disk images, NVRAM and flash memory contents and clock settings, i.e data that survives reboots. The Persistent state is saved as a standard simics configuration.

Execution Context

Global Context

Breakpoints Embedding Simics