OpenASIP  2.0
IPXactFileGenerator.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 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 IPXactFileGenerator.hh
26  *
27  * Implementation of IPXactFileGenerator class.
28  *
29  * @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
30  * @note rating: red
31  */
32 #include <string>
33 #include <vector>
34 #include "PlatformIntegrator.hh"
35 #include "NetlistBlock.hh"
36 #include "NetlistPort.hh"
37 #include "IPXactFileGenerator.hh"
38 #include "IPXactSerializer.hh"
39 #include "IPXactModel.hh"
40 #include "HDLPort.hh"
41 #include "IPXactInterface.hh"
42 #include "IPXactHibiInterface.hh"
43 #include "IPXactClkInterface.hh"
44 #include "IPXactResetInterface.hh"
45 #include "IPXactAddressSpace.hh"
46 #include "AddressSpace.hh"
47 #include "Machine.hh"
49 using ProGe::NetlistPort;
50 using std::pair;
51 
52 const TCEString DEF_VENDOR = "TCE";
53 const TCEString DEF_LIBRARY = "ip.hwp.tta";
54 const TCEString DEF_VERSION = "1.0";
55 
56 
58  TCEString toplevelEntity,
59  const PlatformIntegrator* integrator):
60  ProjectFileGenerator(toplevelEntity, integrator),
61  ipXactWriter_(new IPXactSerializer()) {
62 
63 }
64 
66 
67  delete ipXactWriter_;
68 }
69 
70 
71 void
73 
74  IPXactModel* ip = new IPXactModel();
76 
77  const ProGe::NetlistBlock& toplevel = integrator()->toplevelBlock();
78  for (size_t i = 0; i < toplevel.portCount(); i++) {
79  HDLPort port(toplevel.port(i));
80  ip->addSignal(port);
81  }
82 
83  for (size_t i = 0; i < toplevel.parameterCount(); i++) {
84  ip->addParameter(toplevel.parameter(i));
85  }
86 
87  addBusInterfaces(ip);
88 
89  addAddressSpaces(ip);
90 
91  ip->setHdlFiles(hdlFileList());
92  for (unsigned int i = 0; i < memInitFileList().size(); i++) {
93  ip->setFile(memInitFileList().at(i));
94  }
95 
98  delete ip;
99 }
100 
101 void
103 
104  std::vector<IPXactInterface*> interfaces;
105  interfaces.push_back(new IPXactClkInterface());
106  interfaces.push_back(new IPXactResetInterface());
107  interfaces.push_back(new IPXactHibiInterface());
108 
109 
110  const NetlistBlock& toplevel = integrator()->toplevelBlock();
111  for (unsigned int i = 0; i < interfaces.size(); i++) {
112  if (interfaces.at(i)->mapPortsToInterface(toplevel)) {
113  // mapping was successful, add interface
114  model->addBusInterface(interfaces.at(i));
115  } else {
116  delete interfaces.at(i);
117  interfaces.at(i) = NULL;
118  }
119  }
120 }
121 
122 
123 void
125 
126  IPXactAddressSpace* imemAs =
127  new IPXactAddressSpace(integrator()->imemInfo());
128  model->addAddressSpace(imemAs);
129 
130  for (int i = 0; i < integrator()->dmemCount(); i++) {
131  IPXactAddressSpace* dmemAs =
132  new IPXactAddressSpace(integrator()->dmemInfo(i));
133  model->addAddressSpace(dmemAs);
134  }
135 }
136 
137 
138 TCEString
140 
141  return "spirit_comp_def_" + toplevelEntity() + ".xml";
142 }
ProjectFileGenerator::integrator
const PlatformIntegrator * integrator() const
Definition: ProjectFileGenerator.cc:101
IPXactClkInterface
Definition: IPXactClkInterface.hh:37
ProGe::NetlistBlock
Definition: NetlistBlock.hh:61
IPXactAddressSpace.hh
DEF_VERSION
const TCEString DEF_VERSION
Definition: IPXactFileGenerator.cc:54
ProjectFileGenerator::toplevelEntity
TCEString toplevelEntity() const
Definition: ProjectFileGenerator.hh:66
HDLPort
Definition: PlatformIntegrator/HDLPort.hh:48
ProGe::BaseNetlistBlock::parameterCount
virtual size_t parameterCount() const
Definition: BaseNetlistBlock.cc:231
IPXactSerializer.hh
DEF_LIBRARY
const TCEString DEF_LIBRARY
Definition: IPXactFileGenerator.cc:53
AddressSpace.hh
IPXactModel
Definition: IPXactModel.hh:47
IPXactClkInterface.hh
ProGe::NetlistBlock::portCount
virtual size_t portCount() const
Definition: BaseNetlistBlock.cc:248
IPXactHibiInterface
Definition: IPXactHibiInterface.hh:38
PlatformIntegrator::dmemCount
int dmemCount() const
Definition: PlatformIntegrator.cc:685
IPXactFileGenerator::addBusInterfaces
void addBusInterfaces(IPXactModel *model)
Definition: IPXactFileGenerator.cc:102
ProjectFileGenerator::memInitFileList
const std::vector< TCEString > & memInitFileList() const
Definition: ProjectFileGenerator.cc:94
IPXactFileGenerator::addAddressSpaces
void addAddressSpaces(IPXactModel *model)
Definition: IPXactFileGenerator.cc:124
IPXactSerializer::writeIPXactModel
void writeIPXactModel(const IPXactModel &model)
Definition: IPXactSerializer.cc:56
IPXactFileGenerator::writeProjectFiles
virtual void writeProjectFiles()
Definition: IPXactFileGenerator.cc:72
ProjectFileGenerator
Definition: ProjectFileGenerator.hh:41
IPXactResetInterface.hh
IPXactHibiInterface.hh
NetlistPort.hh
IPXactModel::addAddressSpace
void addAddressSpace(IPXactAddressSpace *addrSpace)
Definition: IPXactModel.cc:307
IPXactModel::setFile
void setFile(const TCEString &file)
Definition: IPXactModel.cc:274
IPXactModel.hh
XMLSerializer::setDestinationFile
void setDestinationFile(const std::string &fileName)
Definition: XMLSerializer.cc:142
NetlistBlock.hh
DEF_VENDOR
const TCEString DEF_VENDOR
Definition: IPXactFileGenerator.cc:52
IPXactAddressSpace
Definition: IPXactAddressSpace.hh:38
HDLPort.hh
IPXactModel::addParameter
void addParameter(const ProGe::Parameter &parameter)
Definition: IPXactModel.cc:296
Machine.hh
PlatformIntegrator::toplevelBlock
const ProGe::NetlistBlock & toplevelBlock() const
Definition: PlatformIntegrator.cc:537
IPXactFileGenerator::outputFileName
TCEString outputFileName() const
Definition: IPXactFileGenerator.cc:139
IPXactFileGenerator::ipXactWriter_
IPXactSerializer * ipXactWriter_
Definition: IPXactFileGenerator.hh:61
IPXactSerializer
Definition: IPXactSerializer.hh:40
IPXactModel::setHdlFiles
void setHdlFiles(const std::vector< TCEString > &files)
Definition: IPXactModel.cc:281
IPXactFileGenerator::IPXactFileGenerator
IPXactFileGenerator(TCEString toplevelEntity, const PlatformIntegrator *integrator)
Definition: IPXactFileGenerator.cc:57
TCEString
Definition: TCEString.hh:53
PlatformIntegrator.hh
ProGe::NetlistPort
Definition: NetlistPort.hh:70
ProjectFileGenerator::hdlFileList
const std::vector< TCEString > & hdlFileList() const
Definition: ProjectFileGenerator.cc:87
PlatformIntegrator
Definition: PlatformIntegrator.hh:65
IPXactResetInterface
Definition: IPXactResetInterface.hh:37
IPXactModel::addBusInterface
void addBusInterface(IPXactInterface *interface)
Definition: IPXactModel.cc:301
IPXactFileGenerator.hh
IPXactModel::addSignal
void addSignal(const HDLPort &signal)
Definition: IPXactModel.cc:290
ProGe::NetlistBlock::parameter
virtual const Parameter & parameter(const std::string &name) const
Definition: BaseNetlistBlock.cc:198
ProGe::NetlistBlock::port
virtual NetlistPort * port(const std::string &portName, bool partialMatch=true)
Definition: NetlistBlock.cc:97
IPXactFileGenerator::~IPXactFileGenerator
virtual ~IPXactFileGenerator()
Definition: IPXactFileGenerator.cc:65
IPXactInterface.hh
IPXactModel::setVLNV
void setVLNV(TCEString vendor, TCEString library, TCEString name, TCEString version)
Definition: IPXactModel.cc:254