OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SOPCBuilderFileGenerator Class Reference

#include <SOPCBuilderFileGenerator.hh>

Inheritance diagram for SOPCBuilderFileGenerator:
Inheritance graph
Collaboration diagram for SOPCBuilderFileGenerator:
Collaboration graph

Public Member Functions

 SOPCBuilderFileGenerator (TCEString toplevelEntity, const PlatformIntegrator *integrator)
 
virtual ~SOPCBuilderFileGenerator ()
 
virtual void writeProjectFiles ()
 
- Public Member Functions inherited from ProjectFileGenerator
 ProjectFileGenerator (TCEString coreEntity, const PlatformIntegrator *integrator)
 
virtual ~ProjectFileGenerator ()
 
void addHdlFile (const TCEString &file)
 
void addHdlFiles (const std::vector< TCEString > &files)
 
void addMemInitFile (const TCEString &memInit)
 
void addSignalMapping (const PlatInt::SignalMapping &mapping)
 

Private Member Functions

int countAvalonMMMasters () const
 
void createInterfaces ()
 
bool handleAvalonSignal (const ProGe::NetlistPort &port)
 
void exportSignal (const ProGe::NetlistPort &port)
 
void writeModuleProperties (std::ostream &stream)
 
void writeGenerics (std::ostream &stream)
 
void writeFileList (std::ostream &stream)
 
void writeInterfaces (std::ostream &stream) const
 
AvalonMMMasterInterfacegetMaster (const TCEString &fuName)
 

Private Attributes

SOPCInterfaceclock_
 
SOPCInterfaceexport_
 
std::map< TCEString, AvalonMMMasterInterface * > masters_
 

Static Private Attributes

static const TCEString HDB_AVALON_PREFIX = "avalon_d_"
 
static const TCEString SOPC_COMPONENT_FILE_TYPE
 
static const TCEString TTA_CLOCK_NAME = "clk"
 
static const TCEString TTA_RESET_NAME = "rstx"
 
static const TCEString SOPC_CLOCK_NAME = "clk"
 
static const TCEString SOPC_RESET_NAME = "reset_n"
 
static const TCEString SOPC_DEFAULT_GROUP = "User Logic"
 
static const TCEString SOPC_DEFAULT_VHDL_LIBS
 
static const TCEString SOPC_SET_MODULE_PROPERTY
 
static const TCEString SOPC_ADD_FILE
 
static const TCEString PI_DEVICE_FAMILY_GENERIC
 

Additional Inherited Members

- Protected Member Functions inherited from ProjectFileGenerator
const std::vector< TCEString > & hdlFileList () const
 
const std::vector< TCEString > & memInitFileList () const
 
const PlatformIntegratorintegrator () const
 
TCEString coreEntity () const
 
TCEString toplevelEntity () const
 
int signalMappingCount () const
 
const PlatInt::SignalMappingsignalMapping (int index) const
 
TCEString extractFUName (const TCEString &port, const TCEString &delimiter) const
 

Detailed Description

Definition at line 45 of file SOPCBuilderFileGenerator.hh.

Constructor & Destructor Documentation

◆ SOPCBuilderFileGenerator()

SOPCBuilderFileGenerator::SOPCBuilderFileGenerator ( TCEString  toplevelEntity,
const PlatformIntegrator integrator 
)

Definition at line 70 of file SOPCBuilderFileGenerator.cc.

72 :
80
81 clock_->setProperty("ptfSchematicName", "\"\"");
84
87}
const PlatformIntegrator * integrator() const
TCEString toplevelEntity() const
static const TCEString TTA_RESET_NAME
static const TCEString SOPC_CLOCK_NAME
static const TCEString TTA_CLOCK_NAME
static const TCEString SOPC_RESET_NAME
static const TCEString SOPC_CLOCK_INT_NAME
TCEString name() const
static const TCEString SOPC_EXPORT_INT_NAME
static const TCEString SOPC_EXPORT_INT_DECLR
void setPort(const TCEString &hdlName, const TCEString &interfaceName, ProGe::Direction direction, int width)
static const TCEString SOPC_ASSOCIATED_CLOCK
void setProperty(const TCEString &propertyName, const TCEString &propertyValue)
static const TCEString SOPC_CLOCK_INT_DECLR
@ IN
Input port.
Definition ProGeTypes.hh:53

