113516Sgabeblack@google.com/***************************************************************************** 213516Sgabeblack@google.com 313516Sgabeblack@google.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 413516Sgabeblack@google.com more contributor license agreements. See the NOTICE file distributed 513516Sgabeblack@google.com with this work for additional information regarding copyright ownership. 613516Sgabeblack@google.com Accellera licenses this file to you under the Apache License, Version 2.0 713516Sgabeblack@google.com (the "License"); you may not use this file except in compliance with the 813516Sgabeblack@google.com License. You may obtain a copy of the License at 913516Sgabeblack@google.com 1013516Sgabeblack@google.com http://www.apache.org/licenses/LICENSE-2.0 1113516Sgabeblack@google.com 1213516Sgabeblack@google.com Unless required by applicable law or agreed to in writing, software 1313516Sgabeblack@google.com distributed under the License is distributed on an "AS IS" BASIS, 1413516Sgabeblack@google.com WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1513516Sgabeblack@google.com implied. See the License for the specific language governing 1613516Sgabeblack@google.com permissions and limitations under the License. 1713516Sgabeblack@google.com 1813516Sgabeblack@google.com *****************************************************************************/ 1913516Sgabeblack@google.com 2013586Sgabeblack@google.com#include "systemc/ext/core/sc_main.hh" 2113586Sgabeblack@google.com#include "systemc/ext/core/sc_time.hh" 2213586Sgabeblack@google.com#include "systemc/ext/tlm_core/2/quantum/global_quantum.hh" 2313516Sgabeblack@google.com 2413516Sgabeblack@google.comnamespace tlm 2513516Sgabeblack@google.com{ 2613516Sgabeblack@google.com 2713516Sgabeblack@google.comtlm_global_quantum::tlm_global_quantum() : 2813516Sgabeblack@google.com m_global_quantum(sc_core::SC_ZERO_TIME) 2913516Sgabeblack@google.com{} 3013516Sgabeblack@google.com 3113516Sgabeblack@google.comtlm_global_quantum & 3213516Sgabeblack@google.comtlm_global_quantum::instance() 3313516Sgabeblack@google.com{ 3413516Sgabeblack@google.com static tlm_global_quantum instance_; 3513516Sgabeblack@google.com return instance_; 3613516Sgabeblack@google.com} 3713516Sgabeblack@google.com 3813516Sgabeblack@google.comsc_core::sc_time 3913516Sgabeblack@google.comtlm_global_quantum::compute_local_quantum() 4013516Sgabeblack@google.com{ 4113516Sgabeblack@google.com if (m_global_quantum != sc_core::SC_ZERO_TIME) { 4213516Sgabeblack@google.com const sc_core::sc_time current = sc_core::sc_time_stamp(); 4313516Sgabeblack@google.com const sc_core::sc_time g_quant = m_global_quantum; 4413519Sgabeblack@google.com return sc_core::sc_time::from_value( 4513519Sgabeblack@google.com g_quant.value() - (current.value() % g_quant.value())); 4613516Sgabeblack@google.com } else { 4713516Sgabeblack@google.com return sc_core::SC_ZERO_TIME; 4813516Sgabeblack@google.com } 4913516Sgabeblack@google.com} 5013516Sgabeblack@google.com 5113516Sgabeblack@google.com} // namespace tlm 52