How to clear pending events of type custom_cycle_event when DML module is reset

33 Views Asked by At

Is there a way to clear pending events of type custom_cycle_event when a DML module is reset?

For events of type simple_cycle_event we call the remove method of the event during reset but Simics documentation specifies the remove method is not supported for custom_cycle_event.

1

There are 1 best solutions below

0
Erik Carstensen On

Cancellation is not possible with the custom_cycle_event. If at most one event can be posted at a given time, then one alternative is to use a simple_cycle_event and pass event data in saved variables when posting:

event e is simple_cycle_event {
  saved int param1;
  saved uint64 param2;
  method event() {
    log info: "%d %d", param1, param2;
  }
}
...
e.post(14);
e.param1 = 7;
e.param2 = 8;
...
e.cancel();

An even better solution may be an after statement:

method event(int param1, uint64 param2) {
  log info: "%d %d", param1, param2;
}
...
group reset_domain {
  method m() {
    after 14 cycles: e.event(7, 8);
  }
}
...
// cancels all `after` statements called by methods
// in this group object 
reset_domain.cancel_after();

The after syntax is more compact and allows the same event method to be called from within different reset domains.

Some background: In DML 1.2, cancellation of custom events was permitted, but it was so error-prone that we couldn't find a single device that provided a correct implementation if the event data was more complex than what a uint64_cycle_event can handle. This is why it was removed it in DML 1.4.