References clock_, export_, ProGe::IN, SOPCInterface::name(), SOPCInterface::setPort(), SOPCInterface::setProperty(), SOPCInterface::SOPC_ASSOCIATED_CLOCK, SOPC_CLOCK_NAME, SOPC_RESET_NAME, TTA_CLOCK_NAME, and TTA_RESET_NAME.

Here is the call graph for this function:

◆ ~SOPCBuilderFileGenerator()

SOPCBuilderFileGenerator::~SOPCBuilderFileGenerator ( )
virtual

Definition at line 90 of file SOPCBuilderFileGenerator.cc.

90 {
91
92 if (clock_ != NULL) {
93 delete clock_;
94 }
95 if (export_ != NULL) {
96 delete export_;
97 }
99}
static void deleteAllValues(MapType &aMap)
std::map< TCEString, AvalonMMMasterInterface * > masters_

References clock_, MapTools::deleteAllValues(), export_, and masters_.

Here is the call graph for this function:

Member Function Documentation

◆ countAvalonMMMasters()

int SOPCBuilderFileGenerator::countAvalonMMMasters ( ) const
private

Counts how many Avalon MM Master interfaces toplevel netlis block has.

Avalon MM interface is recognised by the address port. Address signal in first of the 2 mandatory signals in Avalon MM interface. Direction of the address port determines whether it belongs to a master or slave interface.

Returns
Number of found Avalon MM Master interfaces

Definition at line 147 of file SOPCBuilderFileGenerator.cc.

147 {
148
150 TCEString addressPortName =
152 int found = 0;
153 for (size_t i = 0; i < top.portCount(); i++) {
154 TCEString portName = top.port(i).name();
155 if (portName.find(addressPortName) != TCEString::npos) {
156 if (top.port(i).direction() == ProGe::OUT) {
157 found++;
158 }
159 }
160 }
161 return found;
162}
static const TCEString AVALON_MM_ADDRESS
const ProGe::NetlistBlock & toplevelBlock() const
virtual NetlistPort * port(const std::string &portName, bool partialMatch=true)
virtual size_t portCount() const
Direction direction() const
std::string name() const
static const TCEString HDB_AVALON_PREFIX
@ OUT
Output port.
Definition ProGeTypes.hh:54

References AvalonMMMasterInterface::AVALON_MM_ADDRESS, ProGe::NetlistPort::direction(), HDB_AVALON_PREFIX, ProjectFileGenerator::integrator(), ProGe::NetlistPort::name(), ProGe::OUT, ProGe::NetlistBlock::port(), ProGe::NetlistBlock::portCount(), and PlatformIntegrator::toplevelBlock().

Referenced by writeProjectFiles().

Here is the call graph for this function:

◆ createInterfaces()

void SOPCBuilderFileGenerator::createInterfaces ( )
private

Definition at line 246 of file SOPCBuilderFileGenerator.cc.

246 {
247
249 for (size_t i = 0; i < top.portCount(); i++) {
250 TCEString portName = top.port(i).name();
251
252 bool needToExport = true;
253 if (portName == TTA_CLOCK_NAME || portName == TTA_RESET_NAME) {
254 continue;
255 } else if (portName.find(HDB_AVALON_PREFIX) != TCEString::npos) {
256 needToExport = !handleAvalonSignal(top.port(i));
257 }
258
259 if (needToExport) {
260 exportSignal(top.port(i));
261 }
262 }
263}
bool handleAvalonSignal(const ProGe::NetlistPort &port)
void exportSignal(const ProGe::NetlistPort &port)

