Go to the documentation of this file.
44 #ifndef __CPU_MINOR_BUFFERS_HH__
45 #define __CPU_MINOR_BUFFERS_HH__
89 template <
typename ElemType>
95 { elem.reportData(
os); }
100 template <
typename PtrType>
106 { elem->reportData(
os); }
114 template <
typename ElemType>
118 static bool isBubble(
const ElemType &) {
return false; }
122 panic(
"bubble called but no bubble interface");
127 template <
typename ElemType>
132 {
return elem.isBubble(); }
134 static ElemType
bubble() {
return ElemType::bubble(); }
138 template <
typename PtrType,
typename ElemType>
143 {
return elem->isBubble(); }
145 static PtrType
bubble() {
return ElemType::bubble(); }
149 template <
typename ElemType,
150 typename ReportTraits = ReportTraitsAdaptor<ElemType>,
151 typename BubbleTraits = BubbleTraitsAdaptor<ElemType> >
163 const std::string &data_name,
164 int num_past,
int num_future,
165 int report_left = -1,
int report_right = -1) :
179 if (!BubbleTraits::isBubble((*
this)[
i]))
193 std::ostringstream
data;
200 const ElemType &datum = (*this)[
i];
202 ReportTraits::reportData(
data, datum);
214 template <
typename Data>
231 const std::string &data_name,
233 bool report_backwards =
false) :
235 buffer(
name, data_name, delay_, 0, (report_backwards ? -delay_ : 0),
236 (report_backwards ? 0 : -delay_))
284 template <
typename ElemType,
285 typename ReportTraits,
286 typename BubbleTraits = BubbleTraitsAdaptor<ElemType> >
304 const std::string &data_name,
307 (
name, data_name, depth, 0, -1, -depth),
317 for (
unsigned i = 0;
i <= depth;
i++)
318 (*
this)[-
i] = BubbleTraits::bubble();
330 if (!BubbleTraits::isBubble(elem))
364 ElemType bubble = BubbleTraits::bubble();
394 template <
typename ElemType,
395 typename ReportTraits = ReportTraitsAdaptor<ElemType>,
396 typename BubbleTraits = BubbleTraitsAdaptor<ElemType> >
413 Queue(
const std::string &
name,
const std::string &data_name,
414 unsigned int capacity_) :
428 if (!BubbleTraits::isBubble(
data)) {
433 warn(
"%s: No space to push data into queue of capacity"
458 warn(
"%s: No space is reservable in queue",
name());
481 return (ret < 0 ? 0 : ret);
490 return (ret < 0 ? 0 : ret);
507 std::ostringstream
data;
518 while (num_printed <= num_occupied) {
519 ReportTraits::reportData(
data,
queue[num_printed - 1]);
522 if (num_printed <= num_total)
526 int num_printed_reserved = 1;
528 while (num_printed_reserved <= num_reserved &&
529 num_printed <= num_total)
532 num_printed_reserved++;
535 if (num_printed <= num_total)
540 while (num_printed <= num_total) {
543 if (num_printed <= num_total)
562 template <
typename ElemType,
563 typename ReportTraits = ReportTraitsAdaptor<ElemType>,
564 typename BubbleTraits = BubbleTraitsAdaptor<ElemType> >
576 unsigned int capacity_) :
589 if (!BubbleTraits::isBubble(new_element)) {
593 queue.push(new_element);
615 queue.freeReservation();
650 return queue.unreservedRemainingSpace();
virtual void reserve()=0
Reserve a slot in whatever structure this is attached to.
virtual bool canReserve() const =0
Can a slot be reserved?
void advance()
Try to advance the pipeline.
void minorTrace() const
Report buffer states from 'slot' 'from' to 'to'.
virtual bool isBubble() const =0
Queue(const std::string &name, const std::string &data_name, unsigned int capacity_)
bool stalled
If true, advance will not advance the pipeline.
TimeBuffer< ElemType >::wire pushWire
Wire at the input end of the pipeline (for convenience)
TimeBuffer< ElemType >::wire popWire
Wire at the output end of the pipeline (for convenience)
void push(ElemType &elem)
Write an element to the back of the pipeline.
unsigned int reservedSpace() const
Number of slots which are reserved.
void freeReservation()
Clear a single reserved slot.
unsigned int totalSpace() const
Number of slots available in an empty buffer.
Wraps a MinorBuffer with Input/Output interfaces to ensure that units within the model can only see t...
Output output()
An interface to just the output of the buffer.
#define MINORTRACE(...)
DPRINTFN for MinorTrace reporting.
bool empty() const
Is the queue empty?
Base class for space reservation requestable objects.
void push(ElemType &data)
Push an element into the buffer if it isn't a bubble.
static bool isBubble(const ElemType &elem)
unsigned int unreservedRemainingSpace() const
Like remainingSpace but does not count reserved spaces.
Latch(const std::string &name, const std::string &data_name, Cycles delay_=Cycles(1), bool report_backwards=false)
forward/backwardDelay specify the delay from input to output in each direction.
unsigned int remainingSpace() const
Number of slots yet to fill in this buffer.
Interface class for data with reporting/tracing facilities.
A similar adaptor but for elements held by pointer ElemType should implement ReportIF.
const ElemType & front() const
void reserve()
Reserve space in the queue for future pushes.
static bool isBubble(const ElemType &)
...ReportTraits are trait classes with the same functionality as ReportIF, but with elements explicit...
A pipeline simulating class that will stall (not advance when advance() is called) if a non-bubble va...
Pass on call to the element where the element is a pointer.
bool canReserve() const
Can a slot be reserved?
ElemType & front()
Peek at the end element of the pipe.
bool alreadyPushed()
Have we already pushed onto this pipe without advancing.
std::string dataName
Name to use for the data in MinorTrace.
Wrapper for a queue type to act as a pipeline stage input queue.
virtual void reportData(std::ostream &os) const =0
Print the data in a format suitable to be the value in "name=value" trace lines.
MinorBuffer(const std::string &name, const std::string &data_name, int num_past, int num_future, int report_left=-1, int report_right=-1)
ElemType & front()
Head value.
Output(typename Buffer::wire output_wire)
Cycles delay
Delays, in cycles, writing data into the latch and seeing it on the latched wires.
void pop()
Pop the head item.
unsigned int capacity
Need this here as queues usually don't have a limited capacity.
Pass on call to the element.
unsigned int occupiedSpace() const
Number of slots already occupied in this buffer.
const std::string & name()
SelfStallingPipeline(const std::string &name, const std::string &data_name, unsigned depth)
unsigned int numReservedSlots
Number of slots currently reserved for future (reservation respecting) pushes.
static bool isBubble(const PtrType &elem)
virtual void freeReservation()=0
Free a reserved slot.
Input input()
An interface to just the input of the buffer.
TimeBuffer with MinorTrace and Named interfaces.
bool isPopable()
There's data (not a bubble) at the end of the pipe.
unsigned int occupancy
The number of slots with non-bubbles in them.
MinorBuffer< Data > Buffer
int reportLeft
The range of elements that should appear in trace lines.
Cycles is a wrapper class for representing cycle counts, i.e.
std::string dataName
Name to use for the data in a MinorTrace line.
static void reportData(std::ostream &os, const PtrType &elem)
const std::string & name() const
std::deque< ElemType > queue
Interface class for data with 'bubble' values.
const ElemType & front() const
void clearReservedSpace()
Clear all allocated space.
#define panic(...)
This implements a cprintf based panic() function.
static void reportData(std::ostream &os, const ElemType &elem)
Generated on Wed Sep 30 2020 14:02:08 for gem5 by doxygen 1.8.17