diff options
author | Nilay Vaish <nilay@cs.wisc.edu> | 2014-10-11 15:02:23 -0500 |
---|---|---|
committer | Nilay Vaish <nilay@cs.wisc.edu> | 2014-10-11 15:02:23 -0500 |
commit | e8ed7b1d1b5bef31e9874f679a5797c2e00d06f1 (patch) | |
tree | 421c9c50377aa664958685914f5504c4c019e21f /ext/dsent/model/optical_graph/OpticalNode.cc | |
parent | a098fad174d8559037602b248b8e6f7f46bfebbb (diff) | |
download | gem5-e8ed7b1d1b5bef31e9874f679a5797c2e00d06f1.tar.xz |
ext: add the source code for DSENT
This patch adds a tool called DSENT to the ext/ directory. DSENT
is a tool that models power and area for on-chip networks. The next
patch adds a script for using the tool.
Diffstat (limited to 'ext/dsent/model/optical_graph/OpticalNode.cc')
-rw-r--r-- | ext/dsent/model/optical_graph/OpticalNode.cc | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/ext/dsent/model/optical_graph/OpticalNode.cc b/ext/dsent/model/optical_graph/OpticalNode.cc new file mode 100644 index 000000000..89e034b09 --- /dev/null +++ b/ext/dsent/model/optical_graph/OpticalNode.cc @@ -0,0 +1,96 @@ + +#include "model/optical_graph/OpticalNode.h" + +namespace DSENT +{ + // Set the optical node initial visited num + const int OpticalNode::OPTICAL_NODE_INIT_VISITED_NUM = 0; + + OpticalNode::OpticalNode(Type type_, const String& instance_name_, OpticalModel* model_, const WavelengthGroup& wavelengths_) + :m_type_(type_), m_instance_name_(instance_name_), m_model_(model_), m_wavelengths_(wavelengths_) + { + m_loss_ = 0.0; + setVisitedNum(OpticalNode::OPTICAL_NODE_INIT_VISITED_NUM); + m_downstream_nodes_ = new vector<OpticalNode*>; + } + + OpticalNode::~OpticalNode() + { + + } + + OpticalNode::Type OpticalNode::getType() const + { + return m_type_; + } + + vector<OpticalNode*>* OpticalNode::getDownstreamNodes() const + { + return m_downstream_nodes_; + } + + const String& OpticalNode::getInstanceName() const + { + return m_instance_name_; + } + + OpticalModel* OpticalNode::getModel() + { + return m_model_; + } + + const OpticalModel* OpticalNode::getModel() const + { + return (const OpticalModel*) m_model_; + } + + void OpticalNode::addDownstreamNode(OpticalNode* node_) + { + ASSERT(node_->isExpected(getWavelengths()), "[Error] " + getInstanceName() + + " -> Downstream node not expecting a superset of the current wavelengths"); + m_downstream_nodes_->push_back(node_); + } + + WavelengthGroup OpticalNode::getWavelengths() const + { + return m_wavelengths_; + } + + bool OpticalNode::isExpected(const WavelengthGroup& wavelengths_) const + { + // Check that the lower limits are within bounds + bool lower_match = (wavelengths_.first >= getWavelengths().first); + // Check that the upper limits are within bounds + bool upper_match = (wavelengths_.second <= getWavelengths().second); + // Assert that there are no misalignments + ASSERT(lower_match == upper_match, "[Error] " + getInstanceName() + + " -> Wavelength group misalignment!"); + // Both upper and lower bounds must match + return (upper_match && lower_match); + } + + //------------------------------------------------------------------------- + void OpticalNode::setLoss(double loss_) + { + m_loss_ = loss_; + } + + double OpticalNode::getLoss() const + { + return m_loss_; + } + + void OpticalNode::setVisitedNum(int visited_num_) + { + m_visited_num_ = visited_num_; + } + + int OpticalNode::getVisitedNum() const + { + return m_visited_num_; + } + //------------------------------------------------------------------------- + +} // namespace DSENT + + |