gem5  v20.1.0.0
fifo_resize.hh
Go to the documentation of this file.
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.
24 namespace tlm
25 {
26 
27 template <typename T>
28 inline void
29 tlm_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 
38 template <typename T>
39 inline void
40 tlm_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 
52 template <typename T>
53 inline bool
54 tlm_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 
63 template <typename T>
64 inline bool
65 tlm_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__ */
tlm::tlm_fifo::nb_unbound
void nb_unbound(unsigned int n=16)
Definition: fifo_resize.hh:57
ArmISA::n
Bitfield< 31 > n
Definition: miscregs_types.hh:450
tlm::tlm_fifo::nb_bound
bool nb_bound(unsigned int n)
Definition: fifo_resize.hh:82
tlm
Definition: analysis_fifo.hh:27
tlm::tlm_fifo::nb_reduce
bool nb_reduce(unsigned int n=1)
Definition: fifo_resize.hh:71
tlm::tlm_fifo::nb_expand
void nb_expand(unsigned int n=1)
Definition: fifo_resize.hh:46

Generated on Wed Sep 30 2020 14:02:16 for gem5 by doxygen 1.8.17