gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
fifo_put_get.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_PUT_GET_HH__
21#define __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_PUT_GET_HH__
22
23namespace tlm
24{
25
26// Get interface.
27template <typename T>
28inline T
30{
31 while (is_empty()) {
33 }
34
35 m_num_read++;
37
38 return buffer.read();
39}
40
41// Non-blocking read.
42template <typename T>
43inline bool
45{
46 if (is_empty()) {
47 return false;
48 }
49
50 m_num_read++;
52
53 val_ = buffer.read();
54
55 return true;
56}
57
58template <typename T>
59inline bool
61{
62 return !is_empty();
63}
64
66// Put interface.
67template <typename T>
68inline void
69tlm_fifo<T>::put(const T &val_)
70{
71 while (is_full()) {
73 }
74
75 if (buffer.is_full()) {
76 buffer.resize(buffer.size() * 2);
77 }
78
80 buffer.write(val_);
81
83}
84
85template <typename T>
86inline bool
87tlm_fifo<T>::nb_put(const T &val_)
88{
89 if (is_full()) {
90 return false;
91 }
92
93 if (buffer.is_full()) {
94 buffer.resize(buffer.size() * 2);
95 }
96
97 m_num_written++;
98 buffer.write(val_);
99 request_update();
100
101 return true;
102}
103
104template <typename T>
105inline bool
107{
108 return !is_full();
109}
110
111} // namespace tlm
112
113#endif /* __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_FIFO_PUT_GET_HH__ */
bool nb_get(T &)
bool is_full() const
Definition fifo.hh:167
int m_num_read
Definition fifo.hh:145
bool nb_can_get(tlm_tag< T > *=nullptr) const
sc_core::sc_event m_data_written_event
Definition fifo.hh:152
int m_num_written
Definition fifo.hh:146
sc_core::sc_event m_data_read_event
Definition fifo.hh:151
T get(tlm_tag< T > *=nullptr)
bool nb_put(const T &)
circular_buffer< T > buffer
Definition fifo.hh:140
void put(const T &)
bool nb_can_put(tlm_tag< T > *=nullptr) const
bool is_empty() const
Definition fifo.hh:164
void wait()
Definition sc_module.cc:653

Generated on Mon May 26 2025 09:19:14 for gem5 by doxygen 1.13.2