92 bool presume_zero_delay =
true) :
93 OutPort(portset, name, presume_zero_delay)
95 sparta_assert(name.length() != 0,
"You cannot have an unnamed port.");
119 throw SpartaException(
"ERROR: Attempt to bind DataInPort of a disparate types: '" +
123 bound_in_ports_.push_back(inp);
145 void send(
const DataT & dat, sparta::Clock::Cycle rel_time = 0)
148 "ERROR! Attempt to send data on unbound port: " <<
getLocation());
150 itr->send_(dat, rel_time);
163 bool isDriven(Clock::Cycle rel_cycle)
const override {
165 if(itr->isDriven(rel_cycle)) {
178 if(itr->isDriven()) {
195 uint32_t cancel_cnt = 0;
197 cancel_cnt += itr->cancel();
213 uint32_t cancel_cnt = 0;
215 cancel_cnt += itr->cancelIf(criteria);
230 uint32_t
cancelIf(std::function<
bool(
const DataT &)> compare) {
231 uint32_t cancel_cnt = 0;
233 cancel_cnt += itr->cancelIf(compare);
240 std::vector <DataInPort<DataT>*> bound_in_ports_;
287 template<
class DataT>
309 InPort(portset, name, delivery_phase),
311 data_in_port_events_(this),
318 "DataInPort " << name <<
" does not have a clock");
319 sparta_assert(name.length() != 0,
"You cannot have an unnamed port.");
357 throw SpartaException(
"ERROR: Attempt to bind DataOutPort of a disparate types: '" +
378 user_payload_delivery_->getScheduleable().setContinuing(continuing);
390 bool isDriven(Clock::Cycle rel_cycle)
const override {
391 return user_payload_delivery_->isScheduled(rel_cycle);
400 return user_payload_delivery_->isScheduled();
412 return user_payload_delivery_->cancel();
426 return user_payload_delivery_->cancelIf(criteria);
439 uint32_t
cancelIf(std::function<
bool(
const DataT &)> compare) {
440 return user_payload_delivery_->cancelIf(compare);
449 "Data being received on this DataInPort"));
455 return user_payload_delivery_->getScheduleable();
458 void setProducerPrecedence_(Scheduleable * pd)
override final {
459 if(pd->getSchedulingPhase() == user_payload_delivery_->getSchedulingPhase()) {
460 pd->precedes(user_payload_delivery_->getScheduleable(),
"Port::bind of OutPort to " +
getName() +
": '" +
461 pd->getLabel() +
"' is a registered driver");
465 void registerConsumerHandler_(
const SpartaHandler & handler)
override final
469 <<
": The handler associated with the DataInPort must take at least one argument: "
470 << handler.getName());
471 handler_name_ =
getName() +
"<DataInPort>[" + handler.getName() +
"]";
472 user_payload_delivery_->getScheduleable().setLabel(handler_name_.c_str());
475 void bind_(
Port * outp)
override final
480 if(consumer->getSchedulingPhase() == user_payload_delivery_->getSchedulingPhase()) {
481 user_payload_delivery_->getScheduleable().precedes(consumer,
"Port::bind(" +
getName() +
"->" + outp->getName() +
"),'"
482 + consumer->getLabel() +
"' is registered consumer");
504 void send_(
const DataT & dat, sparta::Clock::Cycle rel_time)
506 const uint32_t total_delay = rel_time + port_delay_;
514 receivePortData_(dat);
518 user_payload_delivery_->preparePayload(dat)->schedule(total_delay, receiver_clock_);
525 std::unique_ptr<PhasedPayloadEvent<DataT>> user_payload_delivery_;
528 std::string handler_name_;
531 const Clock * receiver_clock_ =
nullptr;
534 std::unique_ptr<CollectorType> collector_;
537 void receivePortData_(
const DataT & dat)
545 collector_->collect(dat);
551 const Clock::Cycle port_delay_;
Implementation of the Collectable class that allows a user to collect an object into an pipeViewer pi...
File that defines the DataContainer class.
File that defines the EventSet class.
File that defines the PayloadEvent class.
File that defines the Port base class.
File that defines Precedence operator>> rules between EventNode types.
File that defines the Scheduleable class.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
#define SPARTA_EXPECT_TRUE(x)
A macro for hinting to the compiler a particular condition should be considered most likely true.
#define SPARTA_EXPECT_FALSE(x)
A macro for hinting to the compiler a particular condition should be considered most likely false.
#define CREATE_SPARTA_HANDLER_WITH_DATA(clname, meth, dataT)
Scheduler * getScheduler() const
Used by DataInPort and SyncInPort, this class holds received data from these ports and remembers the ...
void setData_(const DataT &dat)
Set the data received.
DataInPort receives data from sender using a DataOutPort.
Clock::Cycle getPortDelay() const override final
Get the port delay associated with this port.
DataInPort(TreeNode *portset, const std::string &name, sparta::Clock::Cycle delay=0)
Construct a DataInPort with a default delivery phase based on the delay.
uint32_t cancelIf(const DataT &criteria)
Cancel any scheduled Payload that matches the given criteria.
DataInPort(TreeNode *portset, const std::string &name, sparta::SchedulingPhase delivery_phase, sparta::Clock::Cycle delay)
Construct a DataInPort with a specific delivery phase.
void enableCollection(TreeNode *node) override
Enable pipeline collection.
uint32_t cancelIf(std::function< bool(const DataT &)> compare)
Cancel any scheduled Payload that matches the given function.
DataT DataType
Expected typedef for DataT.
uint32_t cancel()
Cancel all outstanding incoming data not delivered
bool isDriven() const override
Is this Port driven at all?
bool isDriven(Clock::Cycle rel_cycle) const override
Determine if this DataInPort is driven on the given cycle.
DataInPort & operator=(const DataInPort &)=delete
No assignments.
void setContinuing(bool continuing) override final
Do events from this port keep simulation going?
DataInPort(const DataInPort &)=delete
No making copies.
void bind(Port *out) override
Check the Data types.
DataOutPort is used for transferring any data to another module.
DataT DataType
A typedef for the type of data this port passes.
DataOutPort(const DataOutPort &)=delete
No making copies!
uint32_t cancel()
Cancel all outstanding port sends regardless of criteria.
bool isDriven(Clock::Cycle rel_cycle) const override
Determine if this DataOutPort has any connected DataInPort where the data is to be delivered on the g...
uint32_t cancelIf(const DataT &criteria)
Cancel any scheduled Payload that matches the given criteria.
DataOutPort(TreeNode *portset, const std::string &name, bool presume_zero_delay=true)
Construct a DataOutPort within the given PortSet.
void bind(Port *in) override
Bind to an DataInPort.
DataOutPort & operator=(const DataOutPort &)=delete
No making assignments!
uint32_t cancelIf(std::function< bool(const DataT &)> compare)
Cancel any scheduled Payload that matches the given function.
bool isDriven() const override
Does this DataOutPort have any DataInPort's where the data is not yet delivered?
void send(const DataT &dat, sparta::Clock::Cycle rel_time=0)
Send data to bound receivers.
Set of Events that a unit (or sparta::TreeNode, sparta::Resource) contains and are visible through a ...
Base class for all InPort types.
Scheduler * scheduler_
The scheduler used.
void bind(Port *out) override
Bind to an OutPort.
void checkSchedulerPhaseForZeroCycleDelivery_(const sparta::SchedulingPhase &user_callback_phase)
Common method for checking phasing.
virtual void bind_(Port *outp)
Called by the OutPort, remember the binding.
ScheduleableList port_consumers_
Base class for all OutPort types.
void bind(Port *in) override
Bind to an InPort.
Class to schedule a Scheduleable in the future with a payload, but the class itself is not typed on t...
The port interface used to bind port types together and defines a port behavior.
const std::string name_
The name of this port.
virtual void bind(Port *port)=0
Method to bind this Port to another, pointer style.
SpartaHandler explicit_consumer_handler_
Explicit consumer handler registered via registerConsumerHandler.
virtual void setContinuing(bool continuing)
A class that defines the basic scheduling interface to the Scheduler. Not intended to be used by mode...
SchedulingPhase getCurrentSchedulingPhase() const
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Node in a composite tree representing a sparta Tree item.
std::string getLocation() const override final
const Clock * getClock() override
Walks up parents (starting with self) until a parent with an associated local clock is found,...
const std::string & getName() const override
Gets the name of this node.
Class used to either manually or auto-collect an Annotation String object in a pipeline database.
Macros for handling exponential backoff.
SchedulingPhase
The SchedulingPhases used for events (Tick, Update, PortUpdate, etc)
@ PortUpdate
N-cycle Ports are updated in this phase.
@ Tick
Most operations (combinational logic) occurs in this phase.