OpenASIP  2.0
SchedulingResource.icc
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 SchedulingResource.icc
26  *
27  * In-line definitions for Scheduling Resource class
28  *
29  * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include <climits>
34 
35 /**
36  * Return the name of resource
37  * return Name of resource
38  */
39 inline const std::string&
40 SchedulingResource::name() const {
41  return name_;
42 }
43 
44 /**
45  * Test if resource is InputPSocketResource
46  * @return True if resource is InputPSocketResource
47  */
48 inline bool
49 SchedulingResource::isInputPSocketResource() const {
50  return false;
51 }
52 
53 /**
54  * Test if resource is OutputPSocketResource
55  * @return True if resource is OutputPSocketResource
56  */
57 inline bool
58 SchedulingResource::isOutputPSocketResource() const {
59  return false;
60 }
61 
62 /**
63  * Test if resource is ShortImmPSocketResource.
64  *
65  * @return True if resource is ShortImmPSocketResource.
66  */
67 inline bool
68 SchedulingResource::isShortImmPSocketResource() const {
69  return false;
70 }
71 
72 /**
73  * Test if resource is InputFUResource
74  * @return True if resource is InputFUResource
75  */
76 
77 inline bool
78 SchedulingResource::isInputFUResource() const {
79  return false;
80 }
81 
82 /**
83  * Test if resource is OutputFUResource
84  * @return True if resource is OutputFUResource
85  */
86 inline bool
87 SchedulingResource::isOutputFUResource() const {
88  return false;
89 }
90 
91 /**
92  * Test if resource is ExecutionPipelineResource
93  * @return True if resource is ExecutionPipelineResource
94  */
95 inline bool
96 SchedulingResource::isExecutionPipelineResource() const {
97  return false;
98 }
99 
100 /**
101  * Test if resource is BusResource
102  * @return True if resource is BusResource
103  */
104 inline bool
105 SchedulingResource::isBusResource() const {
106  return false;
107 }
108 
109 /**
110  * Test if resource is SegmentResource
111  * @return True if resource is SegmentResource
112  */
113 
114 inline bool
115 SchedulingResource::isSegmentResource() const {
116  return false;
117 }
118 /**
119  * Test if resource is IUResource
120  * @return True if resource is IUResource
121  */
122 
123 inline bool
124 SchedulingResource::isIUResource() const {
125  return false;
126 }
127 /**
128  * Test if resource is ITemplateResource
129  * @return True if resource is ITemplateResource
130  */
131 
132 inline bool
133 SchedulingResource::isITemplateResource() const {
134  return false;
135 }
136 /**
137  * Test if all resource in dependent groups are of type
138  * supported by relevant resource
139  * @return true if resources are of correct types
140  */
141 
142 inline bool
143 SchedulingResource::validateDependentGroups() {
144  return false;
145 }
146 /**
147  * Test if all resource in related groups are of type
148  * supported by relevant resource
149  * @return true if resources are of correct types
150  */
151 
152 inline bool
153 SchedulingResource::validateRelatedGroups() {
154  return false;
155 }
156 
157 /**
158  * Comparison operator. favours least used resources.
159  * @param other other schedulignresource which with to compare.
160  */
161 inline bool
162 SchedulingResource::operator < (const SchedulingResource& other) const
163 {
164  if (useCount() < other.useCount()) {
165  return true;
166  }
167  if (useCount() > other.useCount()) {
168  return false;
169  }
170  return name() < other.name();
171 }
172 
173 /**
174  * Returns number of of related resources in group.
175  *
176  * @param group Group to count resources in.
177  * @return Number of related resources in group.
178  * @exception OutOfRange If group requested does not exist.
179  */
180 int
181 SchedulingResource::relatedResourceCount(const int group) const {
182  return relatedResourceGroup_[group].size();
183 }
184 
185 /**
186  * Return number of of dependent resources in group.
187  *
188  * @param group Group to count dependent in.
189  * @return Number of related dependent in group.
190  * @exception OutOfRange If group requested does not exist.
191  */
192 int
193 SchedulingResource::dependentResourceCount(const int group) const {
194  return dependentResourceGroup_[group].size();
195 }
196 
197 /**
198  * Return the instruction index corresponding to cycle.
199  *
200  * If modulo scheduling is not used (ie. initiation interval is 0), then
201  * index is equal to cycle.
202  *
203  * @param cycle Cycle to get instruction index.
204  * @return Return the instruction index for cycle.
205  */
206 int
207 SchedulingResource::instructionIndex(int cycle) const {
208  if (initiationInterval_ != 0 && cycle != -1 && cycle != INT_MAX) {
209  return cycle % initiationInterval_;
210  } else {
211  return cycle;
212  }
213 }