2 Copyright (c) 2002-2009 Tampere University.
4 This file is part of TTA-Based Codesign Environment (TCE).
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:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
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.
25 * @file SchedulingResource.icc
27 * In-line definitions for Scheduling Resource class
29 * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
36 * Return the name of resource
37 * return Name of resource
39 inline const std::string&
40 SchedulingResource::name() const {
45 * Test if resource is InputPSocketResource
46 * @return True if resource is InputPSocketResource
49 SchedulingResource::isInputPSocketResource() const {
54 * Test if resource is OutputPSocketResource
55 * @return True if resource is OutputPSocketResource
58 SchedulingResource::isOutputPSocketResource() const {
63 * Test if resource is ShortImmPSocketResource.
65 * @return True if resource is ShortImmPSocketResource.
68 SchedulingResource::isShortImmPSocketResource() const {
73 * Test if resource is InputFUResource
74 * @return True if resource is InputFUResource
78 SchedulingResource::isInputFUResource() const {
83 * Test if resource is OutputFUResource
84 * @return True if resource is OutputFUResource
87 SchedulingResource::isOutputFUResource() const {
92 * Test if resource is ExecutionPipelineResource
93 * @return True if resource is ExecutionPipelineResource
96 SchedulingResource::isExecutionPipelineResource() const {
101 * Test if resource is BusResource
102 * @return True if resource is BusResource
105 SchedulingResource::isBusResource() const {
110 * Test if resource is SegmentResource
111 * @return True if resource is SegmentResource
115 SchedulingResource::isSegmentResource() const {
119 * Test if resource is IUResource
120 * @return True if resource is IUResource
124 SchedulingResource::isIUResource() const {
128 * Test if resource is ITemplateResource
129 * @return True if resource is ITemplateResource
133 SchedulingResource::isITemplateResource() const {
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
143 SchedulingResource::validateDependentGroups() {
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
153 SchedulingResource::validateRelatedGroups() {
158 * Comparison operator. favours least used resources.
159 * @param other other schedulignresource which with to compare.
162 SchedulingResource::operator < (const SchedulingResource& other) const
164 if (useCount() < other.useCount()) {
167 if (useCount() > other.useCount()) {
170 return name() < other.name();
174 * Returns number of of related resources in group.
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.
181 SchedulingResource::relatedResourceCount(const int group) const {
182 return relatedResourceGroup_[group].size();
186 * Return number of of dependent resources in group.
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.
193 SchedulingResource::dependentResourceCount(const int group) const {
194 return dependentResourceGroup_[group].size();
198 * Return the instruction index corresponding to cycle.
200 * If modulo scheduling is not used (ie. initiation interval is 0), then
201 * index is equal to cycle.
203 * @param cycle Cycle to get instruction index.
204 * @return Return the instruction index for cycle.
207 SchedulingResource::instructionIndex(int cycle) const {
208 if (initiationInterval_ != 0 && cycle != -1 && cycle != INT_MAX) {
209 return cycle % initiationInterval_;