OpenASIP  2.0
DCMFUResourceConflictDetector.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file DCMFUResourceConflictDetector.cc
26  *
27  * Definition of DCMFUResourceConflictDetector class.
28  *
29  * @author Pekka Jääskeläinen 2007 (pjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
34 #include "StringTools.hh"
35 #include "FunctionUnit.hh"
36 #include "HWOperation.hh"
39 #include "TCEString.hh"
40 
41 /**
42  * Constructor.
43  *
44  * @param fu The function unit to detect conflicts for.
45  * @exception InvalidData If the model could not be built from the given FU.
46  */
48  const TTAMachine::FunctionUnit& fu)
49  : collisionMatrices_(fu),
50  globalCollisionMatrix_(
51  collisionMatrices_.at(0).columnCount(),
52  collisionMatrices_.at(0).rowCount(), false),
53  fu_(fu) {}
54 
55 /**
56  * Destructor.
57  */
60 }
61 
62 /**
63  * Issues an operation and reports a conflict if detected.
64  *
65  * @param id The id of the operation to issue.
66  * @return False in case a conflict is detected, otherwise true.
67  */
68 bool
70  return issueOperationInline(id);
71 }
72 
73 /**
74  * Simulates a cycle advance and reports a conflict if detected.
75  *
76  * @return False in case a conflict is detected, otherwise true.
77  */
78 bool
80  return advanceCycleInline();
81 }
82 
83 /**
84  * Returns an operation id for the given operation.
85  *
86  * Operation IDs are used in the interface for optimizing the access. This
87  * method converts OSAL Operations to operation IDs.
88  *
89  * @param operation The OSAL Operation to find ID for.
90  * @return The operation ID.
91  */
94  const TCEString& operationName) const {
95 
96  // find the index of the operation in the FU, it corresponds to the
97  // operation ID
98  for (int i = 0; i < fu_.operationCount(); ++i) {
99  if (StringTools::ciEqual(fu_.operation(i)->name(), operationName)) {
100  return i;
101  }
102  }
103  throw KeyNotFound(__FILE__, __LINE__, __func__, "Operation not found.");
104 }
105 
106 /**
107  * Sets the state of the detector to its initial state.
108  *
109  * This means that the FU state is assumed to be what it is in powerup.
110  */
111 void
114 }
DCMFUResourceConflictDetector::reset
virtual void reset()
Definition: DCMFUResourceConflictDetector.cc:112
DCMFUResourceConflictDetector.hh
DCMFUResourceConflictDetector::globalCollisionMatrix_
CollisionMatrix globalCollisionMatrix_
The global collision matrix.
Definition: DCMFUResourceConflictDetector.hh:74
BitMatrix::setAllToZero
void setAllToZero()
Definition: BitMatrix.cc:93
FUResourceConflictDetector::OperationID
int OperationID
Type for identifying operations in the conflict detector interface.
Definition: FUResourceConflictDetector.hh:49
TCEString.hh
StringTools.hh
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
HWOperation.hh
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
DCMFUResourceConflictDetector::issueOperationInline
bool issueOperationInline(OperationID id)
DCMFUResourceConflictDetector::~DCMFUResourceConflictDetector
virtual ~DCMFUResourceConflictDetector()
Definition: DCMFUResourceConflictDetector.cc:59
DCMFUResourceConflictDetector::advanceCycleInline
bool advanceCycleInline()
__func__
#define __func__
Definition: Application.hh:67
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
DCMFUResourceConflictDetector::DCMFUResourceConflictDetector
DCMFUResourceConflictDetector(const TTAMachine::FunctionUnit &fu)
Definition: DCMFUResourceConflictDetector.cc:47
StringTools::ciEqual
static bool ciEqual(const std::string &a, const std::string &b)
Definition: StringTools.cc:240
DCMFUResourceConflictDetector::advanceCycle
virtual bool advanceCycle()
Definition: DCMFUResourceConflictDetector.cc:79
DCMFUResourceConflictDetector::issueOperation
virtual bool issueOperation(OperationID id)
Definition: DCMFUResourceConflictDetector.cc:69
FUReservationTableIndex.hh
false
find Finds info of the inner loops in the false
Definition: InnerLoopFinder.cc:81
DCMFUResourceConflictDetector::fu_
const TTAMachine::FunctionUnit & fu_
The modeled FU.
Definition: DCMFUResourceConflictDetector.hh:76
TCEString
Definition: TCEString.hh:53
FUCollisionMatrixIndex.hh
KeyNotFound
Definition: Exception.hh:285
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
DCMFUResourceConflictDetector::operationID
virtual OperationID operationID(const TCEString &operationName) const
Definition: DCMFUResourceConflictDetector.cc:93
FunctionUnit.hh