OpenASIP 2.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
TTAMachine::ExecutionPipeline Class Reference

#include <ExecutionPipeline.hh>

Inheritance diagram for TTAMachine::ExecutionPipeline:
Inheritance graph
Collaboration diagram for TTAMachine::ExecutionPipeline:
Collaboration graph

Public Types

typedef std::set< int > OperandSet
 Set for operand indexes.
 
typedef std::set< PipelineElement *, PipelineElement::ComparatorResourceSet
 Set for pipeline elements.
 

Public Member Functions

 ExecutionPipeline (HWOperation &parentOperation)
 
virtual ~ExecutionPipeline ()
 
const HWOperationparentOperation () const
 
void addResourceUse (const std::string &name, int start, int duration)
 
void addPortRead (int operand, int start, int duration)
 
void addPortWrite (int operand, int start, int duration)
 
void removeResourceUse (const std::string &name)
 
void removeResourceUse (const std::string &name, int cycle)
 
void removeAllResourceUses ()
 
void removeOperandUse (int operand, int cycle)
 
bool isResourceUsed (const std::string &name, int cycle) const
 
ResourceSet resourceUsages (int cycle) const
 
bool isPortUsed (const FUPort &port, int cycle) const
 
bool isPortRead (const FUPort &port, int cycle) const
 
bool isPortWritten (const FUPort &port, int cycle) const
 
OperandSet readOperands (int cycle) const
 
OperandSet writtenOperands (int cycle) const
 
OperandSet readOperands () const
 
OperandSet writtenOperands () const
 
int latency () const
 
int latency (int output) const
 
int slack (int input) const
 
ObjectStatesaveState () const
 
void loadState (const ObjectState *state)
 
bool isArchitectureEqual (const ExecutionPipeline *pipeline) const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 

Static Public Attributes

static const std::string OSNAME_PIPELINE = "pipeline"
 ObjectState name for ExecutionPipeline.
 
static const std::string OSNAME_RESOURCE_USAGE = "resource_usage"
 ObjectState name for pipeline resource usage.
 
static const std::string OSNAME_OPERAND_READ = "op_read"
 ObjectState name for operand read.
 
static const std::string OSNAME_OPERAND_WRITE = "op_write"
 ObjectState name for operand write.
 
static const std::string OSKEY_RESOURCE_NAME = "res_name"
 ObjectState attribute key for name of resource.
 
static const std::string OSKEY_OPERAND = "operand"
 ObjectState attribute key for operand number.
 
static const std::string OSKEY_START_CYCLE = "start_cycle"
 ObjectState attribute key for start cycle of a resource usage.
 
static const std::string OSKEY_CYCLES = "cycles"
 ObjectState attribute key for duration of a resource usage.
 

Private Types

typedef std::vector< const ObjectState * > ObjectStateTable
 Vector for ObjectState pointers.
 
typedef std::vector< ResourceSetResourceUsage
 Vector for resource sets.
 
typedef std::vector< OperandSetIOUsage
 Vector for operand sets.
 

Private Member Functions

void checkStartCycle (int startCycle) const
 
void checkInputOperand (int operand) const
 
void checkOutputOperand (int operand) const
 
void checkResourceAvailability (const std::string &resource, int start, int duration) const
 
void checkOperandAvailability (int operand, int start, int duration) const
 
void internalAddResourceUse (const std::string &name, int start, int duration)
 
void internalAddPortUse (int operand, int start, int duration, IOUsage &toModify)
 
void internalRemoveResourceUse (const std::string &name, int start, int duration)
 
void internalRemoveOperandUse (int operand, int start, int duration)
 
void adjustLatency (int newLatency)
 
bool isOperandBound (const FUPort &port, const OperandSet &operands) const
 
bool isOperandWritten (int operand) const
 
bool isOperandRead (int operand) const
 
int firstCycle () const
 
int firstCycleWithoutResource (const std::string &resource) const
 
int firstCycleWithoutResource (const std::string &resource, int cycle) const
 
int firstCycleWithoutOperandUse (int operand, int cycle) const
 
ResourceSet usedResources () const
 
PipelineElementpipelineElement (const std::string &name) const
 
PipelineElementaddPipelineElement (const std::string &name) const
 
ObjectStateTable sortResourceUsages (const ObjectState *pipelineState) const
 
void addResourceUsage (ObjectStateTable &usages, const ObjectState *usageState) const
 

Static Private Member Functions

static void checkDuration (int duration)
 
static void checkResourceName (const std::string &name)
 
static void saveResourceUse (const PipelineElement *element, int cycleToSave, ObjectState *pipelineState)
 
static void saveOperandUse (int operand, int cycleToSave, ObjectState *pipelineState, const std::string &osName)
 

Private Attributes

ResourceUsage resourceUsage_
 Resource usage.
 
IOUsage opReads_
 Operand reads.
 
IOUsage opWrites_
 Operand writes.
 
HWOperationparent_
 The parent operation.
 

Additional Inherited Members

- Protected Member Functions inherited from TTAMachine::SubComponent
 SubComponent ()
 
virtual ~SubComponent ()
 
- Protected Member Functions inherited from TTAMachine::MachinePart
 MachinePart ()
 
virtual ~MachinePart ()
 

Detailed Description

Represents an execution pipeline in function unit.

Definition at line 55 of file ExecutionPipeline.hh.

Member Typedef Documentation

◆ IOUsage

typedef std::vector<OperandSet> TTAMachine::ExecutionPipeline::IOUsage
private

Vector for operand sets.

Definition at line 120 of file ExecutionPipeline.hh.

◆ ObjectStateTable

typedef std::vector<const ObjectState*> TTAMachine::ExecutionPipeline::ObjectStateTable
private

Vector for ObjectState pointers.

Definition at line 115 of file ExecutionPipeline.hh.

◆ OperandSet

Set for operand indexes.

Definition at line 58 of file ExecutionPipeline.hh.

◆ ResourceSet

Set for pipeline elements.

Definition at line 60 of file ExecutionPipeline.hh.

◆ ResourceUsage

Vector for resource sets.

Definition at line 118 of file ExecutionPipeline.hh.

Constructor & Destructor Documentation

◆ ExecutionPipeline()

TTAMachine::ExecutionPipeline::ExecutionPipeline ( HWOperation parentOperation)

Constructor.

Parameters
parentOperationThe parent operation which uses the pipeline.

Definition at line 68 of file ExecutionPipeline.cc.

68 :
70
71 // run time sanity check
73}
#define assert(condition)
HWOperation * parent_
The parent operation.
const HWOperation * parentOperation() const
ExecutionPipeline * pipeline() const

References assert, parentOperation(), and TTAMachine::HWOperation::pipeline().

Here is the call graph for this function:

◆ ~ExecutionPipeline()

TTAMachine::ExecutionPipeline::~ExecutionPipeline ( )
virtual

Destructor.

Definition at line 79 of file ExecutionPipeline.cc.

References removeAllResourceUses().

Here is the call graph for this function:

Member Function Documentation

◆ addPipelineElement()

PipelineElement * TTAMachine::ExecutionPipeline::addPipelineElement ( const std::string &  name) const
private

Creates a pipeline element by the given name.

Parameters
nameThe name of the pipeline element.
Returns
The pipeline element that was created.

Definition at line 1272 of file ExecutionPipeline.cc.

1272 {
1273 FunctionUnit* fu = parent_->parentUnit();
1274 if (!fu->hasPipelineElement(name)) {
1275 new PipelineElement(name, *fu);
1276 }
1277 return fu->pipelineElement(name);
1278}
FunctionUnit * parentUnit() const

References TTAMachine::FunctionUnit::hasPipelineElement(), parent_, TTAMachine::HWOperation::parentUnit(), and TTAMachine::FunctionUnit::pipelineElement().

Referenced by internalAddResourceUse().

Here is the call graph for this function:

◆ addPortRead()

void TTAMachine::ExecutionPipeline::addPortRead ( int  operand,
int  start,
int  duration 
)

Adds read usage of an operand.

Parameters
operandThe operand to be read.
startStart cycle of the usage.
durationDuration of the usage.
Exceptions
OutOfRangeIf the given cycle is less than 0 or if duration or operand is less than 1.
WrongOperandTypeIf the given operand is not an input operand, that is, if a port write is already added with the given operand.
StartTooLateIf the pipeline does not start by resource usage or operand read at cycle 0 or 1.
NotAvailableIf the given operand is already read at a cycle in the given time interval.

Definition at line 141 of file ExecutionPipeline.cc.

141 {
142 const string procName = "ExecutionPipeline::addPortRead";
143
144 checkStartCycle(start);
145 checkDuration(duration);
146 checkInputOperand(operand);
147 checkOperandAvailability(operand, start, duration);
148
149 internalAddPortUse(operand, start, duration, opReads_);
150}
static void checkDuration(int duration)
void checkInputOperand(int operand) const
void checkStartCycle(int startCycle) const
void internalAddPortUse(int operand, int start, int duration, IOUsage &toModify)
void checkOperandAvailability(int operand, int start, int duration) const