References exportSignal(), handleAvalonSignal(), HDB_AVALON_PREFIX, ProjectFileGenerator::integrator(), ProGe::NetlistPort::name(), ProGe::NetlistBlock::port(), ProGe::NetlistBlock::portCount(), PlatformIntegrator::toplevelBlock(), TTA_CLOCK_NAME, and TTA_RESET_NAME.

Referenced by writeProjectFiles().

Here is the call graph for this function:

◆ exportSignal()

void SOPCBuilderFileGenerator::exportSignal ( const ProGe::NetlistPort port)
private

Definition at line 299 of file SOPCBuilderFileGenerator.cc.

299 {
300
301 int width = 32;
302 if (port.realWidthAvailable()) {
303 width = port.realWidth();
304 }
306 export_->setPort(port.name(), intPortName, port.direction(), width);
307}
bool realWidthAvailable() const
int realWidth() const
static const TCEString SOPC_EXPORT_NAME

References ProGe::NetlistPort::direction(), export_, ProGe::NetlistPort::name(), ProGe::NetlistPort::realWidth(), ProGe::NetlistPort::realWidthAvailable(), SOPCInterface::setPort(), and SOPCInterface::SOPC_EXPORT_NAME.

Referenced by createInterfaces().

Here is the call graph for this function:

◆ getMaster()

AvalonMMMasterInterface * SOPCBuilderFileGenerator::getMaster ( const TCEString fuName)
private

Definition at line 334 of file SOPCBuilderFileGenerator.cc.

334 {
335
336 std::map<TCEString, AvalonMMMasterInterface*>::iterator iter =
337 masters_.find(fuName);
338
339 assert(iter != masters_.end());
340 return iter->second;
341}
#define assert(condition)

References assert, and masters_.

Referenced by handleAvalonSignal().

◆ handleAvalonSignal()

bool SOPCBuilderFileGenerator::handleAvalonSignal ( const ProGe::NetlistPort port)
private

Definition at line 267 of file SOPCBuilderFileGenerator.cc.

268 {
269
271
272 if (fuName.empty()) {
273 TCEString msg = "Failed to extract FU name from: " + port.name();
274 InvalidData exc(__FILE__, __LINE__, "SOPCBuilderFileGenerator", msg);
275 throw exc;
276 }
277
278 if (!MapTools::containsKey(masters_ ,fuName)) {
279 TCEString interfaceName =
282 masters_[fuName] = new AvalonMMMasterInterface(
283 interfaceName, declr, HDB_AVALON_PREFIX, *clock_);
284 }
285
286 AvalonMMMasterInterface* master = getMaster(fuName);
287 bool isAvalonPort = false;
288 if (!master->isValidPort(port)) {
289 isAvalonPort = false;
290 } else {
291 master->addPort(port);
292 isAvalonPort = true;
293 }
294 return isAvalonPort;
295}
void addPort(const ProGe::NetlistPort &port)
bool isValidPort(const ProGe::NetlistPort &port) const
static bool containsKey(const MapType &aMap, const KeyType &aKey)
TCEString extractFUName(const TCEString &port, const TCEString &delimiter) const
AvalonMMMasterInterface * getMaster(const TCEString &fuName)
static const TCEString SOPC_MASTER_INT_NAME
static const TCEString SOPC_MASTER_INT_DECLR

References AvalonMMMasterInterface::addPort(), clock_, MapTools::containsKey(), ProjectFileGenerator::extractFUName(), getMaster(), HDB_AVALON_PREFIX, AvalonMMMasterInterface::isValidPort(), masters_, ProGe::NetlistPort::name(), SOPCInterface::SOPC_MASTER_INT_DECLR, and SOPCInterface::SOPC_MASTER_INT_NAME.

Referenced by createInterfaces().

Here is the call graph for this function:

◆ writeFileList()

void SOPCBuilderFileGenerator::writeFileList ( std::ostream &  stream)
private

Definition at line 230 of file SOPCBuilderFileGenerator.cc.

