44#ifndef __CPU_MINOR_BUFFERS_HH__
45#define __CPU_MINOR_BUFFERS_HH__
95template <
typename ElemType>
101 { elem.reportData(
os); }
106template <
typename PtrType>
112 { elem->reportData(
os); }
120template <
typename ElemType>
124 static bool isBubble(
const ElemType &) {
return false; }
128 panic(
"bubble called but no bubble interface");
133template <
typename ElemType>
138 {
return elem.isBubble(); }
140 static ElemType
bubble() {
return ElemType::bubble(); }
144template <
typename PtrType,
typename ElemType>
149 {
return elem->isBubble(); }
151 static PtrType
bubble() {
return ElemType::bubble(); }
155template <
typename ElemType,
156 typename ReportTraits = ReportTraitsAdaptor<ElemType>,
157 typename BubbleTraits = BubbleTraitsAdaptor<ElemType> >
169 const std::string &data_name,
170 int num_past,
int num_future,
171 int report_left = -1,
int report_right = -1) :
185 if (!BubbleTraits::isBubble((*
this)[
i]))
199 std::ostringstream
data;
206 const ElemType &datum = (*this)[
i];
208 ReportTraits::reportData(
data, datum);
220template <
typename Data>
237 const std::string &data_name,
239 bool report_backwards =
false) :
241 buffer(
name, data_name, delay_, 0, (report_backwards ? -delay_ : 0),
242 (report_backwards ? 0 : -delay_))
257 Input(
typename Buffer::wire input_wire) :
268 Output(
typename Buffer::wire output_wire) :
290template <
typename ElemType,
291 typename ReportTraits,
292 typename BubbleTraits = BubbleTraitsAdaptor<ElemType> >
310 const std::string &data_name,
313 (
name, data_name, depth, 0, -1, -depth),
323 for (
unsigned i = 0;
i <= depth;
i++)
324 (*
this)[-
i] = BubbleTraits::bubble();
336 if (!BubbleTraits::isBubble(elem))
370 ElemType bubble = BubbleTraits::bubble();
400template <
typename ElemType,
401 typename ReportTraits = ReportTraitsAdaptor<ElemType>,
402 typename BubbleTraits = BubbleTraitsAdaptor<ElemType> >
419 Queue(
const std::string &
name,
const std::string &data_name,
420 unsigned int capacity_) :
434 if (!BubbleTraits::isBubble(
data)) {
439 warn(
"%s: No space to push data into queue of capacity"
464 warn(
"%s: No space is reservable in queue",
name());
487 return (ret < 0 ? 0 : ret);
496 return (ret < 0 ? 0 : ret);
513 std::ostringstream
data;
524 while (num_printed <= num_occupied) {
525 ReportTraits::reportData(
data,
queue[num_printed - 1]);
528 if (num_printed <= num_total)
532 int num_printed_reserved = 1;
534 while (num_printed_reserved <= num_reserved &&
535 num_printed <= num_total)
538 num_printed_reserved++;
541 if (num_printed <= num_total)
546 while (num_printed <= num_total) {
549 if (num_printed <= num_total)
568template <
typename ElemType,
569 typename ReportTraits = ReportTraitsAdaptor<ElemType>,
570 typename BubbleTraits = BubbleTraitsAdaptor<ElemType> >
582 unsigned int capacity_) :
595 if (!BubbleTraits::isBubble(new_element)) {
599 queue.push(new_element);
621 queue.freeReservation();
656 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'.
... BubbleTraits are trait classes to add BubbleIF interface functionality to templates which process...
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
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.
ElemType & front()
Head value.
void reserve()
Reserve space in the queue for future pushes.
unsigned int totalSpace() const
Number of slots available in an empty buffer.
const ElemType & front() const
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
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.
ElemType & front()
Peek at the end element of the pipe.
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.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
const std::string & name()