OpenASIP  2.0
IPXactHibiInterface.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2011 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 IPXactHibiInterface.cc
26  *
27  * Implementation of IPXactHibiInterface class.
28  *
29  * @author Otto Esko 2011 (otto.esko-no.spam-tut.fi)
30  * @note rating: red
31  */
32 #include <vector>
33 #include "IPXactHibiInterface.hh"
34 #include "StringTools.hh"
35 #include "NetlistPort.hh"
36 using std::pair;
37 using ProGe::NetlistPort;
38 
41 const TCEString IPXactHibiInterface::LIBRARY ="ip.hwp.communication";
42 const TCEString IPXactHibiInterface::NAME ="hibi_ip_r4.busdef";
48 const TCEString IPXactHibiInterface::ABS_NAME = "hibi_ip_r4.absdef";
51 
54 
56  IPXactInterface(), interfaceSearch_() {
57 
61 
63 
64  interfaceSearch_.push_back(
65  new pair<TCEString,TCEString>("hibi_comm_out", "COMM_FROM_IP"));
66  interfaceSearch_.push_back(
67  new pair<TCEString,TCEString>("hibi_data_out", "DATA_FROM_IP"));
68  interfaceSearch_.push_back(
69  new pair<TCEString,TCEString>("hibi_av_out", "AV_FROM_IP"));
70  interfaceSearch_. push_back(
71  new pair<TCEString,TCEString>("hibi_we_out", "WE_FROM_IP"));
72  interfaceSearch_.push_back(
73  new pair<TCEString,TCEString>("hibi_re_out", "RE_FROM_IP"));
74  interfaceSearch_.push_back(
75  new pair<TCEString,TCEString>("hibi_comm_in", "COMM_TO_IP"));
76  interfaceSearch_.push_back(
77  new pair<TCEString,TCEString>("hibi_data_in", "DATA_TO_IP"));
78  interfaceSearch_.push_back(
79  new pair<TCEString,TCEString>("hibi_av_in", "AV_TO_IP"));
80  interfaceSearch_. push_back(
81  new pair<TCEString,TCEString>("hibi_full_in", "FULL_TO_IP"));
82  interfaceSearch_.push_back(
83  new pair<TCEString,TCEString>("hibi_empty_in", "EMPTY_TO_IP"));
84 }
85 
87 
88  for (unsigned int i = 0; i < interfaceSearch_.size(); i++) {
89  delete interfaceSearch_.at(i);
90  }
91 }
92 
93 bool
95  const ProGe::NetlistBlock& toplevel) {
96 
97  bool instanceNameSet = false;
98  for (unsigned int i = 0; i < interfaceSearch_.size(); i++) {
99  for (size_t j = 0; j < toplevel.portCount(); j++) {
100  TCEString interfacePort = interfaceSearch_.at(i)->first;
101  const NetlistPort& port = toplevel.port(j);
102  if (port.name().find(interfacePort) != TCEString::npos) {
103  TCEString abstractPort = interfaceSearch_.at(i)->second;
104  addSignalMapping(port.name(), abstractPort);
105  if (!instanceNameSet) {
106  createInstanceName(port.name(), interfacePort);
107  instanceNameSet = true;
108  }
109  break;
110  }
111  }
112  if (interfaceMapping().size() == 0) {
113  // does not contain this interface
114  return false;
115  }
116  }
117  bool foundAllPorts = false;
118  if (interfaceSearch_.size() == interfaceMapping().size()) {
119  foundAllPorts = true;
120  }
121  return foundAllPorts;
122 }
123 
124 void
126  const TCEString& fullName,
127  const TCEString& portName) {
128 
129  TCEString fu = "";
130  TCEString::size_type pos = fullName.find(portName);
131  if (pos == TCEString::npos || pos == 0) {
132  fu = fullName;
133  } else {
134  fu = StringTools::trim(fullName.substr(0, pos));
135  }
136  TCEString instance = fu + DEFAULT_INSTANCE_NAME;
137  setInstanceName(instance);
138 }
IPXactHibiInterface::ABS_LIBRARY
static const TCEString ABS_LIBRARY
Definition: IPXactHibiInterface.hh:61
IPXactInterface::setInstanceName
void setInstanceName(const TCEString &name)
Definition: IPXactInterface.cc:89
IPXactHibiInterface::BUS_VERSION
static const TCEString BUS_VERSION
Definition: IPXactHibiInterface.hh:59
ProGe::NetlistBlock
Definition: NetlistBlock.hh:61
IPXactHibiInterface::LIBRARY
static const TCEString LIBRARY
Definition: IPXactHibiInterface.hh:57
IPXactInterface::addSignalMapping
virtual void addSignalMapping(const TCEString &actualSignal, const TCEString &busSignal)
Definition: IPXactInterface.cc:79
IPXactHibiInterface::NAME
static const TCEString NAME
Definition: IPXactHibiInterface.hh:58
IPXactHibiInterface::interfaceSearch_
PlatInt::SignalMappingList interfaceSearch_
Mapping of known port names and interface port names.
Definition: IPXactHibiInterface.hh:53
IPXactHibiInterface::DEFAULT_INSTANCE_NAME
static const TCEString DEFAULT_INSTANCE_NAME
Definition: IPXactHibiInterface.hh:55
IPXactHibiInterface::DEFAULT_BUS_MODE
static const IPXactModel::BusMode DEFAULT_BUS_MODE
Definition: IPXactHibiInterface.hh:65
ProGe::NetlistBlock::portCount
virtual size_t portCount() const
Definition: BaseNetlistBlock.cc:248
IPXactHibiInterface::VENDOR
static const TCEString VENDOR
Definition: IPXactHibiInterface.hh:56
StringTools.hh
IPXactInterface::setBusMode
void setBusMode(IPXactModel::BusMode mode)
Definition: IPXactInterface.cc:95
IPXactInterface
Definition: IPXactInterface.hh:41
IPXactModel::BusMode
BusMode
Definition: IPXactModel.hh:50
IPXactHibiInterface.hh
NetlistPort.hh
IPXactHibiInterface::mapPortsToInterface
virtual bool mapPortsToInterface(const ProGe::NetlistBlock &toplevel)
Definition: IPXactHibiInterface.cc:94
IPXactHibiInterface::createInstanceName
void createInstanceName(const TCEString &fullName, const TCEString &portName)
Definition: IPXactHibiInterface.cc:125
IPXactInterface::setBusType
void setBusType(const TCEString &vendor, const TCEString &library, const TCEString &name, const TCEString &version)
Definition: IPXactInterface.cc:101
ProGe::NetlistPort::name
std::string name() const
Definition: NetlistPort.cc:283
IPXactHibiInterface::IPXactHibiInterface
IPXactHibiInterface()
Definition: IPXactHibiInterface.cc:55
StringTools::trim
static std::string trim(const std::string &source)
Definition: StringTools.cc:55
TCEString
Definition: TCEString.hh:53
IPXactInterface::interfaceMapping
virtual const PlatInt::SignalMappingList & interfaceMapping() const
Definition: IPXactInterface.cc:73
ProGe::NetlistPort
Definition: NetlistPort.hh:70
IPXactHibiInterface::~IPXactHibiInterface
virtual ~IPXactHibiInterface()
Definition: IPXactHibiInterface.cc:86
IPXactInterface::setBusAbsType
void setBusAbsType(const TCEString &vendor, const TCEString &library, const TCEString &name, const TCEString &version)
Definition: IPXactInterface.cc:114
ProGe::NetlistBlock::port
virtual NetlistPort * port(const std::string &portName, bool partialMatch=true)
Definition: NetlistBlock.cc:97
IPXactModel::MASTER
@ MASTER
Definition: IPXactModel.hh:52
IPXactHibiInterface::ABS_NAME
static const TCEString ABS_NAME
Definition: IPXactHibiInterface.hh:62
IPXactHibiInterface::ABS_VERSION
static const TCEString ABS_VERSION
Definition: IPXactHibiInterface.hh:63
IPXactHibiInterface::ABS_VENDOR
static const TCEString ABS_VENDOR
Definition: IPXactHibiInterface.hh:60