OpenASIP 2.2
Loading...
Searching...
No Matches
SchedulingResource.hh
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.hh
26 *
27 * Declaration of prototype of Resource Model:
28 * declaration of the SchedulingResource class.
29 *
30 * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
31 * @note rating: red
32 */
33
34
35#ifndef TTA_SCHEDULING_RESOURCE_HH
36#define TTA_SCHEDULING_RESOURCE_HH
37
38#include <string>
39#include <vector>
40#include <set>
41
42#include "Exception.hh"
43
44//#define NO_OVERCOMMIT
45
46class MoveNode;
47
48/**
49 * An interface for scheduling resources of Resource Model
50 * The base class SchedulingResource
51 */
53public:
54 virtual ~SchedulingResource();
55 SchedulingResource(const std::string& name, const unsigned int ii = 0);
56
57 virtual bool isInUse(const int cycle) const = 0;
58 virtual bool isAvailable(const int cycle) const = 0;
59 virtual bool canAssign(const int cycle, const MoveNode& node) const = 0;
60 virtual void assign(const int cycle, MoveNode& node) = 0;
61 virtual void unassign(const int cycle, MoveNode& node) = 0;
62
63 virtual int relatedResourceGroupCount() const;
64 virtual int dependentResourceGroupCount() const;
66 const int group) const;
68 const int group) const;
69 virtual void addToRelatedGroup(
70 const int group,
71 SchedulingResource& resource);
72 virtual void addToDependentGroup(
73 const int group,
74 SchedulingResource& resource);
76 const int group,
77 const int index) const;
79 const int group,
80 const int index) const;
81 virtual bool hasRelatedResource(
82 const SchedulingResource& sResource)const;
83 virtual bool hasDependentResource(
84 const SchedulingResource& sResource)const;
85 virtual const std::string& name() const;
86 virtual int useCount() const;
87 virtual void increaseUseCount();
88 virtual void decreaseUseCount();
89
90 // Determine if resource is InputPSocketResource
91 virtual bool isInputPSocketResource() const;
92 // Determine if resource is OutputPSocketResource
93 virtual bool isOutputPSocketResource() const;
94 // Determine if resource is OutputPSocketResource
95 virtual bool isShortImmPSocketResource() const;
96 // Determine if resource is InputFUResource
97 virtual bool isInputFUResource() const;
98 // Determine if resource is OutputFUResource
99 virtual bool isOutputFUResource() const;
100 // Determine if resource is ExecutionPipelineResource
101 virtual bool isExecutionPipelineResource() const;
102 // Determine if resource is BusResource
103 virtual bool isBusResource() const;
104 // Determine if resource is SegmentResource
105 virtual bool isSegmentResource() const;
106 // Determine if resource is IUResource
107 virtual bool isIUResource() const;
108 // Determine if resource is ITemplateResource
109 virtual bool isITemplateResource() const;
110
111 // Get instruction index for resource
112 inline int instructionIndex(int cycle) const;
113
114 // Set initiation interval for resource
115 void setInitiationInterval(unsigned int ii);
116 int initiationInterval() const;
117
118 friend class ResourceBroker;
119
120 virtual bool operator < (const SchedulingResource& other) const;
121 virtual void clear();
122 virtual void setMaxCycle(unsigned int) {};
123protected:
124 // Tests if all referenced resources in dependent groups are of correct
125 // type
126 virtual bool validateDependentGroups() ;
127 // Tests if all referenced resources in related groups are of correct
128 // type
129 virtual bool validateRelatedGroups() ;
130
131 // initiation interval used for modulo scheduler
133
134private:
135 // A vector type that stores SchedulingResource pointers
136 typedef std::vector<SchedulingResource*> SchedulingResourceVector;
137 // A container storing SchedulingResourceVectors
138 typedef std::vector<SchedulingResourceVector> SchedulingResourceGroup;
139 // Copying forbidden (it is abstract class but anyway)
141 //Assignment forbidden (it is abstract class but anyway)
143
144 // The related resource group
146 // The dependent resource group
148 // Defines name of the resource
149 std::string name_;
150
151 typedef std::set<const SchedulingResource*> SchedulingResourceSet;
153
154 // Counts number of times particular resource was used
156};
157
158/**
159 * Set of scheduling resources.
160 */
162public:
166 int count() const;
167 SchedulingResource& resource(int index) const;
170 void sort();
171 void clear();
173private:
174 // List for resources.
175 typedef std::vector<SchedulingResource*> ResourceList;
176
177 struct less_name {
179 return *x < *y;
180 }
181 };
182
183 // Scheduling resources in the set.
185};
186
187#include "SchedulingResource.icc"
188
189#endif
void remove(SchedulingResource &resource)
SchedulingResource & resource(int index) const
SchedulingResourceSet & operator=(const SchedulingResourceSet &newSet)
std::vector< SchedulingResource * > ResourceList
bool hasResource(SchedulingResource &res)
void insert(SchedulingResource &resource)
virtual bool isOutputFUResource() const
virtual void addToDependentGroup(const int group, SchedulingResource &resource)
virtual void increaseUseCount()
virtual bool isBusResource() const
SchedulingResource(const SchedulingResource &)
virtual bool validateRelatedGroups()
virtual SchedulingResource & relatedResource(const int group, const int index) const
int instructionIndex(int cycle) const
virtual void unassign(const int cycle, MoveNode &node)=0
virtual bool validateDependentGroups()
virtual bool isITemplateResource() const
int relatedResourceCount(const int group) const
virtual bool canAssign(const int cycle, const MoveNode &node) const =0
void setInitiationInterval(unsigned int ii)
virtual bool isShortImmPSocketResource() const
virtual SchedulingResource & dependentResource(const int group, const int index) const
std::vector< SchedulingResource * > SchedulingResourceVector
virtual void addToRelatedGroup(const int group, SchedulingResource &resource)
virtual bool isInputPSocketResource() const
SchedulingResource & operator=(const SchedulingResource &)
std::set< const SchedulingResource * > SchedulingResourceSet
virtual const std::string & name() const
virtual bool isIUResource() const
virtual bool hasDependentResource(const SchedulingResource &sResource) const
virtual void decreaseUseCount()
std::vector< SchedulingResourceVector > SchedulingResourceGroup
virtual bool hasRelatedResource(const SchedulingResource &sResource) const
SchedulingResourceGroup dependentResourceGroup_
virtual bool isOutputPSocketResource() const
int dependentResourceCount(const int group) const
virtual int relatedResourceGroupCount() const
virtual bool isAvailable(const int cycle) const =0
virtual bool isSegmentResource() const
virtual bool isInputFUResource() const
virtual bool operator<(const SchedulingResource &other) const
virtual int useCount() const
virtual void assign(const int cycle, MoveNode &node)=0
SchedulingResourceGroup relatedResourceGroup_
virtual void setMaxCycle(unsigned int)
virtual bool isExecutionPipelineResource() const
virtual int dependentResourceGroupCount() const
virtual bool isInUse(const int cycle) const =0
SchedulingResourceSet relatedResourceSet_
bool operator()(SchedulingResource *x, SchedulingResource *y)