OpenASIP 2.2
Loading...
Searching...
No Matches
PipelineElement.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 PipelineElement.cc
26 *
27 * Implementation of class PipelineElement.
28 *
29 * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30 */
31
32#include "PipelineElement.hh"
33#include "FunctionUnit.hh"
34#include "ExecutionPipeline.hh"
35#include "HWOperation.hh"
36#include "MachineTester.hh"
37
38using std::string;
39
40namespace TTAMachine {
41
42/**
43 * Constructor.
44 *
45 * Pipeline elements are created automatically when pipeline of operation is
46 * created. Clients should not create pipeline elements.
47 *
48 * @param name Name of the pipeline element.
49 * @param parentUnit The parent unit.
50 * @exception ComponentAlreadyExists If there exists another pipeline element
51 * by the same name in the function unit.
52 * @exception InvalidName If the given name is not a valid component name.
53 */
55 const std::string& name, FunctionUnit& parentUnit)
56 : name_(""), parent_(&parentUnit) {
58
59 // clear parent pointer to pass the assert in addPipelineElement
60 parent_ = NULL;
61
64}
65
66/**
67 * Destructor.
68 */
70
71 FunctionUnit* parent = parent_;
72 parent_ = NULL;
73 parent->deletePipelineElement(*this);
74
75 // remove usages of this resource
76 for (int i = 0; i < parent->operationCount(); i++) {
77 HWOperation* operation = parent->operation(i);
78 ExecutionPipeline* pLine = operation->pipeline();
79 pLine->removeResourceUse(name());
80 }
81}
82
83
84/**
85 * Sets the name of the pipeline element.
86 *
87 * @param name The new name.
88 * @exception ComponentAlreadyExists If another pipeline element exists by
89 * the same name in the same function unit.
90 * @exception InvalidName If the given name is not a valid component name.
91 */
92void
93PipelineElement::setName(const std::string& name) {
94 const string procName = "PipelineElement::setName";
95
97 throw InvalidName(__FILE__, __LINE__, procName);
98 }
99
100 if (name == this->name()) {
101 return;
102 }
103
104 if (parentUnit()->hasPipelineElement(name)) {
105 throw ComponentAlreadyExists(__FILE__, __LINE__, procName);
106 }
107
108 name_ = name;
109}
110
112 const PipelineElement* pe1, const PipelineElement* pe2) const {
113 if (pe1 == NULL) {
114 return false;
115 }
116 if (pe2 == NULL) {
117 return true;
118 }
119 if (pe1->name() > pe2->name()) {
120 return true;
121 }
122
123 if (pe2->name() > pe1->name()) {
124 return false;
125 }
126
127 if (pe1->parentUnit()->name() > pe2->parentUnit()->name()) {
128 return true;
129 }
130 return false;
131}
132
133}
134
135
static bool isValidComponentName(const std::string &name)
virtual TCEString name() const
void removeResourceUse(const std::string &name)
virtual void addPipelineElement(PipelineElement &element)
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
virtual void deletePipelineElement(PipelineElement &element)
ExecutionPipeline * pipeline() const
void setName(const std::string &name)
FunctionUnit * parent_
The parent unit.
std::string name_
Name of the pipeline element.
PipelineElement(const std::string &name, FunctionUnit &parentUnit)
FunctionUnit * parentUnit() const
const std::string & name() const
bool operator()(const PipelineElement *pe1, const PipelineElement *pe2) const