References checkDuration(), checkInputOperand(), checkOperandAvailability(), checkStartCycle(), internalAddPortUse(), and opReads_.

Referenced by VectorLSGenerator::addOperation(), HDB::HDBManager::addOperationPipelinesToFUArchitecture(), BlocksLSU::ConfigurePipeline(), BlocksALU::ConfigurePipeline(), BlocksGCU::ConfigurePipeline(), BlocksMUL::ConfigurePipeline(), UniversalMachine::construct(), OpsetDialog::createOperation(), AddGCUCmd::Do(), CostEstimator::ICDecoderEstimatorPlugin::generateControlUnit(), loadState(), OperationDialog::onOperandLClick(), and SmartHWOperation::SmartHWOperation().

Here is the call graph for this function:

◆ addPortWrite()

void TTAMachine::ExecutionPipeline::addPortWrite ( int  operand,
int  start,
int  duration 
)

Adds write usage of an operand.

Parameters
operandThe operand to be written.
startStart cycle of the usage.
durationDuration of the usage.
Exceptions
OutOfRangeIf the given cycle is less than 0 or if duration or operand is less than 1.
WrongOperandTypeIf the given operand is not an output operand, that is, if a port read is already added with the given operand.
NotAvailableIf the given operand is already written at a cycle in the given time interval.

Definition at line 167 of file ExecutionPipeline.cc.

167 {
168 const string procName = "ExecutionPipeline::addPortWrite";
169
170 if (start < 0) {
171 throw OutOfRange(__FILE__, __LINE__, procName);
172 }
173
174 checkDuration(duration);
175 checkOutputOperand(operand);
176 checkOperandAvailability(operand, start, duration);
177
178 internalAddPortUse(operand, start, duration, opWrites_);
179}
void checkOutputOperand(int operand) const
IOUsage opWrites_
Operand writes.

References checkDuration(), checkOperandAvailability(), checkOutputOperand(), internalAddPortUse(), and opWrites_.

Referenced by VectorLSGenerator::addOperation(), HDB::HDBManager::addOperationPipelinesToFUArchitecture(), BlocksLSU::ConfigurePipeline(), BlocksALU::ConfigurePipeline(), BlocksMUL::ConfigurePipeline(), OpsetDialog::createOperation(), loadState(), OperationDialog::onOperandLClick(), and SmartHWOperation::SmartHWOperation().

Here is the call graph for this function:

◆ addResourceUsage()

void TTAMachine::ExecutionPipeline::addResourceUsage ( ObjectStateTable usages,
const ObjectState usageState 
) const
private

Adds the given ObjectState instance representing a resource usage to the given set of usages to correct position.

The correct position is determined by the start cycle of the resource usage.

Parameters
usagesThe set of resource usages where to add the given usage.
usageStateThe usageState to add.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState instance is invalid.

Definition at line 1401 of file ExecutionPipeline.cc.

1402 {
1403 try {
1404 int startCycle = usageState->intAttribute(OSKEY_START_CYCLE);
1405 for (ObjectStateTable::iterator iter = usages.begin();
1406 iter != usages.end(); iter++) {
1407 const ObjectState* usage = *iter;
1408 int usageStart = usage->intAttribute(OSKEY_START_CYCLE);
1409 if (startCycle < usageStart) {
1410 usages.insert(iter, usageState);
1411 return;
1412 }
1413 }
1414 } catch (const Exception& exception) {
1415 string procName = "ExecutionPipeline::addResourceUsage";
1417 __FILE__, __LINE__, procName, exception.errorMessage());
1418 }
1419
1420 usages.push_back(usageState);
1421}
std::string errorMessage() const
Definition Exception.cc:123
int intAttribute(const std::string &name) const
static const std::string OSKEY_START_CYCLE
ObjectState attribute key for start cycle of a resource usage.

References Exception::errorMessage(), ObjectState::intAttribute(), and OSKEY_START_CYCLE.

Referenced by sortResourceUsages().

Here is the call graph for this function:

◆ addResourceUse()

void TTAMachine::ExecutionPipeline::addResourceUse ( const std::string &  name,
int  start,
int  duration 
)

Adds use for the given pipeline element.

If the function unit does not have a pipeline element by the given name the pipeline element is added to the function unit. Pipeline is valid only if it starts at cycle 0 or 1.

Parameters
nameName of the pipeline element.
startFirst cycle in which the element is used relative to operation start cycle.
durationNumber of cycles the element is used.
Exceptions
OutOfRangeIf given start cycle or duration is out of range.
InvalidNameIf the given name is not a valid component name.
StartTooLateIf the pipeline does not start by resource usage or operand read at cycle 0 or 1.
NotAvailableIf the given resource is already in use at a cycle in the given time interval.

Definition at line 112 of file ExecutionPipeline.cc.

113 {
114 const string procName = "ExecutionPipeline::addResourceUse";
115
116 checkStartCycle(start);
117 checkDuration(duration);
118 checkResourceName(name);
119 checkResourceAvailability(name, start, duration);
120
121 internalAddResourceUse(name, start, duration);
122}
static void checkResourceName(const std::string &name)
void internalAddResourceUse(const std::string &name, int start, int duration)
void checkResourceAvailability(const std::string &resource, int start, int duration) const

References checkDuration(), checkResourceAvailability(), checkResourceName(), checkStartCycle(), and internalAddResourceUse().

Referenced by HDB::HDBManager::addOperationPipelinesToFUArchitecture(), loadState(), and OperationDialog::onResourceLClick().

Here is the call graph for this function:

◆ adjustLatency()

void TTAMachine::ExecutionPipeline::adjustLatency ( int  newLatency)
private

Adjusts the size of usage vectors for the given latency.

If the given latency is greater than the current latency, sizes of the usage vectors are increased. If the given latency is smaller than the current latency (vector size), sizes of the vectors are tried to decrease to match with the given latency. However, if there are non-empty elements in the usage vectors, they are not removed.

Parameters
newLatencyThe new latency.

Definition at line 1003 of file ExecutionPipeline.cc.

1003 {
1004
1005 if (newLatency > latency()) {
1006 resourceUsage_.resize(newLatency);
1007 opReads_.resize(newLatency);
1008 opWrites_.resize(newLatency);
1009
1010 } else if (newLatency < latency()) {
1011 for (int cycle = latency() - 1; cycle >= newLatency; cycle--) {
1012 if (resourceUsage_[cycle].empty() && opReads_[cycle].empty() &&
1013 opWrites_[cycle].empty()) {
1014 resourceUsage_.resize(cycle);
1015 opReads_.resize(cycle);
1016 opWrites_.resize(cycle);
1017 } else {
1018 break;
1019 }
1020 }
1021 }
1022}
ResourceUsage resourceUsage_
Resource usage.

References latency(), opReads_, opWrites_, and resourceUsage_.

Referenced by internalAddPortUse(), internalAddResourceUse(), internalRemoveOperandUse(), and internalRemoveResourceUse().

Here is the call graph for this function:

◆ checkDuration()

void TTAMachine::ExecutionPipeline::checkDuration ( int  duration)
staticprivate

Checks whether the given value is valid for duration of resource usage.

Parameters
durationThe duration value.
Exceptions
OutOfRangeIf the value is not in a valid range.

Definition at line 751 of file ExecutionPipeline.cc.

751 {
752 if (duration < 1) {
753 const string procName = "ExecutionPipeline::checkDuration";
754 throw OutOfRange(__FILE__, __LINE__, procName);
755 }
756}

Referenced by addPortRead(), addPortWrite(), and addResourceUse().

◆ checkInputOperand()

void TTAMachine::ExecutionPipeline::checkInputOperand ( int  operand) const
private

Checks whether the given operand is an input operand.

The operand is an input operand if it is read by the pipeline already.

Parameters
operandThe operand.
Exceptions
OutOfRangeIf the given operand is smaller than 1.
WrongOperandTypeIf the operand is written by the pipeline.

Definition at line 782 of file ExecutionPipeline.cc.

782 {
783 const string procName = "ExecutionPipeline::checkInputOperand";
784
785 if (operand < 1) {
786 throw OutOfRange(__FILE__, __LINE__, procName);
787 }
788
789 if (isOperandWritten(operand)) {
790 throw WrongOperandType(__FILE__, __LINE__, procName);
791 }
792}
bool isOperandWritten(int operand) const

References isOperandWritten().

Referenced by addPortRead().

Here is the call graph for this function:

◆ checkOperandAvailability()

void TTAMachine::ExecutionPipeline::checkOperandAvailability ( int  operand,
int  start,
int  duration 
) const
private

Checks whether the given operand is not read or written at the given time interval.

Parameters
operandThe operand.
startThe start cycle.
durationDuration of the usage.
Exceptions
NotAvailableIf the given operand is used at the given time interval.

Definition at line 858 of file ExecutionPipeline.cc.

