Previous - Up - Next

3.10   Implements

When a device needs to export Simics interfaces (such as the io_memory interface defined in the standard library file io-memory.dml), this is specified by an implement object, containing the methods that implement the interface. The name of the object is also used as the name of the Simics interface registered for the generated device, and the names and signatures of the methods must correspond to the C functions of the Simics interface. (A device object pointer is automatically added as the first parameter of the generated C functions.)

By default, the C type of the Simics interface is assumed to be the name of the object itself with the string "_interface_t" appended. (The C type is typically a typedef:ed name for a struct containing function pointers.) This can be changed by specifying an explicit c_type parameter in the interface object.

For example, to create an alternative implementation of io_memory, we can write:

    implement io_memory {
      method map(addr_space_t sp, map_info_t info)
             -> (int status)
      {
        ...
      }
      method operation (generic_transaction_t *op, map_info_t info)
             -> (exception_type_t exc)
      {
        ...
      }
    }

The code generated by dmlc for this example assumes that the io_memory_interface_t is a C struct type with fields map and operation that can hold function pointers of the corresponding types. (The io_memory_interface_t type is defined in the standard library file simics-api.dml, which is automatically included by the dmlc compiler.)

Previous - Up - Next