HOME       UP       PREV       FURTHER NOTES       NEXT (TLM - Measuring Utilisation and Modelling Contention)  

TLM Modelling: Adding Timing Annotations Continued

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
  // The delay variable records how far ahead of kernel time this thread has advanced.
  void b_putbyte(char d, sc_time &delay)
  {
    ...
    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:
   wait(delay);   
   delay = 0;
// Note: delay has units sc_time so the SystemC overload of waitis called, not the O/S posix wait.

Important point: With frequent resynchs, simulation performance is reduced but true transaction ordering is modelled more closely.


28: (C) 2008-17, DJ Greaves, University of Cambridge, Computer Laboratory.