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 __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_RESIZE_HH__ 21#define __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_RESIZE_HH__ 22 23// Resize interface. 24namespace tlm 25{ 26 27template <typename T> 28inline void 29tlm_fifo<T>::nb_expand(unsigned int n) 30{ 31 if (m_size >= 0) { 32 m_expand = true; 33 m_size += n; 34 request_update(); 35 } 36} 37 38template <typename T> 39inline void 40tlm_fifo<T>::nb_unbound(unsigned int n) 41{ 42 m_expand = true; 43 m_size = -n; 44 45 if (buffer.size() < static_cast<int>(n)) { 46 buffer.resize(n); 47 } 48 49 request_update(); 50} 51 52template <typename T> 53inline bool 54tlm_fifo<T>::nb_reduce(unsigned int n) 55{ 56 if (m_size < 0) { 57 return false; 58 } 59 60 return nb_bound(size() - n); 61} 62 63template <typename T> 64inline bool 65tlm_fifo<T>::nb_bound(unsigned int new_size) 66{ 67 bool ret = true; 68 69 if (static_cast<int>(new_size) < used()) { 70 new_size = used(); 71 ret = false; 72 } 73 74 m_size = new_size; 75 return ret; 76} 77 78} // namespace tlm 79 80#endif /* __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_RESIZE_HH__ */ 81