859 {
860 int end = start + duration - 1;
861 if (end >= latency()) {
862 end = latency() - 1;
863 }
864
865 for (int cycle = start; cycle <= end; cycle++) {
866 if (AssocTools::containsKey(opReads_[cycle], operand) ||
867 AssocTools::containsKey(opWrites_[cycle], operand)) {
868 const string procName =
869 "ExecutionPipeline::checkOperandAvailability";
870 throw NotAvailable(__FILE__, __LINE__, procName);
871 }
872 }
873}
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)

References AssocTools::containsKey(), latency(), opReads_, and opWrites_.

Referenced by addPortRead(), and addPortWrite().

Here is the call graph for this function:

◆ checkOutputOperand()

void TTAMachine::ExecutionPipeline::checkOutputOperand ( int  operand) const
private

Checks whether the given operand is an output operand.

The operand is an output operand if it is written by the pipeline already.

Parameters
operandThe operand.
Exceptions
OutOfRangeIf the given operand is smaller than 1.
WrongOperandTypeIf the operand is read by the pipeline.

Definition at line 804 of file ExecutionPipeline.cc.

804 {
805 const string procName = "ExecutionPipeline::checkOutputOperand";
806
807 if (operand < 1) {
808 throw OutOfRange(__FILE__, __LINE__, procName);
809 }
810
811 if (isOperandRead(operand)) {
812 throw WrongOperandType(__FILE__, __LINE__, procName);
813 }
814}
bool isOperandRead(int operand) const

References isOperandRead().

Referenced by addPortWrite().

Here is the call graph for this function:

◆ checkResourceAvailability()

void TTAMachine::ExecutionPipeline::checkResourceAvailability ( const std::string &  resource,
int  start,
int  duration 
) const
private

Checks whether the given resource is available all the time of the given time interval.

Parameters
resourceName of the pipeline resource.
startThe start cycle.
durationDuration of the usage.
Exceptions
NotAvailableIf the given resource is not available.

Definition at line 826 of file ExecutionPipeline.cc.

827 {
828 PipelineElement* element = pipelineElement(resource);
829 if (element == NULL) {
830 return;
831 }
832
833 int end = start + duration - 1;
834 if (end >= latency()) {
835 end = latency() - 1;
836 }
837
838 for (int cycle = start; cycle <= end; cycle++) {
839 if (AssocTools::containsKey(resourceUsage_[cycle], element)) {
840 const string procName =
841 "ExecutionPipeline::checkResourceAvailability";
842 throw NotAvailable(__FILE__, __LINE__, procName);
843 }
844 }
845}
PipelineElement * pipelineElement(const std::string &name) const

References AssocTools::containsKey(), latency(), pipelineElement(), and resourceUsage_.

Referenced by addResourceUse().

Here is the call graph for this function:

◆ checkResourceName()

void TTAMachine::ExecutionPipeline::checkResourceName ( const std::string &  name)
staticprivate

Checks whether the given name is valid for pipeline resource.

Parameters
nameThe name.
Exceptions
InvalidNameIf the name is not valid for pipeline resource.

Definition at line 765 of file ExecutionPipeline.cc.

765 {
767 const string procName = "ExecutionPipeline::checkResourceName";
768 throw InvalidName(__FILE__, __LINE__, procName);
769 }
770}
static bool isValidComponentName(const std::string &name)

References MachineTester::isValidComponentName().

Referenced by addResourceUse().

Here is the call graph for this function:

◆ checkStartCycle()

void TTAMachine::ExecutionPipeline::checkStartCycle ( int  startCycle) const
private

Checks whether the pipeline would start too late if a new resource usage or operand read was added starting at given cycle.

Parameters
startCycleThe start cycle.
Exceptions
OutOfRangeIf the given cycle is negative.
StartTooLateIf the pipeline would start too late.

Definition at line 723 of file ExecutionPipeline.cc.

723 {
724 const string procName = "ExecutionPipeline::checkStartCycle";
725
726 if (startCycle < 0) {
727 throw OutOfRange(__FILE__, __LINE__, procName);
728 }
729
730 if (startCycle > 1) {
731 if (latency() == 0) {
732 throw StartTooLate(__FILE__, __LINE__, procName);
733 } else if (latency() == 1 && resourceUsage_[0].empty() &&
734 opReads_[0].empty()) {
735 throw StartTooLate(__FILE__, __LINE__, procName);
736 } else if (latency() >= 2 && resourceUsage_[0].empty() &&
737 resourceUsage_[1].empty() && opReads_[0].empty() &&
738 opReads_[1].empty()) {
739 throw StartTooLate(__FILE__, __LINE__, procName);
740 }
741 }
742}

References latency(), opReads_, and resourceUsage_.

Referenced by addPortRead(), and addResourceUse().

Here is the call graph for this function:

◆ firstCycle()

int TTAMachine::ExecutionPipeline::firstCycle ( ) const
private

Returns the first cycle when a resource is used or a port read by this pipeline.

Returns -1 if no resource is used or port read by this pipeline.

Returns
The first cycle or -1.

Definition at line 1097 of file ExecutionPipeline.cc.

1097 {
1098
1099 int latency = this->latency();
1100
1101 for (int cycle = 0; cycle < latency; cycle++) {
1102 if (!resourceUsage_[cycle].empty() || !opReads_[cycle].empty()) {
1103 return cycle;
1104 }
1105 }
1106
1107 return -1;
1108}

References latency(), opReads_, and resourceUsage_.

Referenced by firstCycleWithoutOperandUse(), firstCycleWithoutResource(), and firstCycleWithoutResource().

Here is the call graph for this function:

◆ firstCycleWithoutOperandUse()

int TTAMachine::ExecutionPipeline::firstCycleWithoutOperandUse ( int  operand,
int  cycle 
) const
private

Returns the first cycle when a resource is used or port read if usage of the given operand is removed from the given cycle.

Returns -1 if no resource is used.

Parameters
operandThe operand.
cycleThe cycle.
Returns
The first cycle or -1.

Definition at line 1201 of file ExecutionPipeline.cc.

1203 {
1204
1205 int currentFirstCycle = firstCycle();
1206 if (currentFirstCycle != cycle) {
1207 return currentFirstCycle;
1208 }
1209
1210
1211 if (opReads_[cycle].size() > 1 ||
1212 (opReads_[cycle].size() == 1 &&
1213 !AssocTools::containsKey(opReads_[cycle], operand))) {
1214 return cycle;
1215 }
1216
1217 if (!resourceUsage_[cycle].empty()) {
1218 return cycle;
1219 }
1220
1221 int latency = this->latency();
1222 for (int i = cycle + 1; i < latency; i++) {
1223 if (!resourceUsage_[i].empty() || !opReads_[i].empty()) {
1224 return i;
1225 }
1226 }
1227
1228 return -1;
1229}

References AssocTools::containsKey(), firstCycle(), latency(), opReads_, and resourceUsage_.

Referenced by removeOperandUse().

Here is the call graph for this function:

◆ firstCycleWithoutResource() [1/2]

int TTAMachine::ExecutionPipeline::firstCycleWithoutResource ( const std::string &  resource) const
private

Returns the first cycle when a resource is used or port read by this pipeline if the given pipeline resource is not used.

Returns -1 if no resource is used or port read.

Parameters
resourceName of the pipeline resource.
Returns
The first cycle or -1.

Definition at line 1121 of file ExecutionPipeline.cc.

1122 {
1123
1124 PipelineElement* element = pipelineElement(resource);
1125 if (element == NULL) {
1126 return firstCycle();
1127 }
1128
1129 int latency = this->latency();
1130 for (int i = 0; i < latency; i++) {
1131 if (!opReads_[i].empty()) {
1132 return i;
1133 }
1134 if (resourceUsage_[i].size() > 1 ||
1135 (resourceUsage_[i].size() == 1 &&
1136 !AssocTools::containsKey(resourceUsage_[i], element))) {
1137 return i;
1138 }
1139 }
1140
1141 return -1;
1142}

References AssocTools::containsKey(), firstCycle(), latency(), opReads_, pipelineElement(), and resourceUsage_.

Referenced by removeResourceUse(), and removeResourceUse().

Here is the call graph for this function:

◆ firstCycleWithoutResource() [2/2]

int TTAMachine::ExecutionPipeline::firstCycleWithoutResource ( const std::string &  resource,
int  cycle 
) const
private

Returns the first cycle when a resource is used or port read if usage of the given resource is removed from the given cycle.

Returns -1 if no resource is used or port read.

Parameters
resourceName of the pipeline resource.
cycleThe cycle when the pipeline resource is not used.
Returns
The first cycle or -1.

Definition at line 1156 of file ExecutionPipeline.cc.

