OpenASIP 2.2
Loading...
Searching...
No Matches
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"
41
44
45/**
46 * Constructor with resource name
47 * @param name Name of resource
48 */
49OutputFUResource::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 */
63bool
64OutputFUResource::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 */
77void
78OutputFUResource::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*/
102void
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*/
127bool
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 */
152bool
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 */
163bool
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 */
182bool
184 for (int i = 0; i < relatedResourceGroupCount(); i++) {
185 if (relatedResourceCount(i) > 0) {
186 return false;
187 }
188 }
189 return true;
190}
#define abortWithError(message)
virtual bool canAssignSource(int cycle, const MoveNode &node, const TTAMachine::Port &resultPort) const
virtual void assignSource(int cycle, MoveNode &node)
virtual void unassignSource(const int cycle, MoveNode &node)
virtual bool canAssign(const int cycle, const MoveNode &node) const override
virtual void unassign(const int cycle, MoveNode &node) override
virtual void assign(const int cycle, MoveNode &node) override
OutputFUResource(const std::string &name, int opCount, int nopSlotWeight)
virtual ~OutputFUResource()
virtual bool validateRelatedGroups() override
virtual bool validateDependentGroups() override
virtual bool isOutputFUResource() const override
virtual void increaseUseCount()
int relatedResourceCount(const int group) const
virtual SchedulingResource & dependentResource(const int group, const int index) const
virtual bool isInputPSocketResource() const
virtual void decreaseUseCount()
virtual bool isOutputPSocketResource() const
int dependentResourceCount(const int group) const
virtual int relatedResourceGroupCount() const
virtual bool isExecutionPipelineResource() const
virtual int dependentResourceGroupCount() const