gem5  v20.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
28 tlm_fifo<T>::peek(tlm_tag<T> *) const
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
40 tlm_fifo<T>::nb_peek(T &t) const
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
68 tlm_fifo<T>::nb_can_peek(tlm_tag<T> *) const
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__ */
ArmISA::n
Bitfield< 31 > n
Definition: miscregs_types.hh:450
tlm
Definition: analysis_fifo.hh:27
tlm::tlm_fifo::nb_can_peek
bool nb_can_peek(tlm_tag< T > *=nullptr) const
Definition: fifo_peek.hh:85
sc_core::wait
void wait()
Definition: sc_module.cc:653
tlm::tlm_fifo::nb_peek
bool nb_peek(T &) const
Definition: fifo_peek.hh:57
ArmISA::t
Bitfield< 5 > t
Definition: miscregs_types.hh:67
tlm::tlm_fifo::nb_poke
bool nb_poke(const T &, int n=0)
Definition: fifo_peek.hh:92
tlm::tlm_fifo::peek
T peek(tlm_tag< T > *=nullptr) const
Definition: fifo_peek.hh:45

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