This application note provides a checklist for use when developing models of devices and systems for Simics. The intention is to help developers with creating high quality models that work well in Simics, including future versions, that behave in a way that Simics users expect models to, and that can be used together with other device models easily.
This section describes important generic items that should be taken into consideration when working with Simics. This applies if one is writing device models, components or general functionality to extend Simics.
For more information refer to the sections about events and attributes in "Programming with DML", the section about general usability in "Building Well-Behaved Models" and the section about configuration attributes in "Overview" in the Model Builder User's Guide. Also refer to the section "Configuration and Checkpointing" in the Simics User's Guide
For more information refer to the sections about events and attributes in "Programming with DML", the section about general usability in "Building Well-Behaved Models" and the section about configuration attributes in "Overview" in the Model Builder User's Guide. Also refer to the section "Configuration and Checkpointing" in the Simics User's Guide
The latest API is documented in the Reference Manuals included in each Simics package.
For more information see the section about Simics interfaces in "Overview" in the Model Builder User's Guide. The standard interfaces are documented in the Reference Manuals included in each Simics package.
-O2 -Wall -Werror.For more information refer to the section about general usability in "Building Well-Behaved Models" in the Model Builder User's Guide.
SIMICS_MEMORY_TRACKING before starting Simics and enable internal
commands, using the
enable-unsupported-feature "malloc-debug" command.
For more information see the application note on Debugging User-Developed Simics Modules.
For more information refer to the sections about attributes in "Programming with DML" and the section about configuration attributes in "Overview" in the Model Builder User's Guide.
For more information refer to the sections about structuring DML code in "Building Well-Behaved Models" and "Adding New Commands" in the Model Builder User's Guide.
-comp suffix.list-objects.
Look at the existing naming for things not covered by the guidelines here.
This is essential for reverse execution to work correctly, and greatly helps in pinpointing bugs, as those are guaranteed to be repeatable in a deterministic simulation.
For more information refer to the section about general usability in "Building Well-Behaved Models" in the Model Builder User's Guide.
legacy_. Make sure your
system works with all such settings turned off. Also run Simics with the
-wdeprecated command line argument and make sure that there are
no run-time warnings generated during simulation.
This section describes important items that, in addition to the generic checklist, should be taken into consideration when writing device models. For more in depth understanding of the importance of these items, please refer to the Model Builder User's Guide.
signal interface should be used as input with
one port interface for each reset input.A message is most of the time a fragment or, more rarely, one or more complete sentences. If it is a fragment, the message shall start with a lowercase letter (with the obvious exception for words and abbreviations that shall start with an uppercase letter) and have no period at the end. Sentences shall start with an uppercase letter and end with a period.
In DML, a typical log statement may read: log info, 2, 0: "increased
counter: %d", value;.
Do not use exclamation marks and avoid question marks. Multiple question marks in a row shall never be used.
Do not start an "info" message with the words "error", "unimplemented" or "spec_violation", use the appropriate log-type instead.
Do not start an "error" message with the word "error", it is just a repetition. The word "error" might be appropriate inside the message but should in most circumstances be avoided. Same goes for the "critical", "spec_violation", and "unimplemented" log-types.
Do not use newlines, in particular not at the end of the message. Also do not use multiple log statements to output longer messages, include everything in one statement. It is up to the presentation layer to output a long message in a readable format.
Do not mention the name of the object or class which the message refers to, as it is implicitly given by the log statement and output in the log message prefix.
For abbreviations and other special words, write them as specified in the
"Dictionary" chapter of the "Writing Documentation" manual or in the
src/docs/common/simics-documentation-word-list or
src/docs/internal/documentation-manual/usage.docu files.
Here are some examples: IRQ, DMA, CPU, CPUs.
A message followed by a more specific message, such as:
"can't open file "abc": no such file or directory"
should be (as above) separated by a colon. If even more specific messages
follow, these are also appended using a colon as separator.
A message which contains some extra information at the end should be written
as: "read from register XYZ (value = 0x5000)"
Do not use cryptic abbreviations such as @, addr, idx, reg, len. Instead use: at, address, index, register, length
Do not use variable names (if they aren't complete words) in log messages with log levels 1-3. If values are output, it should be possible to understand what the value represents without reading the source code. I.e. it should be possible to understand the log message without reading the source code.
Do not use assert statements on conditions that can be triggered by users, see GE-15.
Use pre-defined DML templates for different implementations. Log level is
automatically handled in some of these templates. For example, reserved,
unimplemented and read_only. Full list and descriptions about
these templates can be found in the Model Builder DML 1.2 reference
manual.
Spec-violation and unimplemented messages are typically logged on level 1. Sometimes they are first logged at log level 1 then log level 3 for spam reduction when unimplemented registers or features are always accessed. log level 3 should be avoided for spec-violation.
For more information refer to "Logging" in the Model Builder User's Guide.
SIM_ Functions when Modeling
BehaviorSIM_ and
internal VT_ functions as far as possible. Such functions
are mainly intended for simulator specifics such as configuration and logging,
but not to model the actual device. Simics interfaces should be used instead
to communicate with other objects that a device is connected to. The most
common exceptions are SIM_ functions used to access fields in the
generic_transaction_t, timing API functions and event API functions
for devices not written in DML.For more information see the section about Simics interfaces in "Overview" in the Model Builder User's Guide. The standard interfaces are documented in the Reference Manuals included in each Simics package.
The image interface on objects of the Simics
image class provides a way to
mark an image object as holding persistent data. Custom disk and storage
models must call this interface on their associated image objects, if
they are persistent.
Device register and device state saved in attributes are marked as
persistent by using the Sim_Attr_Persistent flag on the attribute
when it is registered with Simics.
For NVRAMs the persistent-ram class can be used.
For more information see the section about saving and restoring persistent data in "Configuration and Checkpointing" in the Simics User's Guide
<ul> <li>The X device does not implement Y hashing.</li> <li>The Z feature does not work with the Windows 7 driver.</li> <li>...</li> </ul>
See the DML Reference Manual for more information.
Unimplemented registers, or registers with limited functionality, should use
the standard Simics log mechanism with the Sim_Log_Unimplemented type
to log any accesses.
int_register interface if it
has to access registers in another object directly. The typical case is for
objects that represent tightly coupled devices. In other situations the devices
can use the architecturally specified way of communicating, for example by
doing memory mapped accesses or sending bus transactions if a bus interface
exists.
The int_register interface is documented in the
Simics Reference Manual
signal
interface unless reset is already part of some technology specific interface
such as the pci_device interface.SIM_ functions.
For more information see the section on Ethernet transceiver in "Modeling Ethernet Devices" in the Model Builder User's Guide.
ieee_802_3_phy_v3 interface. This interface is
used when communicating with PHY devices.mac_address attribute.
signal Interface Ports for
Inputsignal type.
bios attribute that is the image file for the
expansion ROM.
This section describes important items that, in addition to the generic checklist, should be taken into consideration when writing processor models. For more information about processor models, see the Processor Model Integration Guide.
This section describes important items that, in addition to the generic checklist, should be taken into consideration when writing components. For more in depth understanding of the importance of these items, please refer to the Model Builder User's Guide.
eth_adapter — basename for Ethernet PCI cards.ethernet — ethernet-link connector name for components with
a single ethernet-link connector.cpu_frequencynum_cpusnum_coresmemory_megs — for components with RAM.rtc_time — format: "YYYY-MM-DD HH:MM:SS Z".mac_address — single Ethernet device.mac_address0, mac_address1, ...
— multiple Ethernet devices.size — for disk components.
pre_instantiate method. The
connect_<connection>(), add_objects() and
post_instantiate() methods should never trigger any errors.
This section describes important items that, in addition to the generic checklist, should be taken into consideration when assembling a larger system. See also the "Target Script Checklist".
This section describes important items that, in addition to previous checklists, should be taken into consideration when writing the target scripts for a virtual platforms.
.simics and .include scripts for a machine
should follow the guidelines in the section about ready-to-run
configurations in "Configuration and Checkpointing" in
the Simics User's Guide. For
example the setup of the simulated hardware should be separate from the
software configuration. See also "System Configurations" in the
Model Builder User's Guide.
.simics
Scripts.simics file from scratch.
Scripts that require other files to have run first, or require CLI variables to
be set, should have the .include suffix.%simics% path marker can be
used to reference other scripts in a Simics project, the same, or other
packages.
<architecture>-system.include) should create
the top level component with the name configured by the $machine_name
variable. If this variable is not set, it should default to the system name.
The name of the created component should then be saved in $system. It
will typically be the same as $machine_name unless there is a name
collision. See also "System Configurations" in the
Model Builder User's Guide.
For example:
(in decl) param machine_name : string = "board" $system = (create-chassis-qsp-x86 name = $machine_name)
As a result, multiple machines can be instantiated in the following way:
$machine_name = machine1 run-command-file "%simics%/targets/qsp-x86/firststeps.simics" $machine_name = machine2 run-command-file "%simics%/targets/qsp-x86/firststeps.simics"
The old component prefix support should not be used anymore as it will be removed in the future.
targets/common/add-eth-link.include script to create a simulated
Ethernet network and to configure the service-node.
$cpu_cores.$num_cpus
would be misleading.$disk_image, if it cannot be
automatically determined from the file."YYYY-MM-DD HH:MM:SS UTC" format.The following variables are automatically supported if the
targets/common/add-eth-link.include script is used to create a
virtual Ethernet network. Scripts creating their own Ethernet network without
using add-eth-link.include should support some subset of these
variables.
$service_node object on the
$eth_link link.$service_node. Set to 0 to disable DHCP.$eth_link link.$eth_link link, used in
distributed simulation.$host_name variable and then running the target start script (with the
-local flag) without getting any conflicts.
software slot with an
os_awareness component in it. This is typically created in the
<architecture>-system.include script:
new-os-awareness $system.software
If the OS awareness framework in Simics supports the operating system that is
configured on the machine, then a parameter file should be created that matches
the operating system and that is loaded in the software setup script (i.e. the
<architecture>-<software>-setup.include file), typically
using:
$system.software.load-parameters <architecture>-<software>.params
For more details refer to the section "OS Awareness Details" in the Analyzer User's Guide.
$console = (new-text-console-comp) $console.con->title = "new title"
When referencing component and objects created by another machine script, the
$system variable (ST-08) will provide a reference to the
top-level component created by that script.