The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::Unit Class Reference

The is the base class for user defined blocks in simulation. More...

#include <Unit.hpp>

Inheritance diagram for sparta::Unit:
Collaboration diagram for sparta::Unit:

Public Member Functions

 Unit (TreeNode *rc, const std::string &name)
 Construct unit with a ResouceContainer.
 
 Unit (TreeNode *rc)
 Construct unit with a ResouceContainer.
 
virtual ~Unit ()
 Destroy!
 
void setAutoPrecedence (bool auto_p)
 Turn off auto-precedence.
 
PortSetgetPortSet ()
 Return the port set.
 
EventSetgetEventSet ()
 Return the event set.
 
StatisticSetgetStatisticSet ()
 Return the stat set.
 
- Public Member Functions inherited from sparta::Resource
 Resource (TreeNode *rc)
 Construct resource with a resource container.
 
 Resource (TreeNode *rc, const std::string &name)
 Construct resource with a specific name and resource container.
 
 Resource (const std::string &name, const Clock *clk)
 Construct a Resource with the given name and clock having NO association with a resource container. This constructor is reserved for free-standing resources owned by other resources (not containers [TreeNodes])
 
virtual ~Resource ()
 Destroy!
 
const ClockgetClock () const
 
SchedulergetScheduler (const bool must_exist=true) const
 
std::string getName () const
 
TreeNodegetContainer ()
 Gets the TreeNode (container) for this resource (if any)
 
const TreeNodegetContainer () const
 Gets the TreeNode (container) for this resource (if any)
 
ResourceContainergetResourceContainer ()
 Gets the ResourceContainer for this resource (if any)
 
const ResourceContainergetResourceContainer () const
 Gets the ResourceContainer for this resource (if any)
 
virtual void addLink (TreeNode *node, const std::string &label)
 
virtual void activateLink (const std::string &label)
 
 Resource (const Resource &)=delete
 Disallow copying.
 
Resourceoperator= (const Resource &)=delete
 

Static Public Attributes

static constexpr const char * INFO_LOG = "info"
 
static constexpr const char * WARN_LOG = log::categories::WARN_STR
 
static constexpr const char * DEBUG_LOG = log::categories::DEBUG_STR
 

Protected Member Functions

virtual void onBindTreeEarly_ () override
 
virtual void onBindTreeLate_ () override
 Dump a dot.
 

Protected Attributes

sparta::PortSet unit_port_set_
 The Unit's Ports.
 
sparta::EventSet unit_event_set_
 The Unit's event set.
 
sparta::StatisticSet unit_stat_set_
 The Unit's statistic set.
 
log::MessageSource info_logger_
 Default info logger.
 
log::MessageSource warn_logger_
 Default warn logger.
 
log::MessageSource debug_logger_
 Default debug logger.
 

Friends

class DAG
 

Detailed Description

The is the base class for user defined blocks in simulation.

This class defines common set of sets (sparta::PortSet, sparta::EventSet, and sparta::StatisticSet) as well as common loggers (info_logger_, warn_logger_, debug_logger_). In addition, this class will establish precedences between Ports and Events. See setAutoPrecedence() for more information.

Definition at line 37 of file Unit.hpp.

Constructor & Destructor Documentation

◆ Unit() [1/2]

sparta::Unit::Unit ( TreeNode rc,
const std::string &  name 
)
inline

Construct unit with a ResouceContainer.

Parameters
rcResourceContainer that will hold this Unit until the Unit is destructed. Name and clock are extracted from this container. Must not be nullptr
nameThe name of this Unit

Definition at line 54 of file Unit.hpp.

◆ Unit() [2/2]

sparta::Unit::Unit ( TreeNode rc)
inline

Construct unit with a ResouceContainer.

Parameters
rcResourceContainer that will hold this Unit until the Unit is destructed. Name and clock are extracted from this container. Must not be nullptr

Definition at line 71 of file Unit.hpp.

◆ ~Unit()

virtual sparta::Unit::~Unit ( )
inlinevirtual

Destroy!

Definition at line 76 of file Unit.hpp.

Member Function Documentation

◆ getEventSet()

EventSet * sparta::Unit::getEventSet ( )
inline

Return the event set.

Definition at line 100 of file Unit.hpp.

◆ getPortSet()

PortSet * sparta::Unit::getPortSet ( )
inline

Return the port set.

Definition at line 95 of file Unit.hpp.

◆ getStatisticSet()

StatisticSet * sparta::Unit::getStatisticSet ( )
inline

Return the stat set.

Definition at line 105 of file Unit.hpp.

◆ onBindTreeEarly_()

virtual void sparta::Unit::onBindTreeEarly_ ( )
inlineoverrideprotectedvirtual

From sparta::Resource, set up precedence between ports and events registered in the sets

Reimplemented from sparta::Resource.

Definition at line 121 of file Unit.hpp.

Here is the call graph for this function:

◆ onBindTreeLate_()

virtual void sparta::Unit::onBindTreeLate_ ( )
overrideprotectedvirtual

Dump a dot.

Reimplemented from sparta::Resource.

◆ setAutoPrecedence()

void sparta::Unit::setAutoPrecedence ( bool  auto_p)
inline

Turn off auto-precedence.

Parameters
auto_pTrue, perform auto-precedence, false, don't

By default, the sparta::Unit will establish precedence between registered events (via the unit_event_set_) and registered ports (via the unit_port_set_). Specifically, the Unit will register all events in the sparta::SchedulingPhase::Tick as consumers on InPorts and producers on OutPorts. If this behavior is not desired, call setAutoPrecedence() with the value false.

Definition at line 90 of file Unit.hpp.

Friends And Related Symbol Documentation

◆ DAG

friend class DAG
friend

Definition at line 39 of file Unit.hpp.

Member Data Documentation

◆ DEBUG_LOG

constexpr const char* sparta::Unit::DEBUG_LOG = log::categories::DEBUG_STR
staticconstexpr

Definition at line 44 of file Unit.hpp.

◆ debug_logger_

log::MessageSource sparta::Unit::debug_logger_
protected

Default debug logger.

Definition at line 162 of file Unit.hpp.

◆ INFO_LOG

constexpr const char* sparta::Unit::INFO_LOG = "info"
staticconstexpr

Definition at line 42 of file Unit.hpp.

◆ info_logger_

log::MessageSource sparta::Unit::info_logger_
protected

Default info logger.

Definition at line 156 of file Unit.hpp.

◆ unit_event_set_

sparta::EventSet sparta::Unit::unit_event_set_
protected

The Unit's event set.

Definition at line 114 of file Unit.hpp.

◆ unit_port_set_

sparta::PortSet sparta::Unit::unit_port_set_
protected

The Unit's Ports.

Definition at line 111 of file Unit.hpp.

◆ unit_stat_set_

sparta::StatisticSet sparta::Unit::unit_stat_set_
protected

The Unit's statistic set.

Definition at line 117 of file Unit.hpp.

◆ WARN_LOG

constexpr const char* sparta::Unit::WARN_LOG = log::categories::WARN_STR
staticconstexpr

Definition at line 43 of file Unit.hpp.

◆ warn_logger_

log::MessageSource sparta::Unit::warn_logger_
protected

Default warn logger.

Definition at line 159 of file Unit.hpp.


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