OpenASIP  2.0
OutputFUResource.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 OutputFUResource.cc
26  *
27  * Implementation of prototype of Resource Model:
28  * implementation of the OutputFUResource.
29  *
30  * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #include "OutputFUResource.hh"
35 #include "FUPort.hh"
36 #include "Application.hh"
37 #include "Exception.hh"
38 #include "MoveNode.hh"
40 #include "OutputPSocketResource.hh"
41 
42 using TTAMachine::FUPort;
43 using TTAMachine::Port;
44 
45 /**
46  * Constructor with resource name
47  * @param name Name of resource
48  */
49 OutputFUResource::OutputFUResource(const std::string& name, int opCount,
50  int nopSlotWeight) :
51  FUResource(name, opCount, nopSlotWeight) {}
52 
53 /**
54  * Empty destructor
55  */
57 
58 /**
59  * Not to be used, aborts!
60  *
61  * Use version with third OutputPSocket operand!
62  */
63 bool
64 OutputFUResource::canAssign(const int, const MoveNode&) const {
65  abortWithError("Wrong method. Use canAssign with PSocket!");
66  return false;
67 }
68 
69 /**
70  * Assign resource to given node for given cycle.
71  *
72  * There is actually nothing assigned here, only test
73  * that the OutputPSocket of given FU can be assigned.
74  * @param cycle Cycle to assign
75  * @param node MoveNode assigned
76  */
77 void
78 OutputFUResource::assign(const int cycle, MoveNode& node) {
79 
80  for (int i = 0; i < dependentResourceGroupCount(); i++) {
81  for (int j = 0, count = dependentResourceCount(i); j < count; j++) {
85  dynamic_cast<ExecutionPipelineResource*>(res);
86  epRes->assignSource(cycle, node);
88  return;
89  }
90  }
91  }
92 }
93 
94 /**
95 * Unassign resource from given node for given cycle.
96 *
97 * It only tests that OutputPSocket to be unassigned is
98 * connected to given FU.
99 * @param cycle Cycle to remove assignment from
100 * @param node MoveNode to remove assignment from
101 */
102 void
104  const int cycle,
105  MoveNode& node) {
106 
107  for (int i = 0; i < dependentResourceGroupCount(); i++) {
108  for (int j = 0, count = dependentResourceCount(i); j < count; j++) {
112  dynamic_cast<ExecutionPipelineResource*>(res);
113  epRes->unassignSource(cycle, node);
115  return;
116  }
117  }
118  }
119 }
120 
121 /**
122 * Return true if resource can be assigned for given node in given cycle
123 * @param cycle Cycle to test
124 * @param node MoveNode to test
125 * @return true if node can be assigned to cycle
126 */
127 bool
129  const int cycle,
130  const MoveNode& node,
131  const TTAMachine::Port& resultPort) const {
132 
133  for (int i = 0; i < dependentResourceGroupCount(); i++) {
134  for (int j = 0, count = dependentResourceCount(i); j < count; j++) {
138  dynamic_cast<ExecutionPipelineResource*>(res);
139  if (!epRes->canAssignSource(cycle, node, resultPort)){
140  return false;
141  }
142  }
143  }
144  }
145  return true;
146 }
147 
148 /**
149  * Allways return true
150  * @return true
151  */
152 bool
154  return true;
155 }
156 
157 /**
158  * Tests if all referred resources in dependent groups are of
159  * proper types
160  * @return true If all resources in dependent groups are
161  * input or output PSockets or ExecutionPipeline
162  */
163 bool
165  for (int i = 0; i < dependentResourceGroupCount(); i++) {
166  for (int j = 0, count = dependentResourceCount(i); j < count; j++) {
170  return false;
171  }
172  }
173  }
174  return true;
175 }
176 
177 /**
178  * Tests if related resource groups are empty
179  * @return true If all resources in related resource groups are
180  * empty
181  */
182 bool
184  for (int i = 0; i < relatedResourceGroupCount(); i++) {
185  if (relatedResourceCount(i) > 0) {
186  return false;
187  }
188  }
189  return true;
190 }
ExecutionPipelineResource
Definition: ExecutionPipelineResource.hh:64
SchedulingResource::dependentResourceGroupCount
virtual int dependentResourceGroupCount() const
Definition: SchedulingResource.cc:71
OutputPSocketResource.hh
ExecutionPipelineResource::canAssignSource
virtual bool canAssignSource(int cycle, const MoveNode &node, const TTAMachine::Port &resultPort) const
Definition: ExecutionPipelineResource.cc:819
OutputFUResource::validateRelatedGroups
virtual bool validateRelatedGroups() override
Definition: OutputFUResource.cc:183
Exception.hh
ExecutionPipelineResource::unassignSource
virtual void unassignSource(const int cycle, MoveNode &node)
Definition: ExecutionPipelineResource.cc:597
MoveNode
Definition: MoveNode.hh:65
OutputFUResource.hh
SchedulingResource::isInputPSocketResource
virtual bool isInputPSocketResource() const
SchedulingResource::dependentResource
virtual SchedulingResource & dependentResource(const int group, const int index) const
Definition: SchedulingResource.cc:158
SchedulingResource::dependentResourceCount
int dependentResourceCount(const int group) const
TTAMachine::FUPort
Definition: FUPort.hh:46
OutputFUResource::isOutputFUResource
virtual bool isOutputFUResource() const override
Definition: OutputFUResource.cc:153
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
SchedulingResource
Definition: SchedulingResource.hh:52
TTAMachine::Port
Definition: Port.hh:54
Application.hh
OutputFUResource::unassign
virtual void unassign(const int cycle, MoveNode &node) override
Definition: OutputFUResource.cc:103
FUResource
Definition: FUResource.hh:46
SchedulingResource::isOutputPSocketResource
virtual bool isOutputPSocketResource() const
SchedulingResource::isExecutionPipelineResource
virtual bool isExecutionPipelineResource() const
ExecutionPipelineResource::assignSource
virtual void assignSource(int cycle, MoveNode &node)
Definition: ExecutionPipelineResource.cc:405
OutputFUResource::OutputFUResource
OutputFUResource(const std::string &name, int opCount, int nopSlotWeight)
Definition: OutputFUResource.cc:49
SchedulingResource::relatedResourceCount
int relatedResourceCount(const int group) const
OutputFUResource::assign
virtual void assign(const int cycle, MoveNode &node) override
Definition: OutputFUResource.cc:78
OutputFUResource::canAssign
virtual bool canAssign(const int cycle, const MoveNode &node) const override
Definition: OutputFUResource.cc:64
ExecutionPipelineResource.hh
OutputFUResource::validateDependentGroups
virtual bool validateDependentGroups() override
Definition: OutputFUResource.cc:164
FUPort.hh
SchedulingResource::decreaseUseCount
virtual void decreaseUseCount()
Definition: SchedulingResource.cc:364
SchedulingResource::relatedResourceGroupCount
virtual int relatedResourceGroupCount() const
Definition: SchedulingResource.cc:61
MoveNode.hh
OutputFUResource::~OutputFUResource
virtual ~OutputFUResource()
Definition: OutputFUResource.cc:56
SchedulingResource::increaseUseCount
virtual void increaseUseCount()
Definition: SchedulingResource.cc:355