gem5  v20.1.0.0
Public Member Functions | List of all members
CircleBuf< T > Class Template Reference

Circular buffer backed by a vector though a CircularQueue. More...

#include <circlebuf.hh>

Inheritance diagram for CircleBuf< T >:
CircularQueue< T > std::vector< T >

Public Member Functions

 CircleBuf (size_t size)
 
template<class OutputIterator >
void peek (OutputIterator out, size_t len) const
 Copy buffer contents without advancing the read pointer. More...
 
template<class OutputIterator >
void peek (OutputIterator out, off_t offset, size_t len) const
 Copy buffer contents without advancing the read pointer. More...
 
template<class OutputIterator >
void read (OutputIterator out, size_t len)
 Copy buffer contents and advance the read pointer. More...
 
template<class InputIterator >
void write (InputIterator in, size_t len)
 Add elements to the end of the ring buffers and advance. More...
 
- Public Member Functions inherited from CircularQueue< T >
 CircularQueue (uint32_t size=0)
 
void flush ()
 Remove all the elements in the queue. More...
 
bool isValidIdx (size_t idx) const
 Test if the index is in the range of valid elements. More...
 
bool isValidIdx (size_t idx, uint32_t round) const
 Test if the index is in the range of valid elements. More...
 
reference front ()
 
reference back ()
 
uint32_t head () const
 
uint32_t tail () const
 
size_t capacity () const
 
uint32_t size () const
 
uint32_t moduloAdd (uint32_t s1, uint32_t s2) const
 
uint32_t moduloSub (uint32_t s1, uint32_t s2) const
 
void pop_front (size_t num_elem=1)
 Circularly increase the head pointer. More...
 
void pop_back ()
 Circularly decrease the tail pointer. More...
 
void push_back (typename Base::value_type val)
 Pushes an element at the end of the queue. More...
 
void advance_tail ()
 Increases the tail by one. More...
 
void advance_tail (uint32_t len)
 Increases the tail by a specified number of steps. More...
 
bool empty () const
 Is the queue empty? More...
 
bool full () const
 Is the queue full? A queue is full if the head is the 0^{th} element and the tail is the (size-1)^{th} element, or if the head is the n^{th} element and the tail the (n-1)^{th} element. More...
 
iterator begin ()
 Iterators. More...
 
iterator begin () const
 
iterator end ()
 
iterator end () const
 
iterator getIterator (size_t idx)
 Return an iterator to an index in the vector. More...
 

Additional Inherited Members

- Protected Types inherited from CircularQueue< T >
using Base = std::vector< T >
 
- Protected Member Functions inherited from CircularQueue< T >
void increase (uint32_t &v, size_t delta=1)
 
void decrease (uint32_t &v)
 
- Static Protected Member Functions inherited from CircularQueue< T >
static uint32_t moduloAdd (uint32_t op1, uint32_t op2, uint32_t size)
 General modular addition. More...
 
static uint32_t moduloSub (uint32_t op1, uint32_t op2, uint32_t size)
 General modular subtraction. More...
 
static int32_t sub (uint32_t op1, uint32_t op2, uint32_t size)
 
- Protected Attributes inherited from CircularQueue< T >
const uint32_t _capacity
 
uint32_t _head
 
uint32_t _tail
 
uint32_t _empty
 
uint32_t _round
 Counter for how many times the tail wraps around. More...
 

Detailed Description

template<typename T>
class CircleBuf< T >

Circular buffer backed by a vector though a CircularQueue.

The data in the cricular buffer is stored in a standard vector.

Definition at line 57 of file circlebuf.hh.

Constructor & Destructor Documentation

◆ CircleBuf()

template<typename T >
CircleBuf< T >::CircleBuf ( size_t  size)
inlineexplicit

Definition at line 60 of file circlebuf.hh.

Member Function Documentation

◆ peek() [1/2]

template<typename T >
template<class OutputIterator >
void CircleBuf< T >::peek ( OutputIterator  out,
off_t  offset,
size_t  len 
) const
inline

Copy buffer contents without advancing the read pointer.

Parameters
outOutput iterator/pointer
offsetOffset into the ring buffer
lenNumber of elements to copy

Definition at line 89 of file circlebuf.hh.

◆ peek() [2/2]

template<typename T >
template<class OutputIterator >
void CircleBuf< T >::peek ( OutputIterator  out,
size_t  len 
) const
inline

Copy buffer contents without advancing the read pointer.

Parameters
outOutput iterator/pointer
lenNumber of elements to copy

Definition at line 77 of file circlebuf.hh.

Referenced by Terminal::accept(), arrayParamOut(), CircleBuf< char >::peek(), Fifo< uint8_t >::peek(), CircleBuf< char >::read(), and TEST().

◆ read()

template<typename T >
template<class OutputIterator >
void CircleBuf< T >::read ( OutputIterator  out,
size_t  len 
)
inline

Copy buffer contents and advance the read pointer.

Parameters
outOutput iterator/pointer
lenNumber of elements to read

Definition at line 103 of file circlebuf.hh.

Referenced by Fifo< uint8_t >::read(), Terminal::readData(), and TEST().

◆ write()

template<typename T >
template<class InputIterator >
void CircleBuf< T >::write ( InputIterator  in,
size_t  len 
)
inline

Add elements to the end of the ring buffers and advance.

Parameters
inInput iterator/pointer
lenNumber of elements to read

Definition at line 115 of file circlebuf.hh.

Referenced by arrayParamIn(), Terminal::data(), TEST(), Fifo< uint8_t >::write(), and Terminal::writeData().


The documentation for this class was generated from the following file:

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