Go to the documentation of this file.
20 #ifndef __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_CIRCULAR_BUFFER_HH__
21 #define __TLM_CORE_1_REQ_RSP_CHANNELS_FIFO_CIRCULAR_BUFFER_HH__
39 void write(
const T &);
71 circular_buffer<T> &
operator = (
const circular_buffer<T> &);
92 std::cout <<
"Buffer debug" << std::endl;
93 std::cout <<
"Size : " << size() << std::endl;
94 std::cout <<
"Free/Used " << free() <<
"/" << used() << std::endl;
95 std::cout <<
"Indices : r/w = " << m_ri <<
"/" << m_wi << std::endl;
98 std::cout <<
"empty" << std::endl;
102 std::cout <<
"full" << std::endl;
105 std::cout <<
"Data : " << std::endl;
106 for (
int i = 0;
i < used();
i++) {
107 std::cout << peek_data(
i ) << std::endl;
111 template <
typename T>
117 template <
typename T>
121 for (
int i = 0;
i < used();
i++) {
122 buf_clear(m_buf, (m_ri +
i) % m_size);
125 m_used = m_ri = m_wi = 0;
128 template <
typename T>
135 template <
typename T>
140 void *new_buf = buf_alloc(size);
142 for (
i = 0;
i < size &&
i < used();
i++) {
143 buf_write(new_buf,
i, peek_data(
i));
144 buf_clear(m_buf, (m_ri +
i) % m_size);
153 m_free = m_size - m_used;
159 template <
typename T>
164 m_buf = buf_alloc(m_size);
173 template <
typename T>
175 circular_buffer<T>::read()
179 buf_clear(m_buf, m_ri);
180 increment_read_pos();
185 template <
typename T>
189 buf_write(m_buf, m_wi,
t);
190 increment_write_pos();
193 template <
typename T>
197 m_wi = (m_wi +
i) % m_size;
202 template <
typename T>
206 m_ri = (m_ri +
i) % m_size;
211 template <
typename T>
215 return new unsigned char [size *
sizeof(T)];
218 template <
typename T>
222 delete []
static_cast<unsigned char *
>(buf);
226 template <
typename T>
230 T *
p =
static_cast<T *
>(buf) +
n;
234 template <
typename T>
238 T *
p =
static_cast<T *
>(buf) +
n;
242 template <
typename T>
246 T *
p =
static_cast<T *
>(buf) +
n;
const T & read_data() const
void * buf_alloc(int size)
const FlagsType init
This Stat is Initialized.
circular_buffer< T > & operator=(const circular_buffer< T > &)
void increment_read_pos(int i=1)
void buf_write(void *buf, int n, const T &t)
void increment_write_pos(int i=1)
const T & peek_data(int i) const
void buf_free(void *&buf)
void buf_clear(void *buf, int n)
T & buf_read(void *buf, int n) const
circular_buffer(int size=0)
Generated on Wed Sep 30 2020 14:02:16 for gem5 by doxygen 1.8.17