OpenASIP  2.0
CentralizedControlICGenerator.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 CentralizedControlICGenerator.cc
26  *
27  * Implementation of CentralizedControlICGenerator class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
34 #include "NetlistPort.hh"
35 #include "MapTools.hh"
36 #include "Application.hh"
37 
38 using namespace ProGe;
39 using namespace TTAMachine;
40 
41 /**
42  * The constructor.
43  */
45  glockPort_(0) {
46 }
47 
48 
49 /**
50  * The destructor.
51  */
53 }
54 
55 
56 /**
57  * Returns the short immediate data port for the given bus.
58  *
59  * @param busName Name of the bus.
60  * @return The netlist port that was added by the IC generator.
61  * @exception InstanceNotFound If the port was not created.
62  */
64 CentralizedControlICGenerator::simmDataPort(const std::string& busName) const {
65  try {
66  return *MapTools::valueForKey<NetlistPort*>(
67  simmDataPortMap_, busName);
68  } catch (const Exception&) {
69  throw InstanceNotFound(__FILE__, __LINE__, __func__);
70  }
71 }
72 
73 /**
74  * Returns the short immediate control port for the given bus.
75  *
76  * @param busName Name of the bus.
77  * @return The netlist port that was added by the IC generator.
78  * @exception InstanceNotFound If the port was not created.
79  */
81 CentralizedControlICGenerator::simmCntrlPort(const std::string& busName) const {
82  try {
83  return *MapTools::valueForKey<NetlistPort*>(
84  simmCntrlPortMap_, busName);
85  } catch (const Exception&) {
86  throw InstanceNotFound(__FILE__, __LINE__, __func__);
87  }
88 }
89 
90 /**
91  * Returns the bus control port of the given socket in the IC block.
92  *
93  * @param socketName Name of the socket.
94  * @return The netlist port that was added by the IC generator.
95  * @exception InstanceNotFound If the port was not created.
96  */
99  const std::string& socketName) const {
100  try {
101  return *MapTools::valueForKey<NetlistPort*>(busCntrlPortMap_, socketName);
102  } catch (const Exception&) {
103  throw InstanceNotFound(__FILE__, __LINE__, __func__);
104  }
105 }
106 
107 /**
108  * Returns the data control port of the given socket in the IC block.
109  *
110  * @param socketName Name of the socket.
111  * @return The netlist port that was added by the IC generator.
112  * @exception InstanceNotFound If the port was not created.
113  */
116  const std::string& socketName) const {
117  try {
118  return *MapTools::valueForKey<NetlistPort*>(dataCntrlPortMap_, socketName);
119  } catch (const Exception&) {
120  throw InstanceNotFound(__FILE__, __LINE__, __func__);
121  }
122 }
123 
124 /**
125  * Returns true if IC has glock port.
126  */
127 bool
129  return (glockPort_ != 0);
130 }
131 
132 
133 /**
134  * Returns reference to NetlistPort of glock.
135  *
136  * @exception InstanceNotFound If IC does not have glock port.
137  */
140  if (!hasGlockPort()) {
141  throw InstanceNotFound(__FILE__, __LINE__, __func__,
142  "IC does not have glock port.");
143  } else {
144  return *glockPort_;
145  }
146 }
147 
148 /**
149  * Maps the given netlist port as the short immediate data port of the
150  * given bus.
151  *
152  * @param busName The bus.
153  * @param port The netlist port.
154  */
155 void
157  const std::string& busName,
158  ProGe::NetlistPort& port) {
159 
161  simmDataPortMap_.insert(
162  std::pair<std::string, NetlistPort*>(busName, &port));
163 }
164 
165 
166 /**
167  * Maps the given netlist port as the short immediate control port of the
168  * given bus.
169  *
170  * @param busName The bus.
171  * @param port The netlist port.
172  */
173 void
175  const std::string& busName,
176  ProGe::NetlistPort& port) {
177 
179  simmCntrlPortMap_.insert(
180  std::pair<std::string, NetlistPort*>(busName, &port));
181 }
182 
183 
184 /**
185  * Maps the given bus control port for the given socket.
186  *
187  * @param socketName Name of the socket.
188  * @param port The netlist port.
189  */
190 void
192  const std::string& socketName,
193  ProGe::NetlistPort& port) {
194 
196  busCntrlPortMap_.insert(
197  std::pair<std::string, NetlistPort*>(socketName, &port));
198 }
199 
200 
201 /**
202  * Maps the given data control port for the given socket.
203  *
204  * @param socketName Name of the socket.
205  * @param port The netlist port.
206  */
207 void
209  const std::string& socketName,
210  ProGe::NetlistPort& port) {
211 
213  dataCntrlPortMap_.insert(
214  std::pair<std::string, NetlistPort*>(socketName, &port));
215 }
216 
217 
218 /**
219  * Sets optional glock port of IC.
220  *
221  * @param glockPort The glock port.
222  */
223 void
225  assert(glockPort_ == 0);
227 }
228 
CentralizedControlICGenerator::busCntrlPortOfSocket
ProGe::NetlistPort & busCntrlPortOfSocket(const std::string &socketName) const
Definition: CentralizedControlICGenerator.cc:98
CentralizedControlICGenerator::simmCntrlPortMap_
NetlistPortMap simmCntrlPortMap_
Maps the short immediate control ports for buses.
Definition: CentralizedControlICGenerator.hh:95
CentralizedControlICGenerator::simmDataPortMap_
NetlistPortMap simmDataPortMap_
Maps the short immediate data ports for buses.
Definition: CentralizedControlICGenerator.hh:93
CentralizedControlICGenerator::glockPort_
ProGe::NetlistPort * glockPort_
(optional) Glock port
Definition: CentralizedControlICGenerator.hh:103
CentralizedControlICGenerator::CentralizedControlICGenerator
CentralizedControlICGenerator()
Definition: CentralizedControlICGenerator.cc:44
CentralizedControlICGenerator::simmCntrlPort
ProGe::NetlistPort & simmCntrlPort(const std::string &busName) const
Definition: CentralizedControlICGenerator.cc:81
MapTools.hh
CentralizedControlICGenerator::mapDataCntrlPortOfSocket
void mapDataCntrlPortOfSocket(const std::string &socketName, ProGe::NetlistPort &port)
Definition: CentralizedControlICGenerator.cc:208
CentralizedControlICGenerator::~CentralizedControlICGenerator
virtual ~CentralizedControlICGenerator()
Definition: CentralizedControlICGenerator.cc:52
assert
#define assert(condition)
Definition: Application.hh:86
CentralizedControlICGenerator::simmDataPort
ProGe::NetlistPort & simmDataPort(const std::string &busName) const
Definition: CentralizedControlICGenerator.cc:64
CentralizedControlICGenerator::mapBusCntrlPortOfSocket
void mapBusCntrlPortOfSocket(const std::string &socketName, ProGe::NetlistPort &port)
Definition: CentralizedControlICGenerator.cc:191
CentralizedControlICGenerator::dataCntrlPortMap_
NetlistPortMap dataCntrlPortMap_
Maps the data control ports of sockets.
Definition: CentralizedControlICGenerator.hh:101
NetlistPort.hh
CentralizedControlICGenerator.hh
Application.hh
__func__
#define __func__
Definition: Application.hh:67
Exception
Definition: Exception.hh:54
CentralizedControlICGenerator::busCntrlPortMap_
NetlistPortMap busCntrlPortMap_
Maps the bus control ports of sockets.
Definition: CentralizedControlICGenerator.hh:99
CentralizedControlICGenerator::setGlockPort
void setGlockPort(ProGe::NetlistPort &glockPort)
Definition: CentralizedControlICGenerator.cc:224
MapTools::containsKey
static bool containsKey(const MapType &aMap, const KeyType &aKey)
CentralizedControlICGenerator::mapSImmDataPort
void mapSImmDataPort(const std::string &busName, ProGe::NetlistPort &port)
Definition: CentralizedControlICGenerator.cc:156
ProGe
Definition: FUGen.hh:54
CentralizedControlICGenerator::glockPort
ProGe::NetlistPort & glockPort() const
Definition: CentralizedControlICGenerator.cc:139
ProGe::NetlistPort
Definition: NetlistPort.hh:70
CentralizedControlICGenerator::mapSImmCntrlPort
void mapSImmCntrlPort(const std::string &busName, ProGe::NetlistPort &port)
Definition: CentralizedControlICGenerator.cc:174
TTAMachine
Definition: Assembler.hh:48
CentralizedControlICGenerator::hasGlockPort
bool hasGlockPort() const
Definition: CentralizedControlICGenerator.cc:128
CentralizedControlICGenerator::dataCntrlPortOfSocket
ProGe::NetlistPort & dataCntrlPortOfSocket(const std::string &socketName) const
Definition: CentralizedControlICGenerator.cc:115
InstanceNotFound
Definition: Exception.hh:304