global_quantum.cc revision 13519
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 2013516Sgabeblack@google.com#include <systemc> 2113516Sgabeblack@google.com#include <tlm> 2213516Sgabeblack@google.com 2313516Sgabeblack@google.comnamespace tlm 2413516Sgabeblack@google.com{ 2513516Sgabeblack@google.com 2613516Sgabeblack@google.comtlm_global_quantum::tlm_global_quantum() : 2713516Sgabeblack@google.com m_global_quantum(sc_core::SC_ZERO_TIME) 2813516Sgabeblack@google.com{} 2913516Sgabeblack@google.com 3013516Sgabeblack@google.comtlm_global_quantum & 3113516Sgabeblack@google.comtlm_global_quantum::instance() 3213516Sgabeblack@google.com{ 3313516Sgabeblack@google.com static tlm_global_quantum instance_; 3413516Sgabeblack@google.com return instance_; 3513516Sgabeblack@google.com} 3613516Sgabeblack@google.com 3713516Sgabeblack@google.comsc_core::sc_time 3813516Sgabeblack@google.comtlm_global_quantum::compute_local_quantum() 3913516Sgabeblack@google.com{ 4013516Sgabeblack@google.com if (m_global_quantum != sc_core::SC_ZERO_TIME) { 4113516Sgabeblack@google.com const sc_core::sc_time current = sc_core::sc_time_stamp(); 4213516Sgabeblack@google.com const sc_core::sc_time g_quant = m_global_quantum; 4313519Sgabeblack@google.com return sc_core::sc_time::from_value( 4413519Sgabeblack@google.com g_quant.value() - (current.value() % g_quant.value())); 4513516Sgabeblack@google.com } else { 4613516Sgabeblack@google.com return sc_core::SC_ZERO_TIME; 4713516Sgabeblack@google.com } 4813516Sgabeblack@google.com} 4913516Sgabeblack@google.com 5013516Sgabeblack@google.com} // namespace tlm 51