The preferred loosely-timed coding style is more efficient: we pass a time accumulator variable called `delay' around for various models to augment where time would pass (clearly this causes far fewer entries to the SystemC kernel):
  // Preferred coding style
  putbyte(char d, sc_time &delay)  // The delay variable records how far ahead of kernel time this thread has advanced.
  {
    ...
    delay += sc_time(140, SC_NS); // It should be increment at each point where time would pass...
  }
The leading ampersand on delay is the C++ denotation for pass by reference. But, at any point, any thread can resynch itself with the kernel by performing
// Resynch idiomatic form: sc_wait(delay); delay = 0;
Important note: Simulation performance is reduced when there are frequent resynchs, but true transaction ordering will be modelled correctly.
| 42: (C) 2008-15, DJ Greaves, University of Cambridge, Computer Laboratory. |