1158 {
1159
1160 int currentFirstCycle = firstCycle();
1161 if (currentFirstCycle != cycle) {
1162 return currentFirstCycle;
1163 }
1164
1165 PipelineElement* element = pipelineElement(resource);
1166 if (element == NULL) {
1167 return currentFirstCycle;
1168 }
1169
1170 if (!opReads_[cycle].empty()) {
1171 return cycle;
1172 }
1173 if (resourceUsage_[cycle].size() > 1 ||
1174 (resourceUsage_[cycle].size() == 1 &&
1175 !AssocTools::containsKey(resourceUsage_[cycle], element))) {
1176 return cycle;
1177 }
1178
1179 int latency = this->latency();
1180 for (int i = cycle + 1; i < latency; i++) {
1181 if (!opReads_[i].empty() || !resourceUsage_[i].empty()) {
1182 return i;
1183 }
1184 }
1185
1186 return -1;
1187}

References AssocTools::containsKey(), firstCycle(), latency(), opReads_, pipelineElement(), and resourceUsage_.

Here is the call graph for this function:

◆ internalAddPortUse()

void TTAMachine::ExecutionPipeline::internalAddPortUse ( int  operand,
int  start,
int  duration,
IOUsage toModify 
)
private

Internally adds use of the given operand.

Parameters
operandThe operand to add the usage for.
startThe start cycle of the operand usage.
durationDuration of the operand usage.
toModifyThe IOUsage to modify.

Definition at line 911 of file ExecutionPipeline.cc.

915 {
916
917 if (start + duration > latency()) {
918 adjustLatency(start + duration);
919 }
920
921 for (int cycle = start; cycle < start + duration; cycle++) {
922 toModify[cycle].insert(operand);
923 }
924}

References adjustLatency(), and latency().

Referenced by addPortRead(), and addPortWrite().

Here is the call graph for this function:

◆ internalAddResourceUse()

void TTAMachine::ExecutionPipeline::internalAddResourceUse ( const std::string &  name,
int  start,
int  duration 
)
private

Internally adds the resource usage of the given resource at the given time interval.

Parameters
nameName of the resource.
startThe start cycle.
durationThe duration of the usage.

Definition at line 884 of file ExecutionPipeline.cc.

887 {
888
889 PipelineElement* used = pipelineElement(name);
890 if (used == NULL) {
891 used = addPipelineElement(name);
892 }
893
894 adjustLatency(start + duration);
895
896 for (int cycle = start; cycle < start + duration; cycle++) {
897 resourceUsage_[cycle].insert(used);
898 }
899}
PipelineElement * addPipelineElement(const std::string &name) const

References addPipelineElement(), adjustLatency(), pipelineElement(), and resourceUsage_.

Referenced by addResourceUse().

Here is the call graph for this function:

◆ internalRemoveOperandUse()

void TTAMachine::ExecutionPipeline::internalRemoveOperandUse ( int  operand,
int  start,
int  duration 
)
private

Internally removes the operand usage of the given operand at the given time interval.

Parameters
operandThe operand.
startThe start cycle.
durationThe duration of the usage to be removed.

Definition at line 971 of file ExecutionPipeline.cc.

974 {
975
976 int end = start + duration - 1;
977 if (end >= latency()) {
978 end = latency() - 1;
979 }
980
981 for (int cycle = start; cycle <= end; cycle++) {
984 }
985
986 adjustLatency(0);
987}
static bool removeValueIfExists(ContainerType &aContainer, const ElementType &aKey)

References adjustLatency(), latency(), opReads_, opWrites_, and ContainerTools::removeValueIfExists().

Referenced by removeOperandUse().

Here is the call graph for this function:

◆ internalRemoveResourceUse()

void TTAMachine::ExecutionPipeline::internalRemoveResourceUse ( const std::string &  name,
int  start,
int  duration 
)
private

Internally removes the resource usage of the given resource at the given time interval.

Parameters
nameName of the resource.
startThe start cycle.
durationThe duration of the usage to be removed.

Definition at line 936 of file ExecutionPipeline.cc.

939 {
940
941 PipelineElement* toRemove = pipelineElement(name);
942 if (toRemove == NULL) {
943 return;
944 }
945
946 int end = start + duration - 1;
947 if (end >= latency()) {
948 end = latency() - 1;
949 }
950
951 for (int cycle = start; cycle <= end; cycle++) {
953 }
954
955 adjustLatency(0);
956
957 FunctionUnit* fu = parent_->parentUnit();
958 fu->cleanup(name);
959}
virtual void cleanup(const std::string &resource)

References adjustLatency(), TTAMachine::FunctionUnit::cleanup(), latency(), parent_, TTAMachine::HWOperation::parentUnit(), pipelineElement(), ContainerTools::removeValueIfExists(), and resourceUsage_.

Referenced by removeResourceUse(), and removeResourceUse().

Here is the call graph for this function:

◆ isArchitectureEqual()

bool TTAMachine::ExecutionPipeline::isArchitectureEqual ( const ExecutionPipeline pipeline) const

Compares two ExecutionPipeline architectures.

Parameters
pipelineExecutionPipeline to compare with.
Returns
True if the two ExecutionPipeline architectures are equal.

Definition at line 693 of file ExecutionPipeline.cc.

694 {
695
696 for (unsigned int i = 0; i < resourceUsage_.size(); i++) {
697 ResourceSet::const_iterator iter = resourceUsage_[i].begin();
698 for (; iter != resourceUsage_[i].end(); iter++) {
699 if (!pipeline->isResourceUsed((*iter)->name(), i)) {
700 return false;
701 }
702 }
703 }
704 if (readOperands() != pipeline->readOperands()) {
705 return false;
706 }
707 if (writtenOperands() != pipeline->writtenOperands()) {
708 return false;
709 }
710 return true;
711}

References isResourceUsed(), readOperands(), readOperands(), resourceUsage_, writtenOperands(), and writtenOperands().

Here is the call graph for this function:

◆ isOperandBound()

bool TTAMachine::ExecutionPipeline::isOperandBound ( const FUPort port,
const OperandSet operands 
) const
private

Checks whether the given port is bound to one of the operands in the given operand set.

Parameters
portThe port.
operandsThe operands.
Returns
True if at least one of the operands is bound to the given port, otherwise false.

Definition at line 1035 of file ExecutionPipeline.cc.

1037 {
1038
1039 for (OperandSet::const_iterator iter = operands.begin();
1040 iter != operands.end(); iter++) {
1041 if (parent_->port(*iter) == &port) {
1042 return true;
1043 }
1044 }
1045
1046 return false;
1047}
virtual FUPort * port(int operand) const

References parent_, and TTAMachine::HWOperation::port().

Referenced by isPortRead(), and isPortWritten().

Here is the call graph for this function:

◆ isOperandRead()

bool TTAMachine::ExecutionPipeline::isOperandRead ( int  operand) const
private

Checks whether the given operand is read by the pipeline.

Parameters
operandThe operand.
Returns
True if the operand is read, otherwise false.

Definition at line 1076 of file ExecutionPipeline.cc.

1076 {
1077 int latency = this->latency();
1078 for (int cycle = 0; cycle < latency; cycle++) {
1079 OperandSet cycleReads = opReads_[cycle];
1080 if (AssocTools::containsKey(cycleReads, operand)) {
1081 return true;
1082 }
1083 }
1084 return false;
1085}
std::set< int > OperandSet
Set for operand indexes.

References AssocTools::containsKey(), latency(), and opReads_.

Referenced by checkOutputOperand().

Here is the call graph for this function:

◆ isOperandWritten()

bool TTAMachine::ExecutionPipeline::isOperandWritten ( int  operand) const
private

Checks whether the given operand is written by the pipeline.

Parameters
operandThe operand.
Returns
True if the operand is written, otherwise false.

Definition at line 1057 of file ExecutionPipeline.cc.

1057 {
1058 int latency = this->latency();
1059 for (int cycle = 0; cycle < latency; cycle++) {
1060 OperandSet cycleWrites = opWrites_[cycle];
1061 if (AssocTools::containsKey(cycleWrites, operand)) {
1062 return true;
1063 }
1064 }
1065 return false;
1066}

References AssocTools::containsKey(), latency(), and opWrites_.

Referenced by checkInputOperand().

Here is the call graph for this function:

◆ isPortRead()

bool TTAMachine::ExecutionPipeline::isPortRead ( const FUPort port,
int  cycle 
) const

Checks whether the given port is read at the given cycle by the pipeline.

Parameters
portThe port.
cycleThe cycle.
Returns
True if the port is read, otherwise false.
Exceptions
OutOfRangeIf the given cycle is negative.

Definition at line 362 of file ExecutionPipeline.cc.

362 {
363 if (cycle < 0) {
364 const string procName = "ExecutionPipeline::isPortRead";
365 throw OutOfRange(__FILE__, __LINE__, procName);
366 }
367
368 if (cycle >= latency()) {
369 return false;
370 }
371
373 return (isOperandBound(port, readOperands));
374}
bool isOperandBound(const FUPort &port, const OperandSet &operands) const

References isOperandBound(), latency(), opReads_, and readOperands().

