gem5  v22.1.0.0
fifo_peek.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_PEEK_HH__
21 #define __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_PEEK_HH__
22 
23 namespace tlm
24 {
25 
26 template <typename T>
27 inline T
29 {
30  while (is_empty()) {
31  // call free-standing sc_core::wait(),
32  // since sc_prim_channel::wait(.) is not const
33  sc_core::wait(m_data_written_event);
34  }
35  return buffer.read_data();
36 }
37 
38 template <typename T>
39 inline bool
41 {
42  if (used() < 1) {
43  return false;
44  }
45 
46  t = buffer.peek_data(0);
47  return true;
48 }
49 
50 template <typename T>
51 inline bool
52 tlm_fifo<T>::nb_peek(T &t, int n) const
53 {
54  if (n >= used() || n < -1) {
55  return false;
56  }
57 
58  if (n == -1) {
59  n = used() - 1;
60  }
61 
62  t = buffer.peek_data(n);
63  return true;
64 }
65 
66 template <typename T>
67 inline bool
69 {
70  return !is_empty();
71 }
72 
73 template <typename T>
74 inline bool
75 tlm_fifo<T>::nb_poke(const T &t, int n)
76 {
77  if (n >= used() || n < 0) {
78  return false;
79  }
80 
81  buffer.poke_data(n) = t;
82  return true;
83 }
84 
85 } // namespace tlm
86 
87 #endif /* __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_PEEK_HH__ */
T peek(tlm_tag< T > *=nullptr) const
Definition: fifo_peek.hh:28
bool nb_can_peek(tlm_tag< T > *=nullptr) const
Definition: fifo_peek.hh:68
bool nb_peek(T &) const
Definition: fifo_peek.hh:40
bool nb_poke(const T &, int n=0)
Definition: fifo_peek.hh:75
Bitfield< 31 > n
Definition: misc_types.hh:462
Bitfield< 51 > t
Definition: pagetable.hh:56
void wait()
Definition: sc_module.cc:653

Generated on Wed Dec 21 2022 10:22:42 for gem5 by doxygen 1.9.1