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/electrical/RippleAdder.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/electrical/RippleAdder.cc')
-rw-r--r-- | ext/dsent/model/electrical/RippleAdder.cc | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/ext/dsent/model/electrical/RippleAdder.cc b/ext/dsent/model/electrical/RippleAdder.cc new file mode 100644 index 000000000..779cd4798 --- /dev/null +++ b/ext/dsent/model/electrical/RippleAdder.cc @@ -0,0 +1,106 @@ +#include "model/electrical/RippleAdder.h" + +#include <cmath> + +#include "model/PortInfo.h" +#include "model/TransitionInfo.h" +#include "model/EventInfo.h" +#include "model/std_cells/StdCell.h" +#include "model/std_cells/StdCellLib.h" + +namespace DSENT +{ + RippleAdder::RippleAdder(const String& instance_name_, const TechModel* tech_model_) + : ElectricalModel(instance_name_, tech_model_) + { + initParameters(); + initProperties(); + } + + RippleAdder::~RippleAdder() + {} + + void RippleAdder::initParameters() + { + addParameterName("NumberBits"); + return; + } + + void RippleAdder::initProperties() + { + return; + } + + void RippleAdder::constructModel() + { + // Get properties + unsigned int number_bits = (unsigned int) getParameter("NumberBits"); + + //Construct electrical ports and nets + createInputPort("CI"); + createOutputPort("CO"); + for(unsigned int i = 0; i < number_bits; ++i) + { + createInputPort("A" + String(i)); + createInputPort("B" + String(i)); + createOutputPort("S" + String(i)); + createNet("C" + String(i)); + } + createNet("C" + String(number_bits)); + + //Create energy, power, and area results + createElectricalResults(); + getEventInfo("Idle")->setStaticTransitionInfos(); + createElectricalEventResult("Add"); + Result* add_event = getEventResult("Add"); + + // Connect all nets + assign("C0", "CI"); + assign("CO", "C" + String(number_bits)); + for (unsigned int i = 0; i < number_bits; ++i) + { + String n = (String) i; + StdCell* adder = getTechModel()->getStdCellLib()->createStdCell("ADDF", "ADDF_" + n); + adder->construct(); + + //Build electrical connectivity + portConnect(adder, "A", "A" + String(i)); + portConnect(adder, "B", "B" + String(i)); + portConnect(adder, "CI", "C" + String(i)); + portConnect(adder, "S", "S" + String(i)); + portConnect(adder, "CO", "C" + String(i + 1)); + + //Add ADDF instance, leakage power, energy, and add event results + addSubInstances(adder, 1.0); + addElectricalSubResults(adder, 1.0); + add_event->addSubResult(adder->getEventResult("ADDF"), "ADDF_" + n, 1.0); + } + + return; + } + + void RippleAdder::propagateTransitionInfo() + { + unsigned int number_bits = getParameter("NumberBits").toUInt(); + + TransitionInfo current_trans_CI = getInputPort("CI")->getTransitionInfo(); + for(unsigned int i = 0; i < number_bits; ++i) + { + ElectricalModel* adder = (ElectricalModel*)getSubInstance("ADDF_" + String(i)); + + // Propagate input transition info + propagatePortTransitionInfo(adder, "A", "A" + String(i)); + propagatePortTransitionInfo(adder, "B", "B" + String(i)); + assignPortTransitionInfo(adder, "CI", current_trans_CI); + adder->use(); + + // Assign output transition info + propagatePortTransitionInfo("S" + String(i), adder, "S"); + current_trans_CI = adder->getOutputPort("CO")->getTransitionInfo(); + } + getOutputPort("CO")->setTransitionInfo(current_trans_CI); + return; + } + +} // namespace DSENT + |