OpenASIP 2.2
Loading...
Searching...
No Matches
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>
34#include "StringTools.hh"
35#include "NetlistPort.hh"
36using std::pair;
38
41const TCEString IPXactHibiInterface::LIBRARY ="ip.hwp.communication";
42const TCEString IPXactHibiInterface::NAME ="hibi_ip_r4.busdef";
48const 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
93bool
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
124void
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}
static const TCEString BUS_VERSION
PlatInt::SignalMappingList interfaceSearch_
Mapping of known port names and interface port names.
static const TCEString NAME
static const IPXactModel::BusMode DEFAULT_BUS_MODE
static const TCEString LIBRARY
virtual bool mapPortsToInterface(const ProGe::NetlistBlock &toplevel)
void createInstanceName(const TCEString &fullName, const TCEString &portName)
static const TCEString ABS_LIBRARY
static const TCEString VENDOR
static const TCEString DEFAULT_INSTANCE_NAME
static const TCEString ABS_VERSION
static const TCEString ABS_NAME
static const TCEString ABS_VENDOR
void setBusMode(IPXactModel::BusMode mode)
virtual const PlatInt::SignalMappingList & interfaceMapping() const
virtual void addSignalMapping(const TCEString &actualSignal, const TCEString &busSignal)
void setBusType(const TCEString &vendor, const TCEString &library, const TCEString &name, const TCEString &version)
void setInstanceName(const TCEString &name)
void setBusAbsType(const TCEString &vendor, const TCEString &library, const TCEString &name, const TCEString &version)
virtual NetlistPort * port(const std::string &portName, bool partialMatch=true)
virtual size_t portCount() const
std::string name() const
static std::string trim(const std::string &source)