gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
23namespace tlm
24{
25
26template <typename T>
27inline 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
38template <typename T>
39inline bool
41{
42 if (used() < 1) {
43 return false;
44 }
45
46 t = buffer.peek_data(0);
47 return true;
48}
49
50template <typename T>
51inline bool
52tlm_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
66template <typename T>
67inline bool
69{
70 return !is_empty();
71}
72
73template <typename T>
74inline bool
75tlm_fifo<T>::nb_poke(const T &t, int n)
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
void wait()
Definition sc_module.cc:653

Generated on Tue Jun 18 2024 16:24:07 for gem5 by doxygen 1.11.0