230 {
231
232 stream << "# module hdl files" << endl;
233 for (unsigned int i = 0; i < hdlFileList().size(); i++) {
234 stream << SOPC_ADD_FILE << " " << hdlFileList().at(i)
235 << " {SYNTHESIS SIMULATION}" << endl;
236 }
237 for (unsigned int i = 0; i < memInitFileList().size(); i++) {
238 stream << SOPC_ADD_FILE << " " << memInitFileList().at(i)
239 << " {SYNTHESIS SIMULATION}" << endl;
240 }
241 stream << endl;
242}
const std::vector< TCEString > & hdlFileList() const
const std::vector< TCEString > & memInitFileList() const
static const TCEString SOPC_ADD_FILE

References ProjectFileGenerator::hdlFileList(), ProjectFileGenerator::memInitFileList(), and SOPC_ADD_FILE.

Referenced by writeProjectFiles().

Here is the call graph for this function:

◆ writeGenerics()

void SOPCBuilderFileGenerator::writeGenerics ( std::ostream &  stream)
private

Definition at line 198 of file SOPCBuilderFileGenerator.cc.

198 {
199
201 if (top.parameterCount() == 0) {
202 return;
203 }
204 stream << "# toplevel parameters" << endl;
205 for (size_t i = 0; i < top.parameterCount(); i++) {
206 TCEString line;
207 line << "add_parameter " << top.parameter(i).name() << " ";
208 if (top.parameter(i).type().lower() == "string") {
209 line << "STRING ";
210 if (!top.parameter(i).value().startsWith("\"")) line << "\"";
211 line << top.parameter(i).value();
212 if (!top.parameter(i).value().endsWith("\"")) line << "\"";
213 } else if (top.parameter(i).type().lower() == "integer") {
214 line << "INTEGER " << top.parameter(i).value();
215 } else {
216 // unknown type, ignore
217 continue;
218 }
219 stream << line << endl;
220 if (top.parameter(i).name().lower() == PI_DEVICE_FAMILY_GENERIC) {
221 stream << "set_parameter_property " << PI_DEVICE_FAMILY_GENERIC
222 << " DISPLAY_NAME \"Device family (change if necessary)\""
223 << endl;
224 }
225 }
226 stream << endl;
227}
virtual size_t parameterCount() const
virtual const Parameter & parameter(const std::string &name) const
const TCEString & value() const
Definition Parameter.cc:143
const TCEString & type() const
Definition Parameter.cc:138
const TCEString & name() const
Definition Parameter.cc:133
static const TCEString PI_DEVICE_FAMILY_GENERIC
TCEString lower() const
Definition TCEString.cc:78
bool startsWith(const std::string &str) const
bool endsWith(const std::string &str) const

References TCEString::endsWith(), ProjectFileGenerator::integrator(), TCEString::lower(), ProGe::Parameter::name(), ProGe::NetlistBlock::parameter(), ProGe::BaseNetlistBlock::parameterCount(), PI_DEVICE_FAMILY_GENERIC, TCEString::startsWith(), PlatformIntegrator::toplevelBlock(), ProGe::Parameter::type(), and ProGe::Parameter::value().

Referenced by writeProjectFiles().

Here is the call graph for this function:

◆ writeInterfaces()

void SOPCBuilderFileGenerator::writeInterfaces ( std::ostream &  stream) const
private

Definition at line 311 of file SOPCBuilderFileGenerator.cc.

311 {
312
313 clock_->writeInterface(stream);
314
315 std::map<TCEString, AvalonMMMasterInterface*>::const_iterator iter =
316 masters_.begin();
317 while (iter != masters_.end()) {
318 AvalonMMMasterInterface* master = iter->second;
319 if (master->hasPorts()) {
320 master->writeInterface(stream);
321 }
322 iter++;
323 }
324 if (export_->hasPorts()) {
325 export_->writeInterface(stream);
326 }
327}
virtual void writeInterface(std::ostream &stream) const
virtual void writeInterface(std::ostream &stream) const
bool hasPorts() const

