113 const std::string& name,
int start,
int duration) {
114 const string procName =
"ExecutionPipeline::addResourceUse";
142 const string procName =
"ExecutionPipeline::addPortRead";
168 const string procName =
"ExecutionPipeline::addPortWrite";
171 throw OutOfRange(__FILE__, __LINE__, procName);
190 const string procName =
"ExecutionPipeline::removeResourceUse";
216 const string procName =
"ExecutionPipeline::removeResourceUse";
223 throw OutOfRange(__FILE__, __LINE__, procName);
230 if (cycle == 0 || cycle == 1) {
254 for (ResourceSet::const_iterator iter =
usedResources.begin();
256 parent->
cleanup((*iter)->name());
273 const string procName =
"ExecutionPipeline::removeOperandUse";
275 if (cycle < 0 || operand < 1) {
276 throw OutOfRange(__FILE__, __LINE__, procName);
302 const string procName =
"ExecutionPipeline::isResourceUsed";
303 throw OutOfRange(__FILE__, __LINE__, procName);
311 if (resource == NULL) {
329 const string procName =
"ExecutionPipeline::isResourceUsed";
330 throw OutOfRange(__FILE__, __LINE__, procName);
364 const string procName =
"ExecutionPipeline::isPortRead";
365 throw OutOfRange(__FILE__, __LINE__, procName);
388 const string procName =
"ExecutionPipeline::isPortRead";
389 throw OutOfRange(__FILE__, __LINE__, procName);
410 const string procName =
"ExecutionPipeline::readOperands";
411 throw OutOfRange(__FILE__, __LINE__, procName);
431 const string procName =
"ExecutionPipeline::readOperands";
432 throw OutOfRange(__FILE__, __LINE__, procName);
450 for (
int i = 0; i <
latency(); i++) {
452 operands.insert(cycleOperands.begin(), cycleOperands.end());
466 for (
int i = 0; i <
latency(); i++) {
468 operands.insert(cycleOperands.begin(), cycleOperands.end());
500 for (IOUsage::const_reverse_iterator iter =
opWrites_.rbegin();
509 (boost::format(
"Latency for operand index %d was not found for "
510 "operation '%s' on unit '%s'!") % output %
parent_->
name()
530 for (IOUsage::const_iterator iter =
opReads_.begin();
538 const string errMessage =
"Propably broken operand binding in operation:"
541 const string procName =
"ExecutionPipeline::slack";
557 for (ResourceUsage::const_iterator resUsageIter =
resourceUsage_.begin();
561 for (ResourceSet::const_iterator cycleUsageIter = cycleUsage.begin();
562 cycleUsageIter != cycleUsage.end(); cycleUsageIter++) {
571 for (IOUsage::const_iterator readsIter =
opReads_.begin();
572 readsIter !=
opReads_.end(); readsIter++) {
575 for (OperandSet::const_iterator opIter = operands.begin();
576 opIter != operands.end(); opIter++) {
577 int operand = *opIter;
586 for (IOUsage::const_iterator writesIter =
opWrites_.begin();
587 writesIter !=
opWrites_.end(); writesIter++) {
590 for (OperandSet::const_iterator opIter = operands.begin();
591 opIter != operands.end(); opIter++) {
592 int operand = *opIter;
599 return pipelineState;
612 const string procName =
"ExecutionPipeline::loadState";
623 for (ObjectStateTable::const_iterator iter = childTable.begin();
624 iter != childTable.end(); iter++) {
645 __FILE__, __LINE__, procName);
649 format errorMsg = textGen.
text(
654 __FILE__, __LINE__, procName, errorMsg.str());
657 format errorMsg = textGen.
text(
659 errorMsg % resourceName;
661 __FILE__, __LINE__, procName, errorMsg.str());
664 format errorMsg = textGen.
text(
669 __FILE__, __LINE__, procName, errorMsg.str());
672 format errorMsg = textGen.
text(
676 __FILE__, __LINE__, errorMsg.str());
682 __FILE__, __LINE__, procName, exception.
errorMessage());
724 const string procName =
"ExecutionPipeline::checkStartCycle";
726 if (startCycle < 0) {
727 throw OutOfRange(__FILE__, __LINE__, procName);
730 if (startCycle > 1) {
753 const string procName =
"ExecutionPipeline::checkDuration";
754 throw OutOfRange(__FILE__, __LINE__, procName);
767 const string procName =
"ExecutionPipeline::checkResourceName";
783 const string procName =
"ExecutionPipeline::checkInputOperand";
786 throw OutOfRange(__FILE__, __LINE__, procName);
805 const string procName =
"ExecutionPipeline::checkOutputOperand";
808 throw OutOfRange(__FILE__, __LINE__, procName);
827 const std::string& resource,
int start,
int duration)
const {
829 if (element == NULL) {
833 int end = start + duration - 1;
838 for (
int cycle = start; cycle <= end; cycle++) {
840 const string procName =
841 "ExecutionPipeline::checkResourceAvailability";
859 int operand,
int start,
int duration)
const {
860 int end = start + duration - 1;
865 for (
int cycle = start; cycle <= end; cycle++) {
868 const string procName =
869 "ExecutionPipeline::checkOperandAvailability";
885 const std::string& name,
896 for (
int cycle = start; cycle < start + duration; cycle++) {
917 if (start + duration >
latency()) {
921 for (
int cycle = start; cycle < start + duration; cycle++) {
922 toModify[cycle].insert(operand);
937 const std::string& name,
942 if (toRemove == NULL) {
946 int end = start + duration - 1;
951 for (
int cycle = start; cycle <= end; cycle++) {
976 int end = start + duration - 1;
981 for (
int cycle = start; cycle <= end; cycle++) {
1010 }
else if (newLatency <
latency()) {
1011 for (
int cycle =
latency() - 1; cycle >= newLatency; cycle--) {
1039 for (OperandSet::const_iterator iter = operands.begin();
1040 iter != operands.end(); iter++) {
1059 for (
int cycle = 0; cycle <
latency; cycle++) {
1078 for (
int cycle = 0; cycle <
latency; cycle++) {
1101 for (
int cycle = 0; cycle <
latency; cycle++) {
1122 const std::string& resource)
const {
1125 if (element == NULL) {
1130 for (
int i = 0; i <
latency; i++) {
1157 const std::string& resource,
1161 if (currentFirstCycle != cycle) {
1162 return currentFirstCycle;
1166 if (element == NULL) {
1167 return currentFirstCycle;
1180 for (
int i = cycle + 1; i <
latency; i++) {
1206 if (currentFirstCycle != cycle) {
1207 return currentFirstCycle;
1222 for (
int i = cycle + 1; i <
latency; i++) {
1243 for (
int cycle = 0; cycle <
latency; cycle++) {
1245 resources.insert(cycleResources.begin(), cycleResources.end());
1295 string elementName = element->
name();
1296 bool resourceFound =
false;
1298 for (
int i = 0; i < pipelineState->
childCount(); i++) {
1307 resourceFound =
true;
1313 if (!resourceFound) {
1338 const std::string& osName) {
1342 for (
int i = 0; i < pipelineState->
childCount(); i++) {
1344 if (child->
name() == osName &&
1359 pipelineState->
addChild(operandUsage);
1380 for (
int i = 0; i < pipelineState->
childCount(); i++) {
1405 for (ObjectStateTable::iterator iter = usages.begin();
1406 iter != usages.end(); iter++) {
1409 if (startCycle < usageStart) {
1410 usages.insert(iter, usageState);
1415 string procName =
"ExecutionPipeline::addResourceUsage";
1417 __FILE__, __LINE__, procName, exception.
errorMessage());
1420 usages.push_back(usageState);
#define assert(condition)
std::string errorMessage() const
@ TXT_PORT_READ_AND_WRITTEN_BY_PIPELINE
@ TXT_PIPELINE_NOT_CANONICAL
@ TXT_PIPELINE_START_TOO_LATE
static bool isValidComponentName(const std::string &name)
void setAttribute(const std::string &name, const std::string &value)
ObjectState * child(int index) const
void addChild(ObjectState *child)
std::string stringAttribute(const std::string &name) const
int intAttribute(const std::string &name) const
virtual TCEString name() const
void checkOutputOperand(int operand) const
ExecutionPipeline(HWOperation &parentOperation)
OperandSet writtenOperands(int cycle) const
ObjectStateTable sortResourceUsages(const ObjectState *pipelineState) const
static void checkResourceName(const std::string &name)
void loadState(const ObjectState *state)
bool isPortUsed(const FUPort &port, int cycle) const
OperandSet readOperands() const
static void checkDuration(int duration)
bool isArchitectureEqual(const ExecutionPipeline *pipeline) const
void removeAllResourceUses()
std::vector< const ObjectState * > ObjectStateTable
Vector for ObjectState pointers.
void addResourceUse(const std::string &name, int start, int duration)
void checkInputOperand(int operand) const
void internalRemoveOperandUse(int operand, int start, int duration)
PipelineElement * pipelineElement(const std::string &name) const
static const std::string OSKEY_RESOURCE_NAME
ObjectState attribute key for name of resource.
void addResourceUsage(ObjectStateTable &usages, const ObjectState *usageState) const
OperandSet writtenOperands() const
static const std::string OSNAME_OPERAND_WRITE
ObjectState name for operand write.
int firstCycleWithoutOperandUse(int operand, int cycle) const
void internalRemoveResourceUse(const std::string &name, int start, int duration)
void addPortRead(int operand, int start, int duration)
bool isOperandWritten(int operand) const
void removeOperandUse(int operand, int cycle)
OperandSet readOperands(int cycle) const
IOUsage opReads_
Operand reads.
IOUsage opWrites_
Operand writes.
std::set< int > OperandSet
Set for operand indexes.
static void saveOperandUse(int operand, int cycleToSave, ObjectState *pipelineState, const std::string &osName)
static const std::string OSKEY_START_CYCLE
ObjectState attribute key for start cycle of a resource usage.
ObjectState * saveState() const
bool isOperandBound(const FUPort &port, const OperandSet &operands) const
void checkStartCycle(int startCycle) const
static const std::string OSKEY_OPERAND
ObjectState attribute key for operand number.
HWOperation * parent_
The parent operation.
int slack(int input) const
void internalAddResourceUse(const std::string &name, int start, int duration)
static const std::string OSNAME_OPERAND_READ
ObjectState name for operand read.
void internalAddPortUse(int operand, int start, int duration, IOUsage &toModify)
ResourceSet resourceUsages(int cycle) const
ResourceSet usedResources() const
virtual ~ExecutionPipeline()
void addPortWrite(int operand, int start, int duration)
void adjustLatency(int newLatency)
bool isPortWritten(const FUPort &port, int cycle) const
bool isPortRead(const FUPort &port, int cycle) const
void removeResourceUse(const std::string &name)
int firstCycleWithoutResource(const std::string &resource) const
void checkOperandAvailability(int operand, int start, int duration) const
bool isResourceUsed(const std::string &name, int cycle) const
static const std::string OSNAME_PIPELINE
ObjectState name for ExecutionPipeline.
static const std::string OSNAME_RESOURCE_USAGE
ObjectState name for pipeline resource usage.
std::set< PipelineElement *, PipelineElement::Comparator > ResourceSet
Set for pipeline elements.
static const std::string OSKEY_CYCLES
ObjectState attribute key for duration of a resource usage.
ResourceUsage resourceUsage_
Resource usage.
bool isOperandRead(int operand) const
const HWOperation * parentOperation() const
void checkResourceAvailability(const std::string &resource, int start, int duration) const
std::vector< OperandSet > IOUsage
Vector for operand sets.
static void saveResourceUse(const PipelineElement *element, int cycleToSave, ObjectState *pipelineState)
PipelineElement * addPipelineElement(const std::string &name) const
virtual bool hasPipelineElement(const std::string &name) const
virtual void cleanup(const std::string &resource)
virtual PipelineElement * pipelineElement(int index) const
ExecutionPipeline * pipeline() const
virtual FUPort * port(int operand) const
const std::string & name() const
FunctionUnit * parentUnit() const
const std::string & name() const
virtual boost::format text(int textId)