OpenASIP 2.2
Loading...
Searching...
No Matches
HWBlockImplementation.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 HWBlockImplementation.cc
26 *
27 * Implementation of HWBlockImplementation class.
28 *
29 * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include <string>
34
37#include "SequenceTools.hh"
38#include "ContainerTools.hh"
39
40using std::string;
41
42namespace HDB {
43
44/**
45 * The constructor.
46 *
47 * @param moduleName Name of the module.
48 * @param clkPort Name of the clock port.
49 * @param rstPort Name of the reset port.
50 * @param glockPort Name of the global lock port.
51 */
53 const std::string& moduleName,
54 const std::string& clkPort,
55 const std::string& rstPort,
56 const std::string& glockPort) :
57 moduleName_(moduleName), clkPort_(clkPort), rstPort_(rstPort),
58 glockPort_(glockPort) {
59}
60
61/**
62 * Copy constructor.
63 *
64 * @param original HWBlock to copy.
65 */
67 const HWBlockImplementation& original) {
68
69 moduleName_ = original.moduleName();
70 clkPort_ = original.clkPort();
71 rstPort_ = original.rstPort();
72 glockPort_ = original.glockPort();
73 hasID_ = original.hasID();
74
75 if (original.hasID()) {
76 id_ = original.id();
77 } else {
78 id_ = -1;
79 }
80
81 // Deep copy implementation file list.
82 for (int i = 0; i < original.implementationFileCount(); i++) {
84 new BlockImplementationFile(original.file(i));
85
86 addImplementationFile(newFile);
87 }
88}
89
90
91/**
92 * The destructor.
93 */
97
98
99/**
100 * Tells whether the implementation has an ID.
101 *
102 * @return True if the entry has an ID, otherwise false.
103 */
104bool
106 return hasID_;
107}
108
109
110/**
111 * Sets the ID for the implementation.
112 *
113 * @param id The ID to set.
114 */
115void
117 hasID_ = true;
118 id_ = id;
119}
120
121
122/**
123 * Returns the ID of the implementation.
124 *
125 * @return ID of the implementation.
126 */
127RowID
129 if (!hasID()) {
130 throw NotAvailable(__FILE__, __LINE__, __func__);
131 } else {
132 return id_;
133 }
134}
135
136/**
137 * Sets the module name.
138 *
139 * @param name Name of the module.
140 */
141void
142HWBlockImplementation::setModuleName(const std::string& name) {
143 moduleName_ = name;
144}
145
146
147/**
148 * Returns the name of the module.
149 *
150 * @return The name of the module.
151 */
152std::string
156
157
158/**
159 * Sets the name of the clock port.
160 *
161 * @param name Name of the port.
162 */
163void
164HWBlockImplementation::setClkPort(const std::string& name) {
165 clkPort_ = name;
166}
167
168
169/**
170 * Returns the name of the clock signal port.
171 *
172 * @return The name of the port.
173 */
174std::string
176 return clkPort_;
177}
178
179
180/**
181 * Sets the name of the reset port.
182 *
183 * @param name Name of the port.
184 */
185void
186HWBlockImplementation::setRstPort(const std::string& name) {
187 rstPort_ = name;
188}
189
190
191/**
192 * Returns the name of the reset port.
193 *
194 * @return The name of the port.
195 */
196std::string
198 return rstPort_;
199}
200
201
202/**
203 * Sets the name of the global lock port.
204 *
205 * @param name Name of the port.
206 */
207void
208HWBlockImplementation::setGlockPort(const std::string& name) {
209 glockPort_ = name;
210}
211
212
213/**
214 * Returns the name of the global lock port.
215 *
216 * @return The name of the port.
217 */
218std::string
222
223
224/**
225 * Adds a new implementation file for the block implementation.
226 *
227 * @param file The file to add.
228 */
229void
233
234
235/**
236 * Removes the given block implementation file from the implementation.
237 *
238 * @param file The file to remove.
239 */
240void
245
246
247/**
248 * Returns the number of files which constitutes the implementation of the
249 * block.
250 *
251 * @return The number of files.
252 */
253int
257
258
259/**
260 * Returns a block implementation file by the given index.
261 *
262 * @param index The index.
263 * @exception OutOfRange If the index is negative or not smaller than the
264 * number of files.
265 */
268 if (index < 0 || index >= implementationFileCount()) {
269 const string procName = "HWBlockImplementation::file";
270 throw OutOfRange(__FILE__, __LINE__, procName);
271 }
272
273 return *files_[index];
274}
275}
#define __func__
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
static bool removeValueIfExists(ContainerType &aContainer, const ElementType &aKey)
void setModuleName(const std::string &name)
std::string clkPort_
Name of the clock port.
HWBlockImplementation(const std::string &moduleName, const std::string &clkPort, const std::string &rstPort, const std::string &glockPort)
void setClkPort(const std::string &name)
bool hasID_
Tells whether the implementation has an ID.
RowID id_
ID of the implementation.
std::string glockPort_
Name of the global lock port.
void addImplementationFile(BlockImplementationFile *file)
void removeImplementationFile(const BlockImplementationFile &file)
void setRstPort(const std::string &name)
BlockImplementationFile & file(int index) const
void setGlockPort(const std::string &name)
std::string rstPort_
Name of the reset port.
std::string moduleName_
Name of the module.
FileTable files_
Contains the block implementation files.
static void deleteAllItems(SequenceType &aSequence)