OpenASIP 2.2
Loading...
Searching...
No Matches
RFImplementation.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 RFImplementation.cc
26 *
27 * Implementation of RFImplementation class.
28 *
29 * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include <string>
34
35#include "RFImplementation.hh"
36#include "RFEntry.hh"
37#include "RFExternalPort.hh"
40#include "SequenceTools.hh"
41#include "ContainerTools.hh"
42
43using std::string;
44
45namespace HDB {
46
47/**
48 * The constructor.
49 *
50 * @param moduleName Name of the module.
51 * @param clkPort Name of the clock port.
52 * @param rstPort Name of the reset port.
53 * @param glockPort Name of the global lock port.
54 * @param sizeParam Name of the parameter that defines the size of the
55 * register file.
56 * @param widthParam Name of the parameter that defines the width of the
57 * register file.
58 * @param guardPort Name of the guard port.
59 * @param sacParam Flag for separate address cycle. Default value is false.
60 */
62 const std::string& moduleName,
63 const std::string& clkPort,
64 const std::string& rstPort,
65 const std::string& glockPort,
66 const std::string& sizeParam,
67 const std::string& widthParam,
68 const std::string& guardPort,
69 bool sacParam) :
70 HWBlockImplementation(moduleName, clkPort, rstPort, glockPort),
71 sizeParam_(sizeParam), widthParam_(widthParam), guardPort_(guardPort),
72 sepAddrCycleParam_(sacParam) {
73}
74
75
76/**
77 * Copy constructor.
78 *
79 * @param original RFImplementation to copy.
80 */
82 HWBlockImplementation(original) {
83
84 sizeParam_ = original.sizeParam_;
85 widthParam_ = original.widthParam_;
86 guardPort_ = original.guardPort_;
88
89 // Deep copy ports.
90 for (int i = 0; i < original.portCount(); i++) {
92 addPort(p);
93 }
94
95 // Copy parameters.
96 parameters_ = original.parameters_;
97
98 // Deep copy external ports.
99 for (int i = 0; i < original.externalPortCount(); i++) {
100 RFExternalPort* p = new RFExternalPort(original.externalPort(i));
102 }
103
104}
105
106
107/**
108 * The destructor.
109 */
114
115/**
116 * Sets the name of the size parameter.
117 *
118 * @param sizeParam Name of the size parameter.
119 */
120void
121RFImplementation::setSizeParameter(const std::string& sizeParam) {
122 sizeParam_ = sizeParam;
123}
124
125
126/**
127 * Returns the name of the size parameter.
128 *
129 * @return The name of the size parameter.
130 */
131std::string
135
136
137/**
138 * Sets the name of the width parameter.
139 *
140 * @param widthParam Name of the width parameter.
141 */
142void
143RFImplementation::setWidthParameter(const std::string& widthParam) {
144 widthParam_ = widthParam;
145}
146
147
148/**
149 * Returns the name of the width parameter.
150 *
151 * @return The name of the width parameter.
152 */
153std::string
157
158
159/**
160 * Sets the name of the guard port.
161 *
162 * @param guardPort Name of the guard port.
163 */
164void
165RFImplementation::setGuardPort(const std::string& guardPort) {
167}
168
169
170/**
171 * Returns the name of the guard port.
172 *
173 * @return The name of the guard port.
174 */
175std::string
177 return guardPort_;
178}
179
180/**
181 * Sets flag for separate address cycle.
182 *
183 * @param enable Flag value.
184 */
188
189/**
190 * Returns flag for separate address cycle.
191 *
192 * @return The flag value. True if enabled.
193 */
197
198/**
199 * Adds a new port to the RF implementation.
200 *
201 * @param port The port to be added.
202 */
203void
207
208/**
209 * Adds a new external port to the RF implementation.
210 *
211 * @param extPort The external port to be added.
212 */
213void
215 externalPorts_.push_back(extPort);
216}
217
218
219/**
220 * Deletes the given port from the RF implementation.
221 *
222 * @param port The port to delete.
223 * @exception InstanceNotFound If the given port is not in this RF
224 * implementation.
225 */
226void
229 if (!deleted) {
230 throw InstanceNotFound(__FILE__, __LINE__, __func__);
231 }
232}
233
234/**
235 * Deletes the given external port.
236 *
237 * @param port The port to delete.
238 * @exception InstanceNotFound If the given port is not in this RF
239 * implementation.
240 */
241void
244 if (!removed) {
245 throw InstanceNotFound(__FILE__, __LINE__, __func__);
246 }
247}
248
249/**
250 * Returns the number of ports.
251 *
252 * @return The number of ports.
253 */
254int
256 return ports_.size();
257}
258
259
260/**
261 * Returns the number of external ports.
262 *
263 * @return The number of external ports.
264 */
265int
267 return externalPorts_.size();
268
269}
270
271
272/**
273 * Returns the port at the given position.
274 *
275 * @param index The position index.
276 * @return The port.
277 * @exception OutOfRange If the index is negative or not smaller than the
278 * number of ports.
279 */
281RFImplementation::port(int index) const {
282 if (index < 0 || index >= portCount()) {
283 const string procName = "RFImplementation::port";
284 throw OutOfRange(__FILE__, __LINE__, procName);
285 }
286
287 return *ports_[index];
288}
289
290/**
291 * Returns the external port at the given position.
292 *
293 * @param index The position index.
294 * @return The port.
295 * @exception OutOfRange If the given index is negative or not smaller the
296 * number of external ports.
297 */
300 if (index < 0 || index >= externalPortCount()) {
301 const string procName = "RFImplementation::externalPort";
302 throw OutOfRange(__FILE__, __LINE__, procName);
303 }
304
305 return *externalPorts_[index];
306}
307
308/**
309 * Adds the given parameter for the implementation.
310 *
311 * @param name Name of the parameter.
312 * @param type Type of the parameter.
313 * @param value Value of the parameter.
314 * @exception IllegalParameters If the RF implementation contains a
315 * parameter with the same name already.
316 */
317void
319 const std::string& name, const std::string& type,
320 const std::string& value) {
321 if (hasParameter(name)) {
322 throw IllegalParameters(__FILE__, __LINE__, __func__);
323 } else {
324 Parameter param = {name, type, value};
325 parameters_.push_back(param);
326 }
327}
328
329/**
330 * Removes the parameter of the given name.
331 *
332 * @param name Name of the parameter.
333 */
334void
335RFImplementation::removeParameter(const std::string& name) {
336 for (ParameterTable::iterator iter = parameters_.begin();
337 iter != parameters_.end(); iter++) {
338 if (iter->name == name) {
339 parameters_.erase(iter);
340 return;
341 }
342 }
343}
344
345
346/**
347 * Returns the number of parameters.
348 *
349 * @return The number of parameters.
350 */
351int
353 return parameters_.size();
354}
355
356
357/**
358 * Returns a parameter by the given index.
359 *
360 * @param index The index.
361 * @return The parameter.
362 * @exception OutOfRange If the index is negative or not smaller than the
363 * number of parameters.
364 */
367 if (index < 0 || index >= parameterCount()) {
368 throw OutOfRange(__FILE__, __LINE__, __func__);
369 }
370
371 return parameters_[index];
372}
373
374/**
375 * Tells whether the implementation has the given parameter.
376 *
377 * @param name Name of the parameter.
378 * @return True if the implementation has the parameter, otherwise false.
379 */
380bool
381RFImplementation::hasParameter(const std::string& name) const {
382 for (ParameterTable::const_iterator iter = parameters_.begin();
383 iter != parameters_.end(); iter++) {
384 if (iter->name == name) {
385 return true;
386 }
387 }
388 return false;
389}
390
391}
392
393
394
#define __func__
static bool deleteValueIfExists(ContainerType &aContainer, const ElementType &aKey)
RFExternalPort & externalPort(int index) const
ParameterTable parameters_
Contains the parameters.
void addPort(RFPortImplementation *port)
PortTable ports_
Contains the ports.
void addExternalPort(RFExternalPort *extPort)
bool sepAddrCycleParam_
State of separate address cycle parameter.
ExternalPortTable externalPorts_
Contains the external ports.
RFImplementation(const std::string &moduleName, const std::string &clkPort, const std::string &rstPort, const std::string &glockPort, const std::string &sizeParam, const std::string &widthParam, const std::string &guardPort, bool sacParam=false)
void setSizeParameter(const std::string &sizeParam)
std::string guardPort_
Name of the guard port.
RFPortImplementation & port(int index) const
bool separateAddressCycleParameter() const
std::string sizeParameter() const
void removeParameter(const std::string &name)
void deleteExternalPort(RFExternalPort *port)
bool hasParameter(const std::string &name) const
std::string widthParameter() const
std::string sizeParam_
Name of the size parameter.
void setGuardPort(const std::string &guardPort)
std::string guardPort() const
Parameter parameter(int index) const
std::string widthParam_
Name of the width parameter.
void addParameter(const std::string &name, const std::string &type, const std::string &value)
void setSeparateAddressCycleParameter(bool enable)
void setWidthParameter(const std::string &widthParam)
void deletePort(RFPortImplementation *port)
static void deleteAllItems(SequenceType &aSequence)