113521Sgabeblack@google.com/*****************************************************************************
213521Sgabeblack@google.com
313521Sgabeblack@google.com  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
413521Sgabeblack@google.com  more contributor license agreements.  See the NOTICE file distributed
513521Sgabeblack@google.com  with this work for additional information regarding copyright ownership.
613521Sgabeblack@google.com  Accellera licenses this file to you under the Apache License, Version 2.0
713521Sgabeblack@google.com  (the "License"); you may not use this file except in compliance with the
813521Sgabeblack@google.com  License.  You may obtain a copy of the License at
913521Sgabeblack@google.com
1013521Sgabeblack@google.com    http://www.apache.org/licenses/LICENSE-2.0
1113521Sgabeblack@google.com
1213521Sgabeblack@google.com  Unless required by applicable law or agreed to in writing, software
1313521Sgabeblack@google.com  distributed under the License is distributed on an "AS IS" BASIS,
1413521Sgabeblack@google.com  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1513521Sgabeblack@google.com  implied.  See the License for the specific language governing
1613521Sgabeblack@google.com  permissions and limitations under the License.
1713521Sgabeblack@google.com
1813521Sgabeblack@google.com *****************************************************************************/
1913521Sgabeblack@google.com
2013521Sgabeblack@google.com#ifndef __SYSTEMC_EXT_TLM_CORE_2_QUANTUM_GLOBAL_QUANTUM_HH__
2113521Sgabeblack@google.com#define __SYSTEMC_EXT_TLM_CORE_2_QUANTUM_GLOBAL_QUANTUM_HH__
2213521Sgabeblack@google.com
2313586Sgabeblack@google.com#include "../../../core/sc_time.hh"
2413521Sgabeblack@google.com
2513521Sgabeblack@google.comnamespace tlm
2613521Sgabeblack@google.com{
2713521Sgabeblack@google.com
2813521Sgabeblack@google.com//
2913521Sgabeblack@google.com// tlm_global_quantum class
3013521Sgabeblack@google.com//
3113521Sgabeblack@google.com// The global quantum is the maximum time an initiator can run ahead of
3213521Sgabeblack@google.com// SystemC time. All initiators should synchronize on timingpoints that
3313521Sgabeblack@google.com// are multiples of the global quantum value.
3413521Sgabeblack@google.com//
3513521Sgabeblack@google.com// sc_set_time_resolution can only be called before the first
3613521Sgabeblack@google.com// sc_time object is created. This means that after setting the
3713521Sgabeblack@google.com// global quantum it will not be possible to call sc_set_time_resolution.
3813521Sgabeblack@google.com// If sc_set_time_resolution must be called this must be done before
3913521Sgabeblack@google.com// the global quantum is set.
4013521Sgabeblack@google.com//
4113521Sgabeblack@google.com
4213521Sgabeblack@google.comclass tlm_global_quantum
4313521Sgabeblack@google.com{
4413521Sgabeblack@google.com  public:
4513521Sgabeblack@google.com    //
4613521Sgabeblack@google.com    // Returns a reference to the tlm_global_quantum singleton
4713521Sgabeblack@google.com    //
4813521Sgabeblack@google.com    static tlm_global_quantum &instance();
4913521Sgabeblack@google.com
5013521Sgabeblack@google.com  public:
5113521Sgabeblack@google.com
5213521Sgabeblack@google.com    //
5313521Sgabeblack@google.com    // Setter/getter for the global quantum
5413521Sgabeblack@google.com    //
5513521Sgabeblack@google.com    void set(const sc_core::sc_time &t) { m_global_quantum = t; }
5613521Sgabeblack@google.com    const sc_core::sc_time &get() const { return m_global_quantum; }
5713521Sgabeblack@google.com
5813521Sgabeblack@google.com    //
5913521Sgabeblack@google.com    // This function will calculate the maximum value for the next local
6013521Sgabeblack@google.com    // quantum for an initiator. All initiators should synchronize on
6113521Sgabeblack@google.com    // integer multiples of the global quantum value. The value for the
6213521Sgabeblack@google.com    // local quantum of an initiator can be smaller, but should never be
6313521Sgabeblack@google.com    // greater than the value returned by this method.
6413521Sgabeblack@google.com    //
6513521Sgabeblack@google.com    sc_core::sc_time compute_local_quantum();
6613521Sgabeblack@google.com
6713521Sgabeblack@google.com  protected:
6813521Sgabeblack@google.com    tlm_global_quantum();
6913521Sgabeblack@google.com
7013521Sgabeblack@google.com  protected:
7113521Sgabeblack@google.com    sc_core::sc_time m_global_quantum;
7213521Sgabeblack@google.com};
7313521Sgabeblack@google.com
7413521Sgabeblack@google.com} // namespace tlm
7513521Sgabeblack@google.com
7613521Sgabeblack@google.com#endif /* __SYSTEMC_EXT_TLM_CORE_2_QUANTUM_GLOBAL_QUANTUM_HH__ */
77