44 #ifndef __CPU_MINOR_BUFFERS_HH__
45 #define __CPU_MINOR_BUFFERS_HH__
96 template <
typename ElemType>
102 { elem.reportData(
os); }
107 template <
typename PtrType>
113 { elem->reportData(
os); }
121 template <
typename ElemType>
125 static bool isBubble(
const ElemType &) {
return false; }
129 panic(
"bubble called but no bubble interface");
134 template <
typename ElemType>
139 {
return elem.isBubble(); }
141 static ElemType
bubble() {
return ElemType::bubble(); }
145 template <
typename PtrType,
typename ElemType>
150 {
return elem->isBubble(); }
152 static PtrType
bubble() {
return ElemType::bubble(); }
156 template <
typename ElemType,
157 typename ReportTraits = ReportTraitsAdaptor<ElemType>,
158 typename BubbleTraits = BubbleTraitsAdaptor<ElemType> >
170 const std::string &data_name,
171 int num_past,
int num_future,
172 int report_left = -1,
int report_right = -1) :
186 if (!BubbleTraits::isBubble((*
this)[
i]))
200 std::ostringstream
data;
207 const ElemType &datum = (*this)[
i];
209 ReportTraits::reportData(
data, datum);
221 template <
typename Data>
238 const std::string &data_name,
240 bool report_backwards =
false) :
242 buffer(
name, data_name, delay_, 0, (report_backwards ? -delay_ : 0),
243 (report_backwards ? 0 : -delay_))
291 template <
typename ElemType,
292 typename ReportTraits,
293 typename BubbleTraits = BubbleTraitsAdaptor<ElemType> >
311 const std::string &data_name,
314 (
name, data_name, depth, 0, -1, -depth),
324 for (
unsigned i = 0;
i <= depth;
i++)
325 (*
this)[-
i] = BubbleTraits::bubble();
337 if (!BubbleTraits::isBubble(elem))
371 ElemType bubble = BubbleTraits::bubble();
401 template <
typename ElemType,
402 typename ReportTraits = ReportTraitsAdaptor<ElemType>,
403 typename BubbleTraits = BubbleTraitsAdaptor<ElemType> >
420 Queue(
const std::string &
name,
const std::string &data_name,
421 unsigned int capacity_) :
435 if (!BubbleTraits::isBubble(
data)) {
440 warn(
"%s: No space to push data into queue of capacity"
465 warn(
"%s: No space is reservable in queue",
name());
488 return (ret < 0 ? 0 : ret);
497 return (ret < 0 ? 0 : ret);
514 std::ostringstream
data;
525 while (num_printed <= num_occupied) {
526 ReportTraits::reportData(
data,
queue[num_printed - 1]);
529 if (num_printed <= num_total)
533 int num_printed_reserved = 1;
535 while (num_printed_reserved <= num_reserved &&
536 num_printed <= num_total)
539 num_printed_reserved++;
542 if (num_printed <= num_total)
547 while (num_printed <= num_total) {
550 if (num_printed <= num_total)
569 template <
typename ElemType,
570 typename ReportTraits = ReportTraitsAdaptor<ElemType>,
571 typename BubbleTraits = BubbleTraitsAdaptor<ElemType> >
583 unsigned int capacity_) :
596 if (!BubbleTraits::isBubble(new_element)) {
600 queue.push(new_element);
622 queue.freeReservation();
657 return queue.unreservedRemainingSpace();
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Cycles is a wrapper class for representing cycle counts, i.e.
Interface for things with names.
virtual std::string name() const
Interface class for data with 'bubble' values.
virtual bool isBubble() const =0
Pass on call to the element.
static bool isBubble(const ElemType &elem)
Pass on call to the element where the element is a pointer.
static bool isBubble(const PtrType &elem)
Output(typename Buffer::wire output_wire)
Wraps a MinorBuffer with Input/Output interfaces to ensure that units within the model can only see t...
Input input()
An interface to just the input of the buffer.
MinorBuffer< Data > Buffer
Cycles delay
Delays, in cycles, writing data into the latch and seeing it on the latched wires.
Output output()
An interface to just the output of the buffer.
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.
TimeBuffer with MinorTrace and Named interfaces.
int reportLeft
The range of elements that should appear in trace lines.
std::string dataName
Name to use for the data in a MinorTrace line.
MinorBuffer(const std::string &name, const std::string &data_name, int num_past, int num_future, int report_left=-1, int report_right=-1)
void minorTrace() const
Report buffer states from 'slot' 'from' to 'to'.
static bool isBubble(const ElemType &)
Wrapper for a queue type to act as a pipeline stage input queue.
Queue(const std::string &name, const std::string &data_name, unsigned int capacity_)
bool empty() const
Is the queue empty?
std::deque< ElemType > queue
const ElemType & front() const
unsigned int reservedSpace() const
Number of slots which are reserved.
void clearReservedSpace()
Clear all allocated space.
void pop()
Pop the head item.
bool canReserve() const
Can a slot be reserved?
unsigned int unreservedRemainingSpace() const
Like remainingSpace but does not count reserved spaces.
unsigned int remainingSpace() const
Number of slots yet to fill in this buffer.
unsigned int occupiedSpace() const
Number of slots already occupied in this buffer.
void freeReservation()
Clear a single reserved slot.
std::string dataName
Name to use for the data in MinorTrace.
unsigned int capacity
Need this here as queues usually don't have a limited capacity.
void reserve()
Reserve space in the queue for future pushes.
unsigned int totalSpace() const
Number of slots available in an empty buffer.
ElemType & front()
Head value.
unsigned int numReservedSlots
Number of slots currently reserved for future (reservation respecting) pushes.
void push(ElemType &data)
Push an element into the buffer if it isn't a bubble.
Interface class for data with reporting/tracing facilities.
virtual void reportData(std::ostream &os) const =0
Print the data in a format suitable to be the value in "name=value" trace lines.
...ReportTraits are trait classes with the same functionality as ReportIF, but with elements explicit...
static void reportData(std::ostream &os, const ElemType &elem)
A similar adaptor but for elements held by pointer ElemType should implement ReportIF.
static void reportData(std::ostream &os, const PtrType &elem)
Base class for space reservation requestable objects.
virtual void freeReservation()=0
Free a reserved slot.
virtual void reserve()=0
Reserve a slot in whatever structure this is attached to.
virtual bool canReserve() const =0
Can a slot be reserved?
A pipeline simulating class that will stall (not advance when advance() is called) if a non-bubble va...
bool alreadyPushed()
Have we already pushed onto this pipe without advancing.
bool stalled
If true, advance will not advance the pipeline.
void advance()
Try to advance the pipeline.
SelfStallingPipeline(const std::string &name, const std::string &data_name, unsigned depth)
TimeBuffer< ElemType >::wire popWire
Wire at the output end of the pipeline (for convenience)
unsigned int occupancy
The number of slots with non-bubbles in them.
const ElemType & front() const
ElemType & front()
Peek at the end element of the pipe.
TimeBuffer< ElemType >::wire pushWire
Wire at the input end of the pipeline (for convenience)
bool isPopable()
There's data (not a bubble) at the end of the pipe.
void push(ElemType &elem)
Write an element to the back of the pipeline.
This file contains miscellaneous classes and functions for formatting general trace information and a...
#define panic(...)
This implements a cprintf based panic() function.
void minorTrace(const char *fmt, Args ...args)
DPRINTFN for MinorTrace reporting.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
const std::string & name()