Previous - Up - Next

13.2   Changing the Behavior of a Memory Transaction

In a Timing Model

An object listening on the timing-model interface is presented with memory transactions before they have been executed, and may therefore change both their semantics and their timing. Here is a list of changes that a timing model is authorized to perform:

Setting mem_op->ignore
If set to 1, the memory transaction will not be executed.
Setting mem_op->reissue
If set to 1 and the memory hierarchy is stalling, the memory transaction will be sent again to the timing model after the stalling was performed. If set to 0, the transaction will be executed without further calls to the timing model.
Setting mem_op->block_STC
If set to 1, the transaction won't be cached in the STCs, ensuring that the next access to the same memory area will be sent to the timing model. Default is 0, unless the transaction has side-effects that would prevent it from being cached.
Stalling the Memory Transaction
By returning a non-zero number of cycles, the operate() function will stall the memory transaction that was passed as argument for that amount of time.

If a zero stall time is returned, some additional operations are allowed:

Setting mem_op->exception
If set to an exception, the transaction will be interrupted and an exception will be taken. Default is no exception (Sim_PE_No_Exception).
Setting mem_op->user_ptr
This void * pointer is not touched by Simics during the memory operation execution. It can be used to pass information from a timing model to a snoop device.
Memory Store Value
Since the memory operation has not been executed yet, it is possible to change the value of a store operation in the timing model. However, it is important to restore the original value in the snoop device once the operation has been performed. The SIM_get_mem_op_value() and SIM_set_mem_op_value() functions (and their variants) can be used to get and set the value of a given memory transaction.

In a Snoop Device

An object listening on the snoop-memory interface is presented with memory transactions after they have completed. It cannot influence the execution of the operation and it may not return a non-zero value for stalling, but it is allowed to modify the value of the memory operation. Since the data returned by read operations are available at this stage, the snoop device is also an ideal place to trace memory transactions.

The following actions are allowed:

Change a Memory Store Value
If the value of a memory store has been changed in the timing model, it should be reset in the snoop device.
Change a Memory Load Value
Since the operation has been performed, the snoop device is the right place to change the value of a load. This is done with the usual SIM_get/set_mem_op_value() functions.

Previous - Up - Next