global_quantum.hh revision 13521:74fa3ac44057
1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20#ifndef __SYSTEMC_EXT_TLM_CORE_2_QUANTUM_GLOBAL_QUANTUM_HH__ 21#define __SYSTEMC_EXT_TLM_CORE_2_QUANTUM_GLOBAL_QUANTUM_HH__ 22 23#include <systemc> 24 25namespace tlm 26{ 27 28// 29// tlm_global_quantum class 30// 31// The global quantum is the maximum time an initiator can run ahead of 32// SystemC time. All initiators should synchronize on timingpoints that 33// are multiples of the global quantum value. 34// 35// sc_set_time_resolution can only be called before the first 36// sc_time object is created. This means that after setting the 37// global quantum it will not be possible to call sc_set_time_resolution. 38// If sc_set_time_resolution must be called this must be done before 39// the global quantum is set. 40// 41 42class tlm_global_quantum 43{ 44 public: 45 // 46 // Returns a reference to the tlm_global_quantum singleton 47 // 48 static tlm_global_quantum &instance(); 49 50 public: 51 52 // 53 // Setter/getter for the global quantum 54 // 55 void set(const sc_core::sc_time &t) { m_global_quantum = t; } 56 const sc_core::sc_time &get() const { return m_global_quantum; } 57 58 // 59 // This function will calculate the maximum value for the next local 60 // quantum for an initiator. All initiators should synchronize on 61 // integer multiples of the global quantum value. The value for the 62 // local quantum of an initiator can be smaller, but should never be 63 // greater than the value returned by this method. 64 // 65 sc_core::sc_time compute_local_quantum(); 66 67 protected: 68 tlm_global_quantum(); 69 70 protected: 71 sc_core::sc_time m_global_quantum; 72}; 73 74} // namespace tlm 75 76#endif /* __SYSTEMC_EXT_TLM_CORE_2_QUANTUM_GLOBAL_QUANTUM_HH__ */ 77