OpenASIP 2.2
Loading...
Searching...
No Matches
ITemplateResource.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 ITemplateResource.cc
26 *
27 * Implementation of ITemplateResource class.
28 *
29 * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include "ITemplateResource.hh"
34#include "MapTools.hh"
35#include "Application.hh"
37
38/**
39 * Constructor.
40 *
41 * @param name Name of template.
42 */
45 unsigned int initiationInterval):
46 SchedulingResource(templ.name(), initiationInterval),
47 template_(&templ){
48}
49
50/**
51 * Destructor.
52 */
55
56/**
57 * Test if instruction template resource is used in given cycle.
58 *
59 * @param cycle Cycle to test.
60 * @return True if resource is used in given cycle.
61 */
62bool
63ITemplateResource::isInUse(const int cycle) const {
66 return true;
67 }
68 }
69 return false;
70}
71
72/**
73 * Test if instruction tempalte resource is available in given cycle.
74 *
75 * @param cycle Cycle to test.
76 * @return True if resource available in given cycle.
77 */
78bool
79ITemplateResource::isAvailable(const int cycle) const {
80 return !isInUse(cycle);
81}
82
83/**
84 * The overridden method should be used instead.
85 */
86void
88 abortWithError("Not implemented!");
89}
90
91/**
92 * Assign instruction template resource to given cycle.
93 *
94 * @param cycle Cycle to assign.
95 */
96void
97ITemplateResource::assign(const int cycle) {
98
99 if (canAssign(cycle)) {
102 } else {
104 }
105 }
106}
107
108/**
109 * The overridden method should be used instead.
110 */
111void
113
114 abortWithError("Not implemented!");
115}
116
117/**
118 * Unassign instruction template from given cycle.
119 *
120 * @param cycle Cycle to remove assignment from.
121 */
122void
124
125 if (isInUse(cycle)) {
127 }
128}
129
130/**
131 * The overridden method should be used instead.
132 */
133bool
134ITemplateResource::canAssign(const int, const MoveNode&) const {
135 abortWithError("Not implemented!");
136 return false;
137}
138
139/**
140 * Return true if instruction template resource can be assigned on given cycle.
141 *
142 * @param cycle Cycle to test.
143 * @return True if template can be assigned to given cycle.
144 */
145bool
146ITemplateResource::canAssign(const int cycle) const {
147 return !isInUse(cycle);
148}
149
150/**
151 * Return true always.
152 *
153 * @return True always.
154 */
155bool
157 return true;
158}
159
160/**
161 * Tests if all referred resources in dependent groups are of
162 * proper types.
163 *
164 * @return True If all resources in dependent groups are
165 * immediate units or buses (move slots).
166 */
167bool
169 for (int i = 0; i < dependentResourceGroupCount(); i++) {
170 for (int j = 0, count = dependentResourceCount(i); j < count; j++) {
171 if (!(dependentResource(i, j).isIUResource() ||
173 return false;
174 }
175 }
176 }
177 return true;
178}
179
180/**
181 * Tests if related resource groups are empty.
182 *
183 * @return True if related resource groups are empty.
184 * @note This resource type has no related resources.
185 */
186bool
188 for (int i = 0; i < relatedResourceGroupCount(); i++) {
189 if (relatedResourceCount(i) > 0) {
190 return false;
191 }
192 }
193 return true;
194}
195
196
197/**
198 * Clears bookkeeping of the scheduling resource.
199 *
200 * After this call the state of the resource should be identical to a
201 * newly-created and initialized resource.
202 */
203void
208
209/**
210 * Comparison operator.
211 *
212 * Favours itemplates with more nop slots.
213 */
214bool
216 const ITemplateResource *itr = static_cast<const ITemplateResource*>(&other);
217 if (itr == NULL) {
218 return false;
219 }
220
221 return SchedulingResource::operator<(other);
222}
#define abortWithError(message)
virtual bool canAssign(const int cycle, const MoveNode &node) const override
virtual bool isInUse(const int cycle) const override
virtual void assign(const int cycle, MoveNode &node) override
void clear() override
ResourceRecordType resourceRecord_
ITemplateResource(TTAMachine::InstructionTemplate &templ, unsigned int initiationInterval=0)
virtual bool operator<(const SchedulingResource &other) const override
virtual bool isAvailable(const int cycle) const override
virtual bool validateDependentGroups() override
virtual void unassign(const int cycle, MoveNode &node) override
virtual bool validateRelatedGroups() override
virtual bool isITemplateResource() const override
static KeyType keyForValue(const MapType &aMap, const ValueType &aValue)
static bool containsKey(const MapType &aMap, const KeyType &aKey)
virtual bool isBusResource() const
int instructionIndex(int cycle) const
int relatedResourceCount(const int group) const
virtual SchedulingResource & dependentResource(const int group, const int index) const
virtual bool isIUResource() const
int dependentResourceCount(const int group) const
virtual int relatedResourceGroupCount() const
virtual bool operator<(const SchedulingResource &other) const
virtual int dependentResourceGroupCount() const