Previous - Up - Next

2.2   Loading And Testing

To test your new module, start Simics and load the example machine configuration vacuum, as follows (from the [home]/workspace directory):

  $ ./simics targets/vacuum/vacuum.simics

The vacuum machine is a minimal configuarion that contains only a clock and a memory space, called phys_mem, with some RAM mapped at addresses 0x10000000 to 0x1fffffff.

At the Simics prompt, type the list-modules command to see if your module appears on the list:

  simics> list-modules

Som of the modules in the list will have Loaded printed in the second columnt, but not your new module. You can load it using the load-module command:

  simics> load-module simple_device

If the module was successfully loaded, it should now be marked as loaded in the output from by the list-modules command.

You can also try the list-classes command to see if your device apears in the list of available models. It should appear in this list even if you have not loaded the module yet. Normally, modules are loaded automatically when you try to use them, so the load-module command is mostly used for testing.

To test the new model, we first of all need to create an instance of the device class. This can be done with the following command:

  simics> @SIM_create_object("simple_device", "dev1", [])
(the @ operator on the Simics command line executes the rest of the line as a Python expression), which uses the Simics API directly to create a new object named dev1.

To be able to communicate with the device object, it must be mapped into the physical memory space of the machine. This can be done using the <memory-space>.add-map command.

  simics> phys_mem.add-map dev1 0x1000 0x100 0

The first argument is the device to map, in this case our newly created object dev1. The following arguments are the base address within the memory space and the size of the mapped range. The fourth argument is the function number which is used by the device model to choose which register bank will handle the accesses to this mapping. In this example, we have a mapping from the range 0x1000-0x10ff (0x100 bytes) to the range 0-0xff of function 0 (bank b) of the device object dev1.

We can now try to read from register r0 of our device. (Since it has internal offset 0, it will correspond to address 0x1000 of the physical memory.) Use the get method of the memory space to simulate a read operation:

  simics> phys_mem.get 0x1000
(do not use the @ operator here). You should see the following output:
  [dev1 info] Hello, bus!
  42
The first line is the info message printed by the log statement in the read method of r0, and the second is the value that was returned by get. The device is working!

Previous - Up - Next