OpenASIP  2.0
FUResourceConflictDetector.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 FUResourceConflictDetector.cc
26  *
27  * Definition of FUResourceConflictDetector class.
28  *
29  * @author Pekka Jääskeläinen 2006 (pjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
34 #include "StringTools.hh"
35 #include "OperationIDIndex.hh"
36 #include "TCEString.hh"
37 #include "Exception.hh"
38 
39 /**
40  * Constructor.
41  */
43  operationIndices_(new OperationIDIndex()) {
44  reset();
45 }
46 
47 /**
48  * Destructor.
49  */
51  delete operationIndices_;
52  operationIndices_ = NULL;
53 }
54 
55 /**
56  * Issues an operation and reports a conflict if detected.
57  *
58  * The default implementation always returns true, thus detects no conflicts.
59  *
60  * @param id The id of the operation to issue.
61  * @return False in case a conflict is detected, otherwise true.
62  */
63 bool
65  return true;
66 }
67 
68 /**
69  * Simulates a cycle advance and reports a conflict if detected.
70  *
71  * The default implementation always returns true, thus detects no conflicts.
72  * This interface is provided for allowing the model to update its state at
73  * the point simulation advances to the next cycle.
74  *
75  * @return False in case a conflict is detected, otherwise true.
76  */
77 bool
79  return true;
80 }
81 
82 /**
83  * Simulates a cycle advance and reports a conflict by throwing an exception.
84  */
85 void
87  advanceCycle();
88 }
89 
90 
91 /**
92  * Called after advanceClock() has been called to all clocked states.
93  */
94 void
96 }
97 
98 /**
99  * Should return true in case the model needs to receive clock advance calls.
100  *
101  * @return By default always returns false.
102  */
103 bool
105  return false;
106 }
107 
108 /**
109  * Returns an operation id for the given operation.
110  *
111  * Operation IDs are used in the interface for optimizing the access. This
112  * method converts OSAL Operations to operation IDs.
113  *
114  * @param operation The OSAL Operation to find ID for.
115  * @return The operation ID.
116  * @exception KeyNotFound if the operation of given name couldn't be found
117  */
120 {
121  OperationIDIndex::const_iterator i =
122  operationIndices_->find(StringTools::stringToLower(operationName));
123  if (i == operationIndices_->end())
124  throw KeyNotFound(
125  __FILE__, __LINE__, __func__, "Operation not found.");
126  return (*i).second;
127 }
128 
129 /**
130  * Sets the state of the detector to its initial state.
131  *
132  * This means that the FU state is assumed to be what it is in powerup.
133  */
134 void
136 }
FUResourceConflictDetector::isIdle
virtual bool isIdle()
Definition: FUResourceConflictDetector.cc:104
FUResourceConflictDetector::~FUResourceConflictDetector
virtual ~FUResourceConflictDetector()
Definition: FUResourceConflictDetector.cc:50
Exception.hh
FUResourceConflictDetector.hh
FUResourceConflictDetector::endClock
virtual void endClock()
Definition: FUResourceConflictDetector.cc:95
FUResourceConflictDetector::OperationID
int OperationID
Type for identifying operations in the conflict detector interface.
Definition: FUResourceConflictDetector.hh:49
FUResourceConflictDetector::advanceCycle
virtual bool advanceCycle()
Definition: FUResourceConflictDetector.cc:78
TCEString.hh
StringTools.hh
__func__
#define __func__
Definition: Application.hh:67
FUResourceConflictDetector::FUResourceConflictDetector
FUResourceConflictDetector()
Definition: FUResourceConflictDetector.cc:42
FUResourceConflictDetector::issueOperation
virtual bool issueOperation(OperationID id)
Definition: FUResourceConflictDetector.cc:64
FUResourceConflictDetector::operationID
virtual OperationID operationID(const TCEString &operationName) const
Definition: FUResourceConflictDetector.cc:119
TCEString
Definition: TCEString.hh:53
FUResourceConflictDetector::advanceClock
virtual void advanceClock()
Definition: FUResourceConflictDetector.cc:86
OperationIDIndex.hh
KeyNotFound
Definition: Exception.hh:285
FUResourceConflictDetector::operationIndices_
OperationIDIndex * operationIndices_
Map for finding indices for operations quickly.
Definition: FUResourceConflictDetector.hh:68
OperationIDIndex
Definition: OperationIDIndex.hh:41
StringTools::stringToLower
static std::string stringToLower(const std::string &source)
Definition: StringTools.cc:160
FUResourceConflictDetector::reset
virtual void reset()
Definition: FUResourceConflictDetector.cc:135