Referenced by MachineStateBuilder::addPortToFU(), FullyConnectedCheck::connectFUPort(), ExecutionPipelineResourceTable::ExecutionPipelineResourceTable(), isPortUsed(), AddFUFromHDBDialog::onAdd(), HDB::FUArchitecture::portDirection(), and FUPortImplementationDialog::TransferDataToWindow().

Here is the call graph for this function:

◆ isPortUsed()

bool TTAMachine::ExecutionPipeline::isPortUsed ( const FUPort port,
int  cycle 
) const

Checks whether the given port is used at the given cycle by the pipeline.

Parameters
portThe port.
cycleThe cycle.
Returns
True if the port is used, otherwise false.
Exceptions
OutOfRangeIf the given cycle is negative.

Definition at line 349 of file ExecutionPipeline.cc.

349 {
350 return isPortRead(port, cycle) || isPortWritten(port, cycle);
351}
bool isPortWritten(const FUPort &port, int cycle) const
bool isPortRead(const FUPort &port, int cycle) const

References isPortRead(), and isPortWritten().

Referenced by ReservationTable::ReservationTable().

Here is the call graph for this function:

◆ isPortWritten()

bool TTAMachine::ExecutionPipeline::isPortWritten ( const FUPort port,
int  cycle 
) const

Checks whether the given port is written at the given cycle by the pipeline.

Parameters
portThe port.
cycleThe cycle.
Returns
True if the port is written, otherwise false.
Exceptions
OutOfRangeIf the given cycle is negative.

Definition at line 386 of file ExecutionPipeline.cc.

386 {
387 if (cycle < 0) {
388 const string procName = "ExecutionPipeline::isPortRead";
389 throw OutOfRange(__FILE__, __LINE__, procName);
390 }
391
392 if (cycle >= latency()) {
393 return false;
394 }
395
397 return (isOperandBound(port, writtenOperands));
398}

References isOperandBound(), latency(), opWrites_, and writtenOperands().

Referenced by MachineStateBuilder::addPortToFU(), FullyConnectedCheck::connectFUPort(), ExecutionPipelineResourceTable::ExecutionPipelineResourceTable(), isPortUsed(), AddFUFromHDBDialog::onAdd(), HDB::FUArchitecture::portDirection(), and FUPortImplementationDialog::TransferDataToWindow().

Here is the call graph for this function:

◆ isResourceUsed()

bool TTAMachine::ExecutionPipeline::isResourceUsed ( const std::string &  name,
int  cycle 
) const

Tells whether a given pipeline element is used in the given cycle by this pipeline.

Parameters
nameName of the pipeline element.
cycleCycle in which element use is to be tested.
Returns
True if the element is in use in the given cycle.
Exceptions
OutOfRangeIf the given cycle is negative.

Definition at line 300 of file ExecutionPipeline.cc.

300 {
301 if (cycle < 0) {
302 const string procName = "ExecutionPipeline::isResourceUsed";
303 throw OutOfRange(__FILE__, __LINE__, procName);
304 }
305
306 if (latency() <= cycle) {
307 return false;
308 }
309
310 PipelineElement* resource = pipelineElement(name);
311 if (resource == NULL) {
312 return false;
313 }
314
316 return (AssocTools::containsKey(usedResources, resource));
317}
std::set< PipelineElement *, PipelineElement::Comparator > ResourceSet
Set for pipeline elements.

References AssocTools::containsKey(), latency(), pipelineElement(), resourceUsage_, and usedResources().

Referenced by HDB::HDBManager::addFUArchitecture(), TTAMachine::FunctionUnit::cleanup(), ExecutionPipelineResourceTable::ExecutionPipelineResourceTable(), HDBToHtml::fuArchToHtml(), isArchitectureEqual(), HDB::HDBManager::isMatchingArchitecture(), OperationDialog::onResourceLClick(), HDB::FUArchitecture::operator==(), ReservationTable::ReservationTable(), OperationDialog::updateResourceGrid(), and OperationDialog::warnOnResourcesWithoutUsages().

Here is the call graph for this function:

◆ latency() [1/2]

int TTAMachine::ExecutionPipeline::latency ( ) const

Returns the latency of the pipeline.

If the pipeline is totally empty, returns 0.

Returns
The latency of the pipeline.

Definition at line 482 of file ExecutionPipeline.cc.

482 {
483 assert(resourceUsage_.size() == opReads_.size());
484 assert(resourceUsage_.size() == opWrites_.size());
485 return resourceUsage_.size();
486}

References assert, opReads_, opWrites_, and resourceUsage_.

Referenced by HDB::HDBManager::addFUArchitecture(), MachineStateBuilder::addPortToFU(), adjustLatency(), checkOperandAvailability(), FUValidator::checkOperandBindings(), FUValidator::checkOperations(), checkResourceAvailability(), checkStartCycle(), TTAMachine::FunctionUnit::cleanup(), ExecutionPipelineResourceTable::ExecutionPipelineResourceTable(), firstCycle(), firstCycleWithoutOperandUse(), firstCycleWithoutResource(), firstCycleWithoutResource(), internalAddPortUse(), internalRemoveOperandUse(), internalRemoveResourceUse(), isOperandRead(), isOperandWritten(), isPortRead(), isPortWritten(), isResourceUsed(), TTAMachine::HWOperation::latency(), latency(), TTAMachine::HWOperation::latency(), OperationDialog::onDeleteOperand(), readOperands(), readOperands(), removeOperandUse(), removeResourceUse(), removeResourceUse(), resourceUsages(), TTAMachine::ResourceVector::ResourceVector(), OperationDialog::updateOperandList(), OperationDialog::updateResourceGrid(), OperationDialog::updateUsageGrid(), usedResources(), OperationDialog::warnOnResourcesWithoutUsages(), writtenOperands(), and writtenOperands().

◆ latency() [2/2]

int TTAMachine::ExecutionPipeline::latency ( int  output) const

Returns the latency for the given output.

Parameters
outputThe number of the output.
Returns
The latency for the given output.
Exceptions
IllegalParametersIf the given output is not written in the pipeline.

Definition at line 498 of file ExecutionPipeline.cc.

498 {
499 int cycle = latency();
500 for (IOUsage::const_reverse_iterator iter = opWrites_.rbegin();
501 iter != opWrites_.rend(); iter++) {
502 if (AssocTools::containsKey(*iter, output)) {
503 return cycle;
504 }
505 cycle--;
506 }
507
508 const string msg =
509 (boost::format("Latency for operand index %d was not found for "
510 "operation '%s' on unit '%s'!") % output % parent_->name()
511 % parent_->parentUnit()->name()).str();
512 throw IllegalParameters(__FILE__, __LINE__, __func__, msg);
513}
#define __func__
virtual TCEString name() const
const std::string & name() const

References __func__, AssocTools::containsKey(), latency(), TTAMachine::HWOperation::name(), TTAMachine::Component::name(), opWrites_, parent_, and TTAMachine::HWOperation::parentUnit().

Here is the call graph for this function:

◆ loadState()

void TTAMachine::ExecutionPipeline::loadState ( const ObjectState pipelineState)
virtual

Loads the state of pipeline from the given ObjectState tree.

Parameters
pipelineStateAn ObjectState tree representing state of a pipeline.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading state.

Implements Serializable.

Definition at line 611 of file ExecutionPipeline.cc.

