OpenASIP 2.2
Loading...
Searching...
No Matches
PendingAssignment.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 PendingAssignment.cc
26 *
27 * Implementation of PendingAssignment class.
28 *
29 * @author Ari Mets�halme 2006 (ari.metsahalme-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include <string>
34
35#include "ResourceBroker.hh"
36#include "PendingAssignment.hh"
37#include "MoveNode.hh"
38
39using std::string;
40
41/**
42 * Constructor.
43 */
45 broker_(broker), cycle_(-1), node_(NULL), assignmentTried_(false),
46 lastTriedAssignment_(-1) {
47}
48
49/**
50 * Destructor.
51 */
54
55/**
56 * Return the broker of this pending assignment.
57 *
58 * @return The broker of this pending assignment.
59 */
64
65/**
66 * Record the input node to which resources have to be assigned or
67 * allocated, and the cycle in which the node should be placed.
68 *
69 * @param cycle Cycle.
70 * @param node Node.
71 */
72void
74 const TTAMachine::Bus* bus,
75 const TTAMachine::FunctionUnit* srcFU,
76 const TTAMachine::FunctionUnit* dstFU,
77 int immWriteCycle,
78 const TTAMachine::ImmediateUnit* immu,
79 int immRegIndex) {
80 cycle_ = cycle;
81 node_ = &node;
82 bus_ = bus;
83 srcFU_ = srcFU;
84 dstFU_ = dstFU;
85 immWriteCycle_ = immWriteCycle;
86 immu_ = immu;
87 immRegIndex_ = immRegIndex;
89}
90
91/**
92 * Return true if, for the currently applied assignments, there exists
93 * at least one tentative assignment which has not been tried yet.
94 *
95 * @return True if, for the currently applied assignments, there exists
96 * at least one tentative assignment which has not been tried yet.
97 */
98bool
100 if (lastTriedAssignment_ == -1) {
104 // Sorts candidate set of resources by their use count or name if
105 // the use counts are identical
107 }
109}
110
111/**
112 * Try to assign the next possible assignment found by current
113 * broker.
114 *
115 * @exception ModuleRunTimeError If this PendingAssignment has run out of
116 * possible assignments.
117 */
118void
120
122
123 if (availableResources_.count() == 0 ||
125 string msg = "Ran out of possible assignments!";
126 throw ModuleRunTimeError(__FILE__, __LINE__, __func__, msg);
127 }
128
132 assignmentTried_ = true;
133}
134
135/**
136 * Unassign the resource of this pending assignment currently assigned
137 * to the node.
138 *
139 * Last tried assignment is remembered.
140 *
141 * @exception ModuleRunTimeError If no resource in the set of
142 * resources of this pending assignment is currently assigned to the
143 * node.
144 */
145void
149 } else {
150 string msg = "No resource in the set of resources of this pending"
151 "assignment was assigned to the given node!";
152 throw ModuleRunTimeError(__FILE__, __LINE__, __func__, msg);
153 }
154}
155
156/**
157 * Clear out the record of the possible resource assignments of the
158 * current broker that have been already tried.
159 *
160 * If one of the possible resources is still assigned to the node,
161 * unassign it.
162 */
163void
170
171/**
172 * Clears the pending assignment.
173 *
174 * Does not unassign anything.
175 */
176void
178 cycle_ = -1;
179 node_ = NULL;
180 immu_ = NULL;
181 immWriteCycle_ = -1;
182 immRegIndex_ = -1;
183
184 assignmentTried_ = false;
187 bus_ = NULL;
188}
#define __func__
find Finds info of the inner loops in the false
SchedulingResourceSet availableResources_
ResourceBroker & broker()
const TTAMachine::Bus * bus_
const TTAMachine::FunctionUnit * dstFU_
const TTAMachine::ImmediateUnit * immu_
ResourceBroker & broker_
Corresponding resource broker.
PendingAssignment(ResourceBroker &broker)
const TTAMachine::FunctionUnit * srcFU_
void setRequest(int cycle, MoveNode &node, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex)
virtual bool isAlreadyAssigned(int cycle, const MoveNode &node, const TTAMachine::Bus *preassignedBus) const =0
virtual void assign(int cycle, MoveNode &node, SchedulingResource &res, int immWriteCycle, int immRegIndex)=0
virtual void unassign(MoveNode &node)=0
virtual SchedulingResourceSet allAvailableResources(int cycle, const MoveNode &node, const TTAMachine::Bus *bus, const TTAMachine::FunctionUnit *srcFU, const TTAMachine::FunctionUnit *dstFU, int immWriteCycle, const TTAMachine::ImmediateUnit *immu, int immRegIndex) const
SchedulingResource & resource(int index) const