References clock_, export_, SOPCInterface::hasPorts(), masters_, AvalonMMMasterInterface::writeInterface(), and SOPCInterface::writeInterface().

Referenced by writeProjectFiles().

Here is the call graph for this function:

◆ writeModuleProperties()

void SOPCBuilderFileGenerator::writeModuleProperties ( std::ostream &  stream)
private

Definition at line 166 of file SOPCBuilderFileGenerator.cc.

166 {
167
169 stream
170 << "# Module properties" << endl
171 << property << " NAME " << toplevelEntity() << endl
172 << property << " VERSION 1.0" << endl
173 << property << " GROUP \"" << SOPC_DEFAULT_GROUP << "\"" << endl
174 << property << " DISPLAY_NAME " << toplevelEntity() << endl
175 << property << " LIBRARIES {" << SOPC_DEFAULT_VHDL_LIBS;
176
177 if (integrator()->toplevelBlock().netlist().parameterCount() > 0) {
178 stream << " work." << toplevelEntity() << "_params.all";
179 }
180 stream << "}" << endl;
181
182 TCEString toplevelFile =
184 stream
185 << property << " TOP_LEVEL_HDL_FILE " << toplevelFile << endl
186 << property << " TOP_LEVEL_HDL_MODULE " << toplevelEntity() << endl
187 << property << " INSTANTIATE_IN_SYSTEM_MODULE true" << endl
188 << property << " EDITABLE false" << endl
189 << property << " SIMULATION_MODEL_IN_VERILOG false" << endl
190 << property << " SIMULATION_MODEL_IN_VHDL false" << endl
191 << property << " SIMULATION_MODEL_HAS_TULIPS false" << endl
192 << property << " SIMULATION_MODEL_IS_OBFUSCATED false" << endl
193 << endl;
194}
TCEString outputFilePath(TCEString fileName, bool absolute=false) const
static const TCEString SOPC_DEFAULT_VHDL_LIBS
static const TCEString SOPC_DEFAULT_GROUP
static const TCEString SOPC_SET_MODULE_PROPERTY

References ProjectFileGenerator::integrator(), PlatformIntegrator::outputFilePath(), SOPC_DEFAULT_GROUP, SOPC_DEFAULT_VHDL_LIBS, SOPC_SET_MODULE_PROPERTY, and ProjectFileGenerator::toplevelEntity().

Referenced by writeProjectFiles().

Here is the call graph for this function:

◆ writeProjectFiles()

void SOPCBuilderFileGenerator::writeProjectFiles ( )
virtual

Implements ProjectFileGenerator.

Definition at line 103 of file SOPCBuilderFileGenerator.cc.

103 {
104
105 int masterInterfaces = countAvalonMMMasters();
106 if (masterInterfaces == 0) {
107 TCEString msg = "Couldn't find any Avalon MM Master interfaces.";
108 InvalidData exc(__FILE__, __LINE__, "SOPCBuilderFileGenerator", msg);
109 throw exc;
110 }
111
113
115 ofstream output;
116 output.open(outputFileName.c_str());
117 if (!output) {
118 TCEString msg =
119 "Couldn't open file " + outputFileName + " for writing";
120 IOException exc(__FILE__, __LINE__, "SOPCBuilderFileGenerator", msg);
121 throw exc;
122 }
123
124 output << "# Generated by SOPCBuilderGenerator" << endl << endl;
125 writeModuleProperties(output);
126
127 writeGenerics(output);
128
129 writeFileList(output);
130
131 writeInterfaces(output);
132
133 output.close();
134}
static std::string outputFileName(const std::string &adfFile)
Definition CreateBEM.cc:77
void writeFileList(std::ostream &stream)
static const TCEString SOPC_COMPONENT_FILE_TYPE
void writeGenerics(std::ostream &stream)
void writeInterfaces(std::ostream &stream) const
void writeModuleProperties(std::ostream &stream)

