OpenASIP 2.2
Loading...
Searching...
No Matches
NetlistPortGroup.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2015 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 NetlistPortGroup.cc
26 *
27 * Implementation of NetlistPortGroup class.
28 *
29 * Created on: 24.4.2015
30 * @author: Henry Linjamäki (henry.linjamaki-no.spam-tut.fi)
31 * @note rating: red
32 */
33
34#include "NetlistPortGroup.hh"
35
36#include <cassert>
37#include <iterator>
38
39#include "BaseNetlistBlock.hh"
40#include "NetlistPort.hh"
41
42#include "SequenceTools.hh"
43
44namespace ProGe {
45
47 : parent_(nullptr), ports_(), signalGroup_() {}
48
49/**
50 * Copy constructor. Copies everything except parent block reference.
51 */
53 const NetlistPortGroup& other, bool asMirrored)
54 : parent_(nullptr), ports_(), signalGroup_(other.signalGroup_) {
55 std::insert_iterator<PortContainerType> portInserter(
56 ports_, ports_.begin());
57 for (size_t i = 0; i < other.portCount(); i++) {
58 portInserter = other.portAt(i).clone(asMirrored);
59 }
60}
61
62/**
63 * Constructs empty port group with given SignalGroup.
64 */
66 : parent_(nullptr), ports_(), signalGroup_(signalGroup) {}
67
73
74/**
75 * Returns number of ports in the group.
76 */
77size_t
79 return ports_.size();
80}
81
82const NetlistPort&
83NetlistPortGroup::portAt(size_t index) const {
84 return *ports_.at(index);
85}
86
89 return *ports_.at(index);
90}
91
92void
94 ports_.push_back(&port);
95}
96
97bool
99 for (const NetlistPort* p : *this) {
100 if (p->assignedSignal() == type) {
101 return true;
102 }
103 }
104 return false;
105}
106
107/**
108 * Returns first found port by given signal type.
109 */
110const NetlistPort&
112 for (const NetlistPort* p : *this) {
113 if (p->assignedSignal() == type) {
114 return *p;
115 }
116 }
119 "The port group does not have port by given signal type.");
120}
121
122/**
123 * Clears all ports associated to the port group.
124 *
125 * The Ports are deleted and detached from the parent block.
126 */
127void
131
132bool
134 return parent_ != nullptr;
135}
136
137const BaseNetlistBlock&
139 assert(hasParent());
140 return *parent_;
141}
142
145 assert(hasParent());
146 return *parent_;
147}
148
149void
151 parent_ = newParent;
152}
153
154void
156 signalGroup_ = signalGroup;
157}
158
163
164/**
165 * Clones the NetlistPort and and its ports without parent block reference
166 * since it would break unique port name constraint.
167 */
169NetlistPortGroup::clone(bool asMirrored) const {
170 NetlistPortGroup* newGroup = new NetlistPortGroup(*this, asMirrored);
171 assert(this->portCount() == newGroup->portCount());
172 for (size_t i = 0; i < portCount(); i++) {
173 assert(
174 this->portAt(i).assignedSignal().type() ==
175 newGroup->portAt(i).assignedSignal().type());
176 }
177 return newGroup;
178}
179
182 return ports_.begin();
183}
184
187 return ports_.end();
188}
189
192 return ports_.begin();
193}
194
197 return ports_.end();
198}
199
202 return ports_.rbegin();
203}
204
207 return ports_.rend();
208}
209
212 return ports_.rbegin();
213}
214
217 return ports_.rend();
218}
219
220} /* namespace ProGe */
#define assert(condition)
#define THROW_EXCEPTION(exceptionType, message)
Exception wrapper macro that automatically includes file name, line number and function name where th...
Definition Exception.hh:39
PortContainerType ports_
The ports belonging to this group by reference.
const NetlistPort & portAt(size_t index) const
SignalGroup signalGroup_
The usage/implemented interface of the group.
BaseNetlistBlock * parent_
The parent block where the group belongs to.
PortContainerType::iterator iterator
void addPort(NetlistPort &port)
bool hasPortBySignal(SignalType type) const
SignalGroup assignedSignalGroup() const
PortContainerType::reverse_iterator reverse_iterator
const NetlistPort & portBySignal(SignalType type) const
virtual NetlistPortGroup * clone(bool asMirrored=false) const
PortContainerType::const_reverse_iterator const_reverse_iterator
void setParent(BaseNetlistBlock *newParent)
PortContainerType::const_iterator const_iterator
void assignSignalGroup(SignalGroup signalGroup)
const BaseNetlistBlock & parent() const
reverse_iterator rbegin()
virtual NetlistPort * clone(bool asMirrored=false) const
Signal assignedSignal() const
SignalType type() const
Definition Signal.cc:55
static void deleteAllItems(SequenceType &aSequence)
Definition FUGen.hh:54