611 {
612 const string procName = "ExecutionPipeline::loadState";
613
614 if (pipelineState->name() != OSNAME_PIPELINE) {
615 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
616 }
617
619 ObjectStateTable childTable = sortResourceUsages(pipelineState);
620 MOMTextGenerator textGen;
621
622 try {
623 for (ObjectStateTable::const_iterator iter = childTable.begin();
624 iter != childTable.end(); iter++) {
625 const ObjectState* usage = *iter;
626 int startCycle = usage->intAttribute(OSKEY_START_CYCLE);
627 int cycles = usage->intAttribute(OSKEY_CYCLES);
628 int operand = 0;
629 string resourceName;
630
631 try {
632
633 if (usage->name() == OSNAME_RESOURCE_USAGE) {
634 resourceName = usage->stringAttribute(
636 addResourceUse(resourceName, startCycle, cycles);
637 } else if (usage->name() == OSNAME_OPERAND_READ) {
638 operand = usage->intAttribute(OSKEY_OPERAND);
639 addPortRead(operand, startCycle, cycles);
640 } else if (usage->name() == OSNAME_OPERAND_WRITE) {
641 operand = usage->intAttribute(OSKEY_OPERAND);
642 addPortWrite(operand, startCycle, cycles);
643 } else {
645 __FILE__, __LINE__, procName);
646 }
647
648 } catch (const WrongOperandType&) {
649 format errorMsg = textGen.text(
651 errorMsg % operand % parent_->name() %
652 parent_->parentUnit()->name();
654 __FILE__, __LINE__, procName, errorMsg.str());
655
656 } catch (const InvalidName&) {
657 format errorMsg = textGen.text(
659 errorMsg % resourceName;
661 __FILE__, __LINE__, procName, errorMsg.str());
662
663 } catch (const StartTooLate&) {
664 format errorMsg = textGen.text(
666 errorMsg % parent_->name() % parent_->parentUnit()->name() %
667 startCycle;
669 __FILE__, __LINE__, procName, errorMsg.str());
670
671 } catch (const NotAvailable&) {
672 format errorMsg = textGen.text(
674 errorMsg % parent_->name() % parent_->parentUnit()->name();
676 __FILE__, __LINE__, errorMsg.str());
677 }
678 }
679
680 } catch (const Exception& exception) {
682 __FILE__, __LINE__, procName, exception.errorMessage());
683 }
684}
std::string stringAttribute(const std::string &name) const
std::string name() const
ObjectStateTable sortResourceUsages(const ObjectState *pipelineState) const
std::vector< const ObjectState * > ObjectStateTable
Vector for ObjectState pointers.
void addResourceUse(const std::string &name, int start, int duration)
static const std::string OSKEY_RESOURCE_NAME
ObjectState attribute key for name of resource.
static const std::string OSNAME_OPERAND_WRITE
ObjectState name for operand write.
void addPortRead(int operand, int start, int duration)
static const std::string OSKEY_OPERAND
ObjectState attribute key for operand number.
static const std::string OSNAME_OPERAND_READ
ObjectState name for operand read.
void addPortWrite(int operand, int start, int duration)
static const std::string OSNAME_PIPELINE
ObjectState name for ExecutionPipeline.
static const std::string OSNAME_RESOURCE_USAGE
ObjectState name for pipeline resource usage.
static const std::string OSKEY_CYCLES
ObjectState attribute key for duration of a resource usage.
virtual boost::format text(int textId)

References addPortRead(), addPortWrite(), addResourceUse(), Exception::errorMessage(), ObjectState::intAttribute(), TTAMachine::HWOperation::name(), TTAMachine::Component::name(), ObjectState::name(), OSKEY_CYCLES, OSKEY_OPERAND, OSKEY_RESOURCE_NAME, OSKEY_START_CYCLE, OSNAME_OPERAND_READ, OSNAME_OPERAND_WRITE, OSNAME_PIPELINE, OSNAME_RESOURCE_USAGE, parent_, TTAMachine::HWOperation::parentUnit(), removeAllResourceUses(), sortResourceUsages(), ObjectState::stringAttribute(), Texts::TextGenerator::text(), MOMTextGenerator::TXT_INVALID_NAME, MOMTextGenerator::TXT_PIPELINE_NOT_CANONICAL, MOMTextGenerator::TXT_PIPELINE_START_TOO_LATE, and MOMTextGenerator::TXT_PORT_READ_AND_WRITTEN_BY_PIPELINE.

Referenced by TTAMachine::HWOperation::loadState().

Here is the call graph for this function:

◆ parentOperation()

const HWOperation * TTAMachine::ExecutionPipeline::parentOperation ( ) const

Returns the parent HWOperation.

Returns
The parent.

Definition at line 89 of file ExecutionPipeline.cc.

89 {
90 return parent_;
91}

References parent_.

Referenced by ExecutionPipeline(), and TTAMachine::ResourceVector::ResourceVector().

◆ pipelineElement()

PipelineElement * TTAMachine::ExecutionPipeline::pipelineElement ( const std::string &  name) const
private

Returns the pipeline element by the given name.

Parameters
nameThe name.
Returns
The pipeline element or NULL if there is no such pipeline element.

Definition at line 1259 of file ExecutionPipeline.cc.

1259 {
1260 FunctionUnit* fu = parent_->parentUnit();
1261 return fu->pipelineElement(name);
1262}
virtual PipelineElement * pipelineElement(int index) const

References parent_, TTAMachine::HWOperation::parentUnit(), and TTAMachine::FunctionUnit::pipelineElement().

Referenced by checkResourceAvailability(), firstCycleWithoutResource(), firstCycleWithoutResource(), internalAddResourceUse(), internalRemoveResourceUse(), isResourceUsed(), and removeResourceUse().

Here is the call graph for this function:

◆ readOperands() [1/2]

ExecutionPipeline::OperandSet TTAMachine::ExecutionPipeline::readOperands ( ) const

Returns a set of operands that are read by this pipeline.

Returns
The operand set.

Definition at line 448 of file ExecutionPipeline.cc.

448 {
449 OperandSet operands;
450 for (int i = 0; i < latency(); i++) {
451 OperandSet cycleOperands = readOperands(i);
452 operands.insert(cycleOperands.begin(), cycleOperands.end());
453 }
454 return operands;
455}

References latency(), and readOperands().

Referenced by isArchitectureEqual(), isPortRead(), and readOperands().

Here is the call graph for this function:

◆ readOperands() [2/2]

ExecutionPipeline::OperandSet TTAMachine::ExecutionPipeline::readOperands ( int  cycle) const

Returns the operands that are read at the given cycle.

Parameters
cycleThe cycle.
Returns
Set of operand indexes.
Exceptions
OutOfRangeIf the cycle is smaller than 0.

Definition at line 408 of file ExecutionPipeline.cc.

408 {
409 if (cycle < 0) {
410 const string procName = "ExecutionPipeline::readOperands";
411 throw OutOfRange(__FILE__, __LINE__, procName);
412 }
413
414 if (cycle >= latency()) {
415 return OperandSet();
416 }
417
418 return opReads_[cycle];
419}

References latency(), and opReads_.

Referenced by HDB::HDBManager::addFUArchitecture(), OperationBindingCheck::check(), FUValidator::checkOperandBindings(), FUValidator::checkOperations(), ADFCombiner::connectVectorLSU(), llvm::LLVMTCEBuilder::emitOperationMacro(), HDBToHtml::fuArchToHtml(), isArchitectureEqual(), HDB::HDBManager::isMatchingArchitecture(), OperationDialog::onDeleteOperand(), OperationDialog::onOperandLClick(), HDB::FUArchitecture::operator==(), TTAMachine::ResourceVector::ResourceVector(), OperationDialog::updateOperandList(), and OperationDialog::updateUsageGrid().

Here is the call graph for this function:

◆ removeAllResourceUses()

void TTAMachine::ExecutionPipeline::removeAllResourceUses ( )

Removes the all the usages of resources.

Definition at line 243 of file ExecutionPipeline.cc.

243 {
244
246
247 resourceUsage_.clear();
248 opWrites_.clear();
249 opReads_.clear();
250
251 FunctionUnit* parent = parent_->parentUnit();
252
253 // clean up pipeline elements
254 for (ResourceSet::const_iterator iter = usedResources.begin();
255 iter != usedResources.end(); iter++) {
256 parent->cleanup((*iter)->name());
257 }
258}

References TTAMachine::FunctionUnit::cleanup(), opReads_, opWrites_, parent_, TTAMachine::HWOperation::parentUnit(), resourceUsage_, and usedResources().

Referenced by loadState(), and ~ExecutionPipeline().

Here is the call graph for this function:

◆ removeOperandUse()

void TTAMachine::ExecutionPipeline::removeOperandUse ( int  operand,
int  cycle 
)

Removes reads and writes of the given operand at the given cycle.

Parameters
operandThe operand.
cycleThe cycle.
Exceptions
OutOfRangeIf the given cycle is less than 0 or the given operand is smaller than 1.
StartTooLateIf the pipeline does not start by resource usage or operand read at cycle 0 or 1.

Definition at line 272 of file ExecutionPipeline.cc.

272 {
273 const string procName = "ExecutionPipeline::removeOperandUse";
274
275 if (cycle < 0 || operand < 1) {
276 throw OutOfRange(__FILE__, __LINE__, procName);
277 }
278
279 if (latency() <= cycle) {
280 return;
281 }
282
283 if (firstCycleWithoutOperandUse(operand, cycle) > 1) {
284 throw StartTooLate(__FILE__, __LINE__, procName);
285 }
286
287 internalRemoveOperandUse(operand, cycle, 1);
288}
void internalRemoveOperandUse(int operand, int start, int duration)
int firstCycleWithoutOperandUse(int operand, int cycle) const

References firstCycleWithoutOperandUse(), internalRemoveOperandUse(), and latency().

Referenced by OperationDialog::onDeleteOperand(), and OperationDialog::onOperandLClick().

Here is the call graph for this function:

◆ removeResourceUse() [1/2]

void TTAMachine::ExecutionPipeline::removeResourceUse ( const std::string &  name)

Removes any usage of given pipeline element in the pipeline.

Parameters
nameName of the pipeline element.
Exceptions
StartTooLateIf the pipeline does not start by resource usage or operand read at cycle 0 or 1.

Definition at line 189 of file ExecutionPipeline.cc.

