Services and Modeling for Embedded Software Development
Embecosm divider strip
Prev  Next

9.1.2.  The Global Quantum Class, tlm_global_quantum

TLM 2.0 defines a singleton class[9] which can be used to hold the system global quantum. A set of functions to manipulate the system global quantum are provided.

instance

Returns a reference to the singleton global quantum object

set

Sets the system global quantum (as a SystemC sc_time object)

get

Returns the value of the system global quantum

compute_local_quantum

Returns the local quantum, i.e. the time from the current SystemC time stamp to the next multiple of the system global quantum.

The intention is that at start up the main program should set the system global quantum in the singleton tlm_global_quantum object. All threads can then set their thread global quantum by getting the value from the tlm_global_quantum object.



[9] A singleton is a class of which only one instance can be created. The constructor is declared private (so no other class can create it), and a static function is provided to return the single instance. This static function will create the single instance the first time it is called, and thereafter just return a reference to that same instance.

Singleton classes are useful for holding centrally required values and providing centrally required functions in a system, where having duplicate provision would lead to incorrect behavior.

Embecosm divider strip