OpenASIP  2.0
ReservationTableFUResourceConflictDetector.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 ReservationTableFUResourceConflictDetector.cc
26  *
27  * Definition of ReservationTableFUResourceConflictDetector 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"
37 #include "TCEString.hh"
38 
39 /**
40  * Constructor.
41  *
42  * @param fu The function unit to detect conflicts for.
43  * @exception InvalidData If the model could not be built from the given FU.
44  */
47  const TTAMachine::FunctionUnit& fu)
48  : reservationTables_(fu), globalReservationTable_(fu), fu_(fu) {}
49 
50 /**
51  * Destructor.
52  */
55 }
56 
57 /**
58  * Issues an operation and reports a conflict if detected.
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 issueOperationInline(id);
66 }
67 
68 /**
69  * Simulates a cycle advance and reports a conflict if detected.
70  *
71  * @return False in case a conflict is detected, otherwise true.
72  */
73 bool
75  return advanceCycleInline();
76 }
77 
78 /**
79  * Returns an operation id for the given operation.
80  *
81  * Operation IDs are used in the interface for optimizing the access. This
82  * method converts OSAL Operations to operation IDs.
83  *
84  * @param operation The OSAL Operation to find ID for.
85  * @return The operation ID.
86  * @exception KeyNotFound if the operation of given name couldn't be found
87  */
90  const TCEString& operationName) const {
91 
92  // find the index of the operation in the FU, it corresponds to the
93  // operation ID
94  for (int i = 0; i < fu_.operationCount(); ++i) {
95  if (StringTools::ciEqual(fu_.operation(i)->name(), operationName)) {
96  return i;
97  }
98  }
99  throw KeyNotFound(__FILE__, __LINE__, __func__, "Operation not found.");
100 }
101 
102 /**
103  * Sets the state of the detector to its initial state.
104  *
105  * This means that the FU state is assumed to be what it is in powerup.
106  */
107 void
110 }
ReservationTableFUResourceConflictDetector::issueOperationInline
bool issueOperationInline(OperationID id)
ReservationTableFUResourceConflictDetector::advanceCycleInline
bool advanceCycleInline()
ReservationTableFUResourceConflictDetector::globalReservationTable_
ReservationTable globalReservationTable_
The global reservation table.
Definition: ReservationTableFUResourceConflictDetector.hh:75
ReservationTableFUResourceConflictDetector::issueOperation
virtual bool issueOperation(OperationID id)
Definition: ReservationTableFUResourceConflictDetector.cc:64
ReservationTableFUResourceConflictDetector::fu_
const TTAMachine::FunctionUnit & fu_
The modeled FU.
Definition: ReservationTableFUResourceConflictDetector.hh:77
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
ReservationTableFUResourceConflictDetector.hh
__func__
#define __func__
Definition: Application.hh:67
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
StringTools::ciEqual
static bool ciEqual(const std::string &a, const std::string &b)
Definition: StringTools.cc:240
ReservationTableFUResourceConflictDetector::~ReservationTableFUResourceConflictDetector
virtual ~ReservationTableFUResourceConflictDetector()
Definition: ReservationTableFUResourceConflictDetector.cc:54
ReservationTableFUResourceConflictDetector::operationID
virtual OperationID operationID(const TCEString &operationName) const
Definition: ReservationTableFUResourceConflictDetector.cc:89
ReservationTableFUResourceConflictDetector::advanceCycle
virtual bool advanceCycle()
Definition: ReservationTableFUResourceConflictDetector.cc:74
TCEString
Definition: TCEString.hh:53
KeyNotFound
Definition: Exception.hh:285
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
ReservationTableFUResourceConflictDetector::reset
virtual void reset()
Definition: ReservationTableFUResourceConflictDetector.cc:108
ReservationTableFUResourceConflictDetector::ReservationTableFUResourceConflictDetector
ReservationTableFUResourceConflictDetector(const TTAMachine::FunctionUnit &fu)
Definition: ReservationTableFUResourceConflictDetector.cc:46
FunctionUnit.hh