189 {
190 const string procName = "ExecutionPipeline::removeResourceUse";
191
192 FunctionUnit* fu = parent_->parentUnit();
193 if (!fu->hasPipelineElement(name)) {
194 return;
195 }
196
197 if (firstCycleWithoutResource(name) > 1) {
198 throw StartTooLate(__FILE__, __LINE__, procName);
199 }
200
202}
void internalRemoveResourceUse(const std::string &name, int start, int duration)
int firstCycleWithoutResource(const std::string &resource) const

References firstCycleWithoutResource(), TTAMachine::FunctionUnit::hasPipelineElement(), internalRemoveResourceUse(), latency(), parent_, and TTAMachine::HWOperation::parentUnit().

Referenced by OperationDialog::onDeleteResource(), OperationDialog::onResourceLClick(), and TTAMachine::PipelineElement::~PipelineElement().

Here is the call graph for this function:

◆ removeResourceUse() [2/2]

void TTAMachine::ExecutionPipeline::removeResourceUse ( const std::string &  name,
int  cycle 
)

Removes any usage of given pipeline element in given cycle from the pipeline.

Parameters
nameName of the pipeline element.
cycleCycle in which element use is to be removed.
Exceptions
OutOfRangeIf the given cycle is negative.
StartTooLateIf the pipeline does not start by resource usage or operand read at cycle 0 or 1.

Definition at line 215 of file ExecutionPipeline.cc.

215 {
216 const string procName = "ExecutionPipeline::removeResourceUse";
217
218 if (pipelineElement(name) == NULL) {
219 return;
220 }
221
222 if (cycle < 0) {
223 throw OutOfRange(__FILE__, __LINE__, procName);
224 }
225
226 if (latency() <= cycle) {
227 return;
228 }
229
230 if (cycle == 0 || cycle == 1) {
231 if (firstCycleWithoutResource(name, cycle) > 1) {
232 throw StartTooLate(__FILE__, __LINE__, procName);
233 }
234 }
235
236 internalRemoveResourceUse(name, cycle, 1);
237}

References firstCycleWithoutResource(), internalRemoveResourceUse(), latency(), and pipelineElement().

Here is the call graph for this function:

◆ resourceUsages()

ExecutionPipeline::ResourceSet TTAMachine::ExecutionPipeline::resourceUsages ( int  cycle) const

Returns the resource usages in the given cycle.

Parameters
cycleCycle of which resource usages to return.
Returns
True if the element is in use in the given cycle.
Exceptions
OutOfRangeIf the given cycle is negative.

Definition at line 327 of file ExecutionPipeline.cc.

327 {
328 if (cycle < 0) {
329 const string procName = "ExecutionPipeline::isResourceUsed";
330 throw OutOfRange(__FILE__, __LINE__, procName);
331 }
332
333 if (latency() <= cycle) {
334 return ResourceSet();
335 }
336
337 return resourceUsage_[cycle];
338}

References latency(), and resourceUsage_.

Referenced by TTAMachine::ResourceVector::ResourceVector().

Here is the call graph for this function:

◆ saveOperandUse()

void TTAMachine::ExecutionPipeline::saveOperandUse ( int  operand,
int  cycleToSave,
ObjectState pipelineState,
const std::string &  osName 
)
staticprivate

Saves use of an operand to ObjectState tree.

Parameters
operandThe operand.
cycleToSaveThe cycle to save.
pipelineStateObjectState instance representing the state of the pipeline.
osNameName of the ObjectState instance in which to save the operand use.

Definition at line 1334 of file ExecutionPipeline.cc.

1338 {
1339
1340 bool found = false;
1341
1342 for (int i = 0; i < pipelineState->childCount(); i++) {
1343 ObjectState* child = pipelineState->child(i);
1344 if (child->name() == osName &&
1345 child->intAttribute(OSKEY_OPERAND) == operand) {
1346
1347 int cycles = child->intAttribute(OSKEY_CYCLES);
1348 if (child->intAttribute(OSKEY_START_CYCLE) + cycles ==
1349 cycleToSave) {
1350 child->setAttribute(OSKEY_CYCLES, cycles + 1);
1351 found = true;
1352 break;
1353 }
1354 }
1355 }
1356
1357 if (!found) {
1358 ObjectState* operandUsage = new ObjectState(osName);
1359 pipelineState->addChild(operandUsage);
1360 operandUsage->setAttribute(OSKEY_OPERAND, operand);
1361 operandUsage->setAttribute(OSKEY_START_CYCLE, cycleToSave);
1362 operandUsage->setAttribute(OSKEY_CYCLES, 1);
1363 }
1364}
void setAttribute(const std::string &name, const std::string &value)
ObjectState * child(int index) const
void addChild(ObjectState *child)
int childCount() const

References ObjectState::addChild(), ObjectState::child(), ObjectState::childCount(), ObjectState::intAttribute(), ObjectState::name(), OSKEY_CYCLES, OSKEY_OPERAND, OSKEY_START_CYCLE, and ObjectState::setAttribute().

Referenced by saveState().

Here is the call graph for this function:

◆ saveResourceUse()

void TTAMachine::ExecutionPipeline::saveResourceUse ( const PipelineElement element,
int  cycleToSave,
ObjectState pipelineState 
)
staticprivate

Saves usage of a pipeline element to ObjectState tree.

Parameters
elementThe pipelineElement used.
cycleToSaveThe cycle to save.
pipelineStateObjectState instance representing the state of the pipeline.

Definition at line 1290 of file ExecutionPipeline.cc.

1293 {
1294
1295 string elementName = element->name();
1296 bool resourceFound = false;
1297
1298 for (int i = 0; i < pipelineState->childCount(); i++) {
1299 ObjectState* child = pipelineState->child(i);
1300 if (child->name() == OSNAME_RESOURCE_USAGE &&
1301 child->stringAttribute(OSKEY_RESOURCE_NAME) == elementName) {
1302
1303 int cycles = child->intAttribute(OSKEY_CYCLES);
1304 if (child->intAttribute(OSKEY_START_CYCLE) + cycles ==
1305 cycleToSave) {
1306 child->setAttribute(OSKEY_CYCLES, cycles + 1);
1307 resourceFound = true;
1308 break;
1309 }
1310 }
1311 }
1312
1313 if (!resourceFound) {
1315 pipelineState->addChild(resource);
1316 resource->setAttribute(OSKEY_RESOURCE_NAME, elementName);
1317 resource->setAttribute(OSKEY_START_CYCLE, cycleToSave);
1318 resource->setAttribute(OSKEY_CYCLES, 1);
1319 }
1320}

References ObjectState::addChild(), ObjectState::child(), ObjectState::childCount(), ObjectState::intAttribute(), TTAMachine::PipelineElement::name(), ObjectState::name(), OSKEY_CYCLES, OSKEY_RESOURCE_NAME, OSKEY_START_CYCLE, OSNAME_RESOURCE_USAGE, ObjectState::setAttribute(), and ObjectState::stringAttribute().

Referenced by saveState().

Here is the call graph for this function:

◆ saveState()

ObjectState * TTAMachine::ExecutionPipeline::saveState ( ) const
virtual

Saves the pipeline to ObjectState tree.

Returns
The newly created ObjectState tree.

Implements Serializable.

Definition at line 551 of file ExecutionPipeline.cc.

551 {
552
553 ObjectState* pipelineState = new ObjectState(OSNAME_PIPELINE);
554
555 // save resources usages in different ObjectState instances
556 int cycle = 0;
557 for (ResourceUsage::const_iterator resUsageIter = resourceUsage_.begin();
558 resUsageIter != resourceUsage_.end(); resUsageIter++) {
559
560 ResourceSet cycleUsage = *resUsageIter;
561 for (ResourceSet::const_iterator cycleUsageIter = cycleUsage.begin();
562 cycleUsageIter != cycleUsage.end(); cycleUsageIter++) {
563 PipelineElement* element = *cycleUsageIter;
564 saveResourceUse(element, cycle, pipelineState);
565 }
566 cycle++;
567 }
568
569 // save operand reads in different ObjectState instances
570 cycle = 0;
571 for (IOUsage::const_iterator readsIter = opReads_.begin();
572 readsIter != opReads_.end(); readsIter++) {
573
574 OperandSet operands = *readsIter;
575 for (OperandSet::const_iterator opIter = operands.begin();
576 opIter != operands.end(); opIter++) {
577 int operand = *opIter;
579 operand, cycle, pipelineState, OSNAME_OPERAND_READ);
580 }
581 cycle++;
582 }
583
584 // save operand writes in different ObjectState instances
585 cycle = 0;
586 for (IOUsage::const_iterator writesIter = opWrites_.begin();
587 writesIter != opWrites_.end(); writesIter++) {
588
589 OperandSet operands = *writesIter;
590 for (OperandSet::const_iterator opIter = operands.begin();
591 opIter != operands.end(); opIter++) {
592 int operand = *opIter;
594 operand, cycle, pipelineState, OSNAME_OPERAND_WRITE);
595 }
596 cycle++;
597 }
598
599 return pipelineState;
600}
static void saveOperandUse(int operand, int cycleToSave, ObjectState *pipelineState, const std::string &osName)
static void saveResourceUse(const PipelineElement *element, int cycleToSave, ObjectState *pipelineState)

