OpenASIP 2.2
Loading...
Searching...
No Matches
ICDecoderGeneratorPlugin.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 ICDecoderGeneratorPlugin.cc
26 *
27 * Implementation of ICDecoderGeneratorPlugin class.
28 *
29 * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30 * @author Vinogradov Viacheslav(added Verilog generating) 2012
31 * @note rating: red
32 */
33
34#include <string>
35
37#include "MapTools.hh"
38
39using std::string;
40
41namespace ProGe {
42
43/**
44 * Constructor.
45 *
46 * @param machine The machine to generate the IC&decoder for.
47 */
50 const BinaryEncoding& bem,
51 const std::string& description) :
52 machine_(machine), bem_(bem), description_(description) {
53
54}
55
56
57/**
58 * Destructor.
59 */
62
63
64/**
65 * Returns the description of the plugin.
66 *
67 * @return The description.
68 */
69std::string
73
74
75/**
76 * Returns the number of recognized parameters.
77 *
78 * @return The number of recognized parameters.
79 */
80int
84
85
86/**
87 * Returns the name of a recognized parameter by the given index.
88 *
89 * @param index The index.
90 * @return The name of the parameter.
91 * @exception OutOfRange If the given index is negative or not smaller than
92 * the number of recognized parameters.
93 */
94std::string
96 if (index < 0 || index >= recognizedParameterCount()) {
97 throw OutOfRange(__FILE__, __LINE__, __func__);
98 }
99
100 int i = 0;
101 for (StringMap::const_iterator iter = parameterDescriptions_.begin();
102 iter != parameterDescriptions_.end(); iter++) {
103 if (i == index) {
104 return iter->first;
105 }
106 i++;
107 }
108
109 assert(false);
110 return "";
111}
112
113/**
114 * Returns the description of the given parameter.
115 *
116 * @param paramName Name of the parameter.
117 * @return The description of the parameter.
118 * @exception IllegalParameter If the given parameter is unrecognized.
119 */
120std::string
122 const std::string& paramName) const {
123 try {
125 parameterDescriptions_, paramName);
126 } catch (const KeyNotFound& e) {
127 throw IllegalParameters(
128 __FILE__, __LINE__, __func__, e.errorMessage());
129 }
130}
131
132/**
133 * Sets the given parameter for the plugin.
134 *
135 * @param name Name of the parameter.
136 * @param value Value of the parameter.
137 * @exception IllegalParameter If the given parameter is unrecognized.
138 */
139void
141 const std::string& name, const std::string& value) {
143 string errorMsg = "Unrecognized IC/decoder plugin parameter: " +
144 name;
145 throw IllegalParameters(__FILE__, __LINE__, __func__, errorMsg);
146 }
147
148 parameterValues_.erase(name);
149 parameterValues_.insert(std::pair<string, string>(name, value));
150}
151
152/**
153 * Adds the given parameter to the set of recognized parameters.
154 *
155 * @param name Name of the parameter.
156 * @param description Description of the parameter.
157 */
158void
160 const std::string& name,
161 const std::string& description) {
162
163 parameterDescriptions_.erase(name);
165 std::pair<string, string>(name, description));
166}
167
168
169/**
170 * Tells whether the plugin has the given parameter set.
171 *
172 * @param name Name of the parameter.
173 * @return True if the given parameter is set, otherwise false.
174 */
175bool
176ICDecoderGeneratorPlugin::hasParameterSet(const std::string& name) const {
178}
179
180
181/**
182 * Returns the value of the given parameter.
183 *
184 * @param name Name of the parameter.
185 * @return Value of the parameter.
186 * @exception KeyNotFound If the given parameter is not set.
187 */
188std::string
189ICDecoderGeneratorPlugin::parameterValue(const std::string& name) const {
190 if (!hasParameterSet(name)) {
191 throw KeyNotFound(__FILE__, __LINE__, __func__);
192 }
193
195}
196
197/**
198 * Returns the machine.
199 *
200 * @return The machine.
201 */
206
207
208/**
209 * Returns the binary encoding map.
210 *
211 * @return The binary encoding map.
212 */
213const BinaryEncoding&
215 return bem_;
216}
217}
#define __func__
#define assert(condition)
TTAMachine::Machine * machine
the architecture definition of the estimated processor
std::string errorMessage() const
Definition Exception.cc:123
static KeyType keyForValue(const MapType &aMap, const ValueType &aValue)
static bool containsKey(const MapType &aMap, const KeyType &aKey)
void addParameter(const std::string &name, const std::string &description)
const BinaryEncoding & bem() const
const BinaryEncoding & bem_
The binary encoding map.
std::string parameterValue(const std::string &name) const
std::string recognizedParameter(int index) const
bool hasParameterSet(const std::string &name) const
std::string description_
Description of the plugin.
StringMap parameterDescriptions_
Parameter descriptions.
const TTAMachine::Machine & machine() const
ICDecoderGeneratorPlugin(const TTAMachine::Machine &machine, const BinaryEncoding &bem, const std::string &description)
std::string parameterDescription(const std::string &paramName) const
const TTAMachine::Machine & machine_
The machine to generate.
void setParameter(const std::string &name, const std::string &value)
Definition FUGen.hh:54