I cannot find an example in the Simics documentation on how the clock object is obtained so that we can use it as an argument in the post()
method.
I suspect that either
- an attribute can be used to get the clock or
- in the ConfObject class scope we get the clock using SIM_object_clock()
I created a new module using bin\project-setup --py-device event-py
I have defined two methods in the ConfObject
class scope called clock_set
and clock_get
.
I wanted to use these methods so that I can set/get the clock object to use in the post method.
The post()
method fails when reading the device registers in the vacuum machine.
import pyobj
# Tie code to specific API, simplifying upgrade to new major version
import simics_6_api as simics
class event_py(pyobj.ConfObject):
"""This is the long-winded documentation for this Simics class.
It can be as long as you want."""
_class_desc = "one-line doc for the class"
_do_not_init = object()
def _initialize(self):
super()._initialize()
def _info(self):
return []
def _status(self):
return [("Registers", [("value", self.value.val)])]
def getter(self):
return self
# In my mind, clock_set is supposed to set the clock object. That way we can use
# it in post()
def clock_set(self):
self.clock = simics.SIM_object_clock(self)
def clock_get(self):
return self.clock(self):
class value(pyobj.SimpleAttribute(0, 'i')):
"""The <i>value</i> register."""
class ev1(pyobj.Event):
def callback(self, data):
return 'ev1 with %s' % data
class regs(pyobj.Port):
class io_memory(pyobj.Interface):
def operation(self, mop, info):
offset = (simics.SIM_get_mem_op_physical_address(mop)
+ info.start - info.base)
size = simics.SIM_get_mem_op_size(mop)
if offset == 0x00 and size == 1:
if simics.SIM_mem_op_is_read(mop):
val = self._up._up.value.val
simics.SIM_set_mem_op_value_le(mop, val)
# POST HERE AS TEST self._up._up.ev1.post(clock, val, seconds = 1)
else:
val = simics.SIM_get_mem_op_value_le(mop)
self._up._up.value.val = val
return simics.Sim_PE_No_Exception
else:
return simics.Sim_PE_IO_Error