References opReads_, opWrites_, OSNAME_OPERAND_READ, OSNAME_OPERAND_WRITE, OSNAME_PIPELINE, resourceUsage_, saveOperandUse(), and saveResourceUse().

Referenced by TTAMachine::HWOperation::saveState().

Here is the call graph for this function:

◆ slack()

int TTAMachine::ExecutionPipeline::slack ( int  input) const

Returns the slack of the given input.

The slack tells how many cycles AFTER the trigger, opcode-setting move is scheduled, can the operand be scheduled (and still affect correctly the result of the operation).

Parameters
inputThe number of the input.
Returns
The slack of the given input.
Exceptions
IllegalParametersIf the given input is not read in the pipeline.

Definition at line 528 of file ExecutionPipeline.cc.

528 {
529 int slack(0);
530 for (IOUsage::const_iterator iter = opReads_.begin();
531 iter != opReads_.end(); iter++) {
532 if (AssocTools::containsKey(*iter, input)) {
533 return slack;
534 }
535 slack++;
536 }
537
538 const string errMessage = "Propably broken operand binding in operation:"
539 + parent_->name() + " in FU: " + parent_->parentUnit()->name();
540
541 const string procName = "ExecutionPipeline::slack";
542 throw IllegalParameters(__FILE__, __LINE__, procName, errMessage);
543}

References AssocTools::containsKey(), TTAMachine::HWOperation::name(), TTAMachine::Component::name(), opReads_, parent_, TTAMachine::HWOperation::parentUnit(), and slack().

Referenced by slack(), and TTAMachine::HWOperation::slack().

Here is the call graph for this function:

◆ sortResourceUsages()

ExecutionPipeline::ObjectStateTable TTAMachine::ExecutionPipeline::sortResourceUsages ( const ObjectState pipelineState) const
private

Sorts the resource and operand usages by the start cycle of the usage.

Parameters
pipelineStateAn ObjectState instance representing an execution pipeline.
Returns
A vector of ObjectState instances each of them representing a resource or operand usage.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState instance is invalid.

Definition at line 1378 of file ExecutionPipeline.cc.

1378 {
1379 ObjectStateTable usages;
1380 for (int i = 0; i < pipelineState->childCount(); i++) {
1381 ObjectState* usageState = pipelineState->child(i);
1382 addResourceUsage(usages, usageState);
1383 }
1384
1385 return usages;
1386}
void addResourceUsage(ObjectStateTable &usages, const ObjectState *usageState) const

References addResourceUsage(), ObjectState::child(), and ObjectState::childCount().

Referenced by loadState().

Here is the call graph for this function:

◆ usedResources()

ExecutionPipeline::ResourceSet TTAMachine::ExecutionPipeline::usedResources ( ) const
private

Returns the pipeline resources used by this pipeline.

Returns
The pipeline resources used by this pipeline.

Definition at line 1238 of file ExecutionPipeline.cc.

1238 {
1239
1240 ResourceSet resources;
1241 int latency = this->latency();
1242
1243 for (int cycle = 0; cycle < latency; cycle++) {
1244 ResourceSet cycleResources = resourceUsage_[cycle];
1245 resources.insert(cycleResources.begin(), cycleResources.end());
1246 }
1247
1248 return resources;
1249}

References latency(), and resourceUsage_.

Referenced by isResourceUsed(), and removeAllResourceUses().

Here is the call graph for this function:

◆ writtenOperands() [1/2]

ExecutionPipeline::OperandSet TTAMachine::ExecutionPipeline::writtenOperands ( ) const

Returns a set of operands that are written by this pipeline.

Returns
The operand set.

Definition at line 464 of file ExecutionPipeline.cc.

464 {
465 OperandSet operands;
466 for (int i = 0; i < latency(); i++) {
467 OperandSet cycleOperands = writtenOperands(i);
468 operands.insert(cycleOperands.begin(), cycleOperands.end());
469 }
470 return operands;
471}

References latency(), and writtenOperands().

Referenced by isArchitectureEqual(), isPortWritten(), and writtenOperands().

Here is the call graph for this function:

◆ writtenOperands() [2/2]

ExecutionPipeline::OperandSet TTAMachine::ExecutionPipeline::writtenOperands ( int  cycle) const

Returns the operands that are written at the given cycle.

Parameters
cycleThe cycle.
Returns
Set of operand indexes.
Exceptions
OutOfRangeIf the given cycle is smaller than 0.

Definition at line 429 of file ExecutionPipeline.cc.

429 {
430 if (cycle < 0) {
431 const string procName = "ExecutionPipeline::readOperands";
432 throw OutOfRange(__FILE__, __LINE__, procName);
433 }
434
435 if (cycle >= latency()) {
436 return OperandSet();
437 }
438
439 return opWrites_[cycle];
440}

References latency(), and opWrites_.

Referenced by HDB::HDBManager::addFUArchitecture(), OperationBindingCheck::check(), FUValidator::checkOperandBindings(), ADFCombiner::connectVectorLSU(), llvm::LLVMTCEBuilder::emitOperationMacro(), ExecutionPipelineResourceTable::ExecutionPipelineResourceTable(), HDBToHtml::fuArchToHtml(), isArchitectureEqual(), HDB::HDBManager::isMatchingArchitecture(), OperationDialog::onDeleteOperand(), OperationDialog::onOperandLClick(), HDB::FUArchitecture::operator==(), TTAMachine::ResourceVector::ResourceVector(), OperationDialog::updateOperandList(), and OperationDialog::updateUsageGrid().

Here is the call graph for this function:

Member Data Documentation

◆ opReads_

IOUsage TTAMachine::ExecutionPipeline::opReads_
private

◆ opWrites_

IOUsage TTAMachine::ExecutionPipeline::opWrites_
private

◆ OSKEY_CYCLES

const string TTAMachine::ExecutionPipeline::OSKEY_CYCLES = "cycles"
static

ObjectState attribute key for duration of a resource usage.

Definition at line 111 of file ExecutionPipeline.hh.

Referenced by loadState(), ADFSerializer::machinePipeline(), ADFSerializer::mdfPipeline(), saveOperandUse(), and saveResourceUse().

◆ OSKEY_OPERAND

const string TTAMachine::ExecutionPipeline::OSKEY_OPERAND = "operand"
static

ObjectState attribute key for operand number.

Definition at line 107 of file ExecutionPipeline.hh.

Referenced by loadState(), ADFSerializer::machinePipeline(), ADFSerializer::mdfPipeline(), and saveOperandUse().

◆ OSKEY_RESOURCE_NAME

const string TTAMachine::ExecutionPipeline::OSKEY_RESOURCE_NAME = "res_name"
static

ObjectState attribute key for name of resource.

Definition at line 105 of file ExecutionPipeline.hh.

Referenced by loadState(), ADFSerializer::machinePipeline(), ADFSerializer::mdfPipeline(), and saveResourceUse().

◆ OSKEY_START_CYCLE

const string TTAMachine::ExecutionPipeline::OSKEY_START_CYCLE = "start_cycle"
static

ObjectState attribute key for start cycle of a resource usage.

Definition at line 109 of file ExecutionPipeline.hh.

Referenced by addResourceUsage(), loadState(), ADFSerializer::machinePipeline(), ADFSerializer::mdfPipeline(), saveOperandUse(), and saveResourceUse().

◆ OSNAME_OPERAND_READ

const string TTAMachine::ExecutionPipeline::OSNAME_OPERAND_READ = "op_read"
static

ObjectState name for operand read.

Definition at line 101 of file ExecutionPipeline.hh.

Referenced by loadState(), ADFSerializer::machinePipeline(), ADFSerializer::mdfPipeline(), and saveState().

◆ OSNAME_OPERAND_WRITE

const string TTAMachine::ExecutionPipeline::OSNAME_OPERAND_WRITE = "op_write"
static

ObjectState name for operand write.

Definition at line 103 of file ExecutionPipeline.hh.

Referenced by loadState(), ADFSerializer::machinePipeline(), ADFSerializer::mdfPipeline(), and saveState().

◆ OSNAME_PIPELINE

const string TTAMachine::ExecutionPipeline::OSNAME_PIPELINE = "pipeline"
static

◆ OSNAME_RESOURCE_USAGE

const string TTAMachine::ExecutionPipeline::OSNAME_RESOURCE_USAGE = "resource_usage"
static

ObjectState name for pipeline resource usage.

Definition at line 99 of file ExecutionPipeline.hh.

Referenced by loadState(), ADFSerializer::machinePipeline(), ADFSerializer::mdfPipeline(), and saveResourceUse().

◆ parent_

HWOperation* TTAMachine::ExecutionPipeline::parent_
private

◆ resourceUsage_

ResourceUsage TTAMachine::ExecutionPipeline::resourceUsage_
private

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