33 Attributes Object Lifetime
Model Builder User’s Guide  /  VI Simics API  / 

34 Object Hierarchy

Simics objects are stored in an object hierarchy. The hierarchy allows objects to be grouped logically, making it easier to navigate complex configurations. The object hierarchy also serves a secondary purpose: it allows child objects to provide functionality to parent objects.

Starting with Simics 6, objects can be created in the namespace of another object almost without restrictions. In previous versions, the object hierarchy was tightly coupled to the component concept.

34.1 Accessing Objects

Several API functions exist for querying the object hierarchy:

In Python, the root of the object hierarchy is the conf namespace, and child objects can be specified using the dot operator, as in the example conf.parent.child. If a child object and an attribute has the same name, then the child object has precedence. Object attributes can be accessed unambiguously using the attr namespace, e.g. object.attr.attribute.

34.2 Object Creation

Simics objects can be created in the namespace of a another object by simply providing a hierarchical name. This is illustrated in the following example which creates the objects testbench, testbench.ram and testbench.ram.image.

tb = simics.pre_conf_object('testbench', 'namespace')
image = simics.pre_conf_object('testbench.ram.image', 'image', size = 0x1000)
ram = simics.pre_conf_object('testbench.ram', 'ram')
ram(image = image)

simics.SIM_add_configuration([tb, image, ram], None)

The pre_conf_object class also allows the configuration to be built hierarchically, which is illustrated in the following example:

tb2 = simics.pre_conf_object('testbench2', 'namespace')
tb2.image = simics.pre_conf_object('image', size = 0x1000)
tb2.image.ram = simics.pre_conf_object('ram')
tb2.image.ram(image = tb2.image)

simics.SIM_add_configuration([tb2], None)

Hierarchical object names can also be passed directly to e.g. SIM_create_object:

simics.SIM_create_object("memory-space", "testbench.pspace", [])

34.3 Special Object Classes

There are two basic Simics classes which often are useful when building the object hierarchy. The first one is the namespace class which basically is an “empty” Simics class without any custom attributes or interfaces. The second class is the index-map class, which is used by Simics to represent object maps.

As an example, the objects alpha[0], alpha[1] and alpha[2] are children of the object index-map object alpha. Nested index maps are used to construct multi-dimensional object maps, e.g. beta[1][2][3].

Simics adds index-maps automatically during object creation when necessary, but sometimes it is useful to create the index map object explicitly, like in the example below:

array = simics.pre_conf_object('array', 'index-map')
array[0] = simics.pre_conf_object('memory-space')
array[1] = simics.pre_conf_object('memory-space')

simics.SIM_add_configuration([array], None)

34.4 Naming Conventions

Simics does not impose any rules how child objects should be named. It is, however, recommended that the following conventions are followed in order to make it easy for a user to understand the purpose of a particular object:

Objects under the port namespace should be used for objects implementing interfaces on behalf of object.

The bank namespace is used for objects implementing register banks on behalf of object.

The object.port and object.bank objects are just plain namespaces. For specific objects, there might also be other namespaces that have been assigned a special meaning:

All CPUs have a vtime object which handles event dispatching. Below this objects there are objects implementing event queues used by the CPU. There are normally at least a cycles object which contains the cycle based event queue and a ps object which holds the pico-seconds based event queue.

34.5 Clock and Cell Inheritance

Each object in Simics has an associated default clock which, among other things, is used for event posting. The queue attribute is used to explicitly select a clock for a particular object.

In Simics 6, objects without an explicitly assigned clock inherit a default one from their respective parents. Thus, in many cases it is sufficient to just set the queue attribute for a single object and all descendants will inherit the clock implicitly.

Note that the queue attribute reflects the explicitly assigned clock. The SIM_object_clock function can be used to retrieve the default clock for a particular object.

Cell membership is also inherited hierarchically.

33 Attributes Object Lifetime