OpenASIP  2.0
ConflictDetectingOperationExecutor.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 ConflictDetectingOperationExecutor.cc
26  *
27  * Definition of ConflictDetectingOperationExecutor class.
28  *
29  * @author Pekka Jääskeläinen 2006 (pjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <boost/format.hpp>
34 
36 #include "Exception.hh"
37 #include "Operation.hh"
38 #include "TCEString.hh"
39 
40 using std::vector;
41 using std::string;
42 
43 /**
44  * Constructor.
45  *
46  * @param detector The conflict detector.
47  * @param operationID The conflict detector ID of the operation executed by
48  * this operation executor.
49  * @param parent Parent of the OperationExecutor.
50  * @param throwWhenConflict In case an exception should be thrown in case of
51  * a resource conflict (otherwise the conflicts are only counted).
52  */
56  FUState& parent,
58  bool throwWhenConflict) :
59  MultiLatencyOperationExecutor(parent, hwOp), detector_(detector),
60  operationID_(operationID), throwWhenConflict_(throwWhenConflict),
61  conflictCounter_(0) {
62 }
63 
64 /**
65  * Destructor.
66  */
68 #if 0
69  if (conflictCounter_ > 0)
70  std::cout << " (" << conflictCounter_ << " conflicts) ";
71 #endif
72 }
73 
74 /**
75  * Starts new operation.
76  *
77  * Checks for resource conflicts before actually simulating the operation
78  * using the parent class implementation.
79  *
80  * @param op Operation to be triggered.
81  */
82 void
84 
89  __FILE__, __LINE__, __func__,
90  (boost::format(
91  "Resource conflict detected: operation %s.")
92  % op.name()).str());
93  return;
94  }
95 
97 
98  // we need to receive the advanceClock() on every clock advance to update
99  // the resource conflict model
100  hasPendingOperations_ = true;
101 }
102 
103 /**
104  * Advances clock by one cycle.
105  *
106  * Updates the resource conflict model.
107  */
108 void
110 
112  // we need to receive the advanceClock() on every clock advance to update
113  // the resource conflict model
114  hasPendingOperations_ = true;
115 }
116 
117 /**
118  * Copies OperationExecutor.
119  *
120  * @return The copied OperationExecutor.
121  */
124  return new ConflictDetectingOperationExecutor(*this);
125 }
ConflictDetectingOperationExecutor::detector_
FUResourceConflictDetector & detector_
The conflict detector used to test whether starting operation is legal.
Definition: ConflictDetectingOperationExecutor.hh:72
TTAMachine::HWOperation
Definition: HWOperation.hh:52
Exception.hh
ConflictDetectingOperationExecutor::~ConflictDetectingOperationExecutor
virtual ~ConflictDetectingOperationExecutor()
Definition: ConflictDetectingOperationExecutor.cc:67
SimulationExecutionError
Definition: Exception.hh:951
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
FUResourceConflictDetector::OperationID
int OperationID
Type for identifying operations in the conflict detector interface.
Definition: FUResourceConflictDetector.hh:49
ConflictDetectingOperationExecutor::startOperation
virtual void startOperation(Operation &op)
Definition: ConflictDetectingOperationExecutor.cc:83
TCEString.hh
FUState
Definition: FUState.hh:58
OperationExecutor::hasPendingOperations_
bool hasPendingOperations_
This is set to true if the OperationExecutor is not in 'idle' mode.
Definition: OperationExecutor.hh:73
FUResourceConflictDetector
Definition: FUResourceConflictDetector.hh:45
ConflictDetectingOperationExecutor::copy
virtual OperationExecutor * copy()
Definition: ConflictDetectingOperationExecutor.cc:123
MultiLatencyOperationExecutor::advanceClock
virtual void advanceClock()
Definition: MultiLatencyOperationExecutor.cc:168
ConflictDetectingOperationExecutor::operationID_
const FUResourceConflictDetector::OperationID operationID_
The conflict detector ID of the operation executed with this executor.
Definition: ConflictDetectingOperationExecutor.hh:74
MultiLatencyOperationExecutor::startOperation
virtual void startOperation(Operation &op)
Definition: MultiLatencyOperationExecutor.cc:118
__func__
#define __func__
Definition: Application.hh:67
Operation.hh
MultiLatencyOperationExecutor
Definition: MultiLatencyOperationExecutor.hh:61
OperationExecutor
Definition: OperationExecutor.hh:49
Operation
Definition: Operation.hh:59
ConflictDetectingOperationExecutor::ConflictDetectingOperationExecutor
ConflictDetectingOperationExecutor(FUResourceConflictDetector &detector, FUResourceConflictDetector::OperationID operationID, FUState &parent, TTAMachine::HWOperation &hwOp, bool throwWhenConflict)
Definition: ConflictDetectingOperationExecutor.cc:53
FUResourceConflictDetector::issueOperation
virtual bool issueOperation(OperationID id)
Definition: FUResourceConflictDetector.cc:64
ConflictDetectingOperationExecutor::conflictCounter_
ClockCycleCount conflictCounter_
Counter for detected conflicts.
Definition: ConflictDetectingOperationExecutor.hh:79
ConflictDetectingOperationExecutor::advanceClock
virtual void advanceClock()
Definition: ConflictDetectingOperationExecutor.cc:109
ConflictDetectingOperationExecutor.hh
ConflictDetectingOperationExecutor::throwWhenConflict_
const bool throwWhenConflict_
True in case an exception should be thrown in case of a resource conflict.
Definition: ConflictDetectingOperationExecutor.hh:77