References countAvalonMMMasters(), createInterfaces(), outputFileName(), SOPC_COMPONENT_FILE_TYPE, ProjectFileGenerator::toplevelEntity(), writeFileList(), writeGenerics(), writeInterfaces(), and writeModuleProperties().

Here is the call graph for this function:

Member Data Documentation

◆ clock_

SOPCInterface* SOPCBuilderFileGenerator::clock_
private

◆ export_

SOPCInterface* SOPCBuilderFileGenerator::export_
private

◆ HDB_AVALON_PREFIX

const TCEString SOPCBuilderFileGenerator::HDB_AVALON_PREFIX = "avalon_d_"
staticprivate

◆ masters_

std::map<TCEString, AvalonMMMasterInterface*> SOPCBuilderFileGenerator::masters_
private

◆ PI_DEVICE_FAMILY_GENERIC

const TCEString SOPCBuilderFileGenerator::PI_DEVICE_FAMILY_GENERIC
staticprivate
Initial value:
=
"dev_family_g"

Definition at line 93 of file SOPCBuilderFileGenerator.hh.

Referenced by writeGenerics().

◆ SOPC_ADD_FILE

const TCEString SOPCBuilderFileGenerator::SOPC_ADD_FILE
staticprivate
Initial value:
=
"add_file"

Definition at line 91 of file SOPCBuilderFileGenerator.hh.

Referenced by writeFileList().

◆ SOPC_CLOCK_NAME

const TCEString SOPCBuilderFileGenerator::SOPC_CLOCK_NAME = "clk"
staticprivate

Definition at line 85 of file SOPCBuilderFileGenerator.hh.

Referenced by SOPCBuilderFileGenerator().

◆ SOPC_COMPONENT_FILE_TYPE

const TCEString SOPCBuilderFileGenerator::SOPC_COMPONENT_FILE_TYPE
staticprivate
Initial value:
=
"_hw.tcl"

Definition at line 81 of file SOPCBuilderFileGenerator.hh.

Referenced by writeProjectFiles().

◆ SOPC_DEFAULT_GROUP

const TCEString SOPCBuilderFileGenerator::SOPC_DEFAULT_GROUP = "User Logic"
staticprivate

Definition at line 88 of file SOPCBuilderFileGenerator.hh.

Referenced by writeModuleProperties().

◆ SOPC_DEFAULT_VHDL_LIBS

const TCEString SOPCBuilderFileGenerator::SOPC_DEFAULT_VHDL_LIBS
staticprivate
Initial value:
=
"std.standard.all ieee.std_logic_1164.all ieee.std_logic_arith.all "
"work.globals.all work.util.all work.imem_mau.all"

Definition at line 89 of file SOPCBuilderFileGenerator.hh.

Referenced by writeModuleProperties().

◆ SOPC_RESET_NAME

const TCEString SOPCBuilderFileGenerator::SOPC_RESET_NAME = "reset_n"
staticprivate

Definition at line 86 of file SOPCBuilderFileGenerator.hh.

Referenced by SOPCBuilderFileGenerator().

◆ SOPC_SET_MODULE_PROPERTY

const TCEString SOPCBuilderFileGenerator::SOPC_SET_MODULE_PROPERTY
staticprivate
Initial value:
=
"set_module_property"

Definition at line 90 of file SOPCBuilderFileGenerator.hh.

Referenced by writeModuleProperties().

◆ TTA_CLOCK_NAME

const TCEString SOPCBuilderFileGenerator::TTA_CLOCK_NAME = "clk"
staticprivate

Definition at line 83 of file SOPCBuilderFileGenerator.hh.

Referenced by createInterfaces(), and SOPCBuilderFileGenerator().

◆ TTA_RESET_NAME

const TCEString SOPCBuilderFileGenerator::TTA_RESET_NAME = "rstx"
staticprivate

Definition at line 84 of file SOPCBuilderFileGenerator.hh.

Referenced by createInterfaces(), and SOPCBuilderFileGenerator().


The documentation for this class was generated from the following files: