OpenASIP 2.2
Loading...
Searching...
No Matches
Functions | Variables
GenerateBits.cc File Reference
#include <iostream>
#include <cmath>
#include <boost/format.hpp>
#include "PIGCmdLineOptions.hh"
#include "ProgramImageGenerator.hh"
#include "PIGCLITextGenerator.hh"
#include "ADFSerializer.hh"
#include "Machine.hh"
#include "ControlUnit.hh"
#include "BinaryEncoding.hh"
#include "BEMSerializer.hh"
#include "BEMGenerator.hh"
#include "Binary.hh"
#include "BinaryStream.hh"
#include "BinaryReader.hh"
#include "FileSystem.hh"
Include dependency graph for GenerateBits.cc:

Go to the source code of this file.

Functions

static BinaryloadTPEF (const std::string &tpefFile)
 
static BinaryEncodingloadBEM (const std::string &bemFile)
 
static MachineloadMachine (const std::string &adfFile)
 
static bool isInstructionMemory (const TTAMachine::AddressSpace &as)
 
std::string programImemImageFile (const std::string &tpefFile, const std::string &format)
 
std::string programDataImageFile (const std::string &tpefFile, const std::string &format, const std::string &asName)
 
void parseParameter (const std::string &param, std::string &paramName, std::string &paramValue)
 
void createMauPkg (int language, int imemMauWidth, string fileName, string entityNameStr)
 
void createCompressor (string fileName, ProgramImageGenerator &imageGenerator, string entityStr)
 
void copyImageToTb (const string &source, const string &progeDir, const string &newImage)
 
int main (int argc, char *argv[])
 

Variables

const int DEFAULT_IMEMWIDTH_IN_MAUS = 1
 
const string IMEM_MAU_PKG = "imem_mau_pkg.vhdl"
 
const string VER_IMEM_MAU_PKG = "imem_mau_pkg.vh"
 
const string DECOMPRESSOR_FILE = "idecompressor.vhdl"
 
const string TB_DIR = "tb"
 
const string DIR_SEP = FileSystem::DIRECTORY_SEPARATOR
 
const string TB_IMEM_FILE = "imem_init.img"
 
const string TB_DMEM_FILE = "dmem_init.img"
 

Detailed Description

Implementation of the main function of generatebits application.

Author
Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
Otto Esko 2009 (otto.esko-no.spam-tut.fi)
Pekka Jääskeläinen 2009 (pekka.jaaskelainen-no.spam-tut.fi)
Otto Esko 2010 (otto.esko-no.spam-tut.fi)
Pekka Jääskeläinen 2011
Vinogradov Viacheslav(added Verilog generating) 2012
Note
rating: red

Definition in file GenerateBits.cc.

Function Documentation

◆ copyImageToTb()

void copyImageToTb ( const string &  source,
const string &  progeDir,
const string &  newImage 
)

Definition at line 271 of file GenerateBits.cc.

274 {
275
276 if (!progeDir.empty()) {
277 string tbDir = progeDir + DIR_SEP + TB_DIR;
278 string tbImage = tbDir + DIR_SEP + newImage;
280 && (FileSystem::fileIsWritable(tbImage)
281 || FileSystem::fileIsCreatable(tbImage))) {
282 try {
283 FileSystem::copy(source, tbImage);
284 } catch (Exception& e) {
285 cerr << e.errorMessage() << endl;
286 }
287 }
288 }
289}
const string DIR_SEP
const string TB_DIR
std::string errorMessage() const
Definition Exception.cc:123
static void copy(const std::string &source, const std::string &target)
static bool fileIsDirectory(const std::string fileName)
static bool fileIsWritable(const std::string fileName)
static bool fileIsCreatable(const std::string fileName)

References FileSystem::copy(), DIR_SEP, Exception::errorMessage(), FileSystem::fileIsCreatable(), FileSystem::fileIsDirectory(), FileSystem::fileIsWritable(), and TB_DIR.

Referenced by main().

Here is the call graph for this function:

◆ createCompressor()

void createCompressor ( string  fileName,
ProgramImageGenerator imageGenerator,
string  entityStr 
)

Definition at line 254 of file GenerateBits.cc.

256 {
257
258 bool created = FileSystem::createFile(fileName);
259 if (!created) {
260 string errorMsg = "Unable to create file " +
261 fileName;
262 throw IOException(__FILE__, __LINE__, __func__, errorMsg);
263 }
264 std::ofstream decompressorStream(
265 fileName.c_str(), std::ofstream::out);
266 imageGenerator.generateDecompressor(decompressorStream, entityStr);
267 decompressorStream.close();
268}
#define __func__
static bool createFile(const std::string &file)
void generateDecompressor(std::ostream &stream, TCEString entityStr)

References __func__, FileSystem::createFile(), and ProgramImageGenerator::generateDecompressor().

Referenced by main().

Here is the call graph for this function:

◆ createMauPkg()

void createMauPkg ( int  language,
int  imemMauWidth,
string  fileName,
string  entityNameStr 
)

Definition at line 222 of file GenerateBits.cc.

223 {
224
225 string indentation = " ";
226
227 if (!FileSystem::fileExists(fileName)
228 && !FileSystem::createFile(fileName)) {
229 string errorMsg = "Unable to create file " + fileName;
230 throw IOException(__FILE__, __LINE__, __func__, errorMsg);
231 } else if (!FileSystem::fileIsWritable(fileName)) {
232 string errorMsg = "Unable to write to file " + fileName;
233 throw IOException(__FILE__, __LINE__, __func__, errorMsg);
234 }
235 std::ofstream stream(fileName.c_str());
236 string entityName = entityNameStr + "_imem_mau";
237 if(language==0){//vhdl
238 stream << "package " << entityName << " is" << endl
239 << indentation << "-- created by generatebits" << endl
240 << indentation << "constant IMEMMAUWIDTH : positive := "
241 << imemMauWidth << ";" << endl
242 << "end " << entityName << ";" << endl;
243 } else {
244 stream << "//package " << entityName << " is" << endl
245 << indentation << "// created by generatebits" << endl
246 << indentation << "parameter IMEMMAUWIDTH = "
247 << imemMauWidth << endl
248 << "//end " << entityName << ";" << endl;
249 }
250 stream.close();
251}
static bool fileExists(const std::string fileName)

References __func__, FileSystem::createFile(), FileSystem::fileExists(), and FileSystem::fileIsWritable().

Referenced by main().

Here is the call graph for this function:

◆ isInstructionMemory()

static bool isInstructionMemory ( const TTAMachine::AddressSpace as)
static

Tells whether the given address space is instruction memory.

Parameters
asThe address space.
Returns
True if the address space is instruction memory, otherwise false.

Definition at line 135 of file GenerateBits.cc.

135 {
136 Machine* mach = as.machine();
137 ControlUnit* gcu = mach->controlUnit();
138 if (gcu != NULL && gcu->addressSpace() == &as) {
139 return true;
140 } else {
141 return false;
142 }
143}
virtual Machine * machine() const
virtual AddressSpace * addressSpace() const
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345

References TTAMachine::FunctionUnit::addressSpace(), TTAMachine::Machine::controlUnit(), and TTAMachine::Component::machine().

Referenced by main().

Here is the call graph for this function:

◆ loadBEM()

static BinaryEncoding * loadBEM ( const std::string &  bemFile)
static

Loads the given BEM file and creates a BinaryEncoding instance from it.

Parameters
bemFileThe BEM file.
Returns
The newly created BinaryEncoding instance.
Exceptions
SerializerExceptionIf an error occurs while reading the file.
ObjectStateLoadingExceptionIf an error occurs while loading the state of BinaryEncoding instance.

Definition at line 106 of file GenerateBits.cc.

106 {
107 BEMSerializer serializer;
108 serializer.setSourceFile(bemFile);
109 return serializer.readBinaryEncoding();
110}
BinaryEncoding * readBinaryEncoding()
void setSourceFile(const std::string &fileName)

References BEMSerializer::readBinaryEncoding(), and XMLSerializer::setSourceFile().

Referenced by main().

Here is the call graph for this function:

◆ loadMachine()

static Machine * loadMachine ( const std::string &  adfFile)
static

Loads the given ADF file and creates a Machine instance from it.

Parameters
adfFileThe ADF file.
Returns
The newly created Machine instance.
Exceptions
SerializerExceptionIf an error occurs while reading the file.
ObjectStateLoadingExceptionIf an error occurs while loading the state of Machine instance.

Definition at line 122 of file GenerateBits.cc.

122 {
123 ADFSerializer serializer;
124 serializer.setSourceFile(adfFile);
125 return serializer.readMachine();
126}
TTAMachine::Machine * readMachine()

References ADFSerializer::readMachine(), and XMLSerializer::setSourceFile().

Referenced by main().

Here is the call graph for this function:

◆ loadTPEF()

static Binary * loadTPEF ( const std::string &  tpefFile)
static

Loads the given TPEF file and creates a Binary instance from it.

Parameters
tpefFileThe TPEF file.
Returns
The newly created Binary instance.
Exceptions
InstanceNotFoundIf instance for reading wasn't found.
UnreachableStreamIf given file can't be read.
KeyAlreadyExistsKey was in use when trying to register object.
EndOfFileIf end of file were reached while it shouldn't.
OutOfRangeSome read value was out of range.
WrongSubclassSome class couldn't do what it was asked for.
UnexpectedValueIf there was unexpected value when reading.

Definition at line 89 of file GenerateBits.cc.

89 {
90 BinaryStream stream(tpefFile);
91 return BinaryReader::readBinary(stream);
92}
static Binary * readBinary(BinaryStream &stream)

References TPEF::BinaryReader::readBinary().

Referenced by main().

Here is the call graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

The main function of generatebits application.

Definition at line 294 of file GenerateBits.cc.

294 {
295
297 try {
298 options->parse(argv, argc);
299 } catch (ParserStopRequest const&) {
300 return EXIT_SUCCESS;
301 } catch (const IllegalCommandLine& exception) {
302 cerr << exception.errorMessage() << endl;
303 return EXIT_FAILURE;
304 }
305
307
308 string adfFile = "";
309 if (options->numberOfArguments() < 1) {
310 PIGCLITextGenerator textGen;
311 cerr << textGen.text(PIGCLITextGenerator::TXT_ADF_REQUIRED) << endl;
312 return EXIT_FAILURE;
313 } else if (options->numberOfArguments() > 1) {
314 PIGCLITextGenerator textGen;
315 cerr << textGen.text(PIGCLITextGenerator::TXT_ILLEGAL_ARGS) << endl;
316 return EXIT_FAILURE;
317 } else {
318 adfFile = options->argument(1);
319 }
320
321 string bemFile = options->bemFile();
322 string piFormat = options->programImageOutputFormat();
323 string diFormat = options->dataImageOutputFormat();
324 int dmemMAUsPerLine = options->dataMemoryWidthInMAUs();
325 string compressor = options->compressorPlugin();
326 const bool useCompression = compressor != "";
327 bool generateDataImages = options->generateDataImages();
328 bool generateDecompressor = options->generateDecompressor();
329 bool showCompressors = options->showCompressors();
330 int imemMAUsPerLine = DEFAULT_IMEMWIDTH_IN_MAUS;
331 string progeOutputDir = options->progeOutputDirectory();
332
333 TCEString entityStr = options->entityName();
334 if (entityStr == "")
335 entityStr = "tta0";
336
337 if (showCompressors) {
338 std::vector<string> compressorFiles =
340 for (std::vector<string>::const_iterator iter =
341 compressorFiles.begin();
342 iter != compressorFiles.end(); iter++) {
343 try {
344 std::cout << "******************************************"
345 << "**********************" << endl;
346 std::cout << "Compressor file: " << *iter << endl;
347
349 *iter, std::cout);
350 } catch (const Exception& e) {
351 cerr << "Error: " << e.errorMessage() << endl;
352 }
353 std::cout << std::endl;
354 }
355 return EXIT_SUCCESS;
356 }
357
359 for (int i = 0; i < options->compressorParameterCount(); i++) {
360 string param = options->compressorParameter(i);
361 string paramName;
362 string paramValue;
363 try {
364 parseParameter(param, paramName, paramValue);
365 } catch (const Exception& e) {
366 cerr << e.errorMessage() << endl;
367 return EXIT_FAILURE;
368 }
369 CodeCompressorPlugin::Parameter newParam = {paramName, paramValue};
370 compressorParams.push_back(newParam);
371 }
372
373 if (adfFile == "" ||
374 (piFormat != "" && piFormat != "binary" && piFormat != "ascii" &&
375 piFormat != "array" && piFormat != "mif" && piFormat != "vhdl" &&
376 piFormat != "coe" && piFormat != "hex" && piFormat != "bin2n") ||
377 (diFormat != "" && diFormat != "binary" &&
378 diFormat != "ascii" && diFormat != "array" && diFormat != "mif" &&
379 diFormat != "vhdl" && diFormat != "coe" && diFormat != "hex" && diFormat != "bin2n")) {
381 return EXIT_FAILURE;
382 }
383
384 std::vector<Binary*> tpefTable;
386 try {
387 Machine* mach = loadMachine(adfFile);
388
389 for (int i = 0; i < options->tpefFileCount(); i++) {
390 string tpefFile = options->tpefFile(i);
391 Binary* tpef = loadTPEF(tpefFile);
392 tpefTable.push_back(tpef);
393 tpefMap[FileSystem::fileOfPath(tpefFile)] = tpef;
394 }
395
396 BinaryEncoding* bem = NULL;
397
398 if (bemFile != "") {
399 bem = loadBEM(bemFile);
400 } else {
401 PIGCLITextGenerator textGen;
402#if 0
403 // useless error output as this happens 100% of the time,
404 // no-one hasn't wanted to customize BEMs yet
405 std::cerr
407 str() << std::endl;
408#endif
409 BEMGenerator bemGenerator(*mach);
410 bem = bemGenerator.generate();
411 }
412
413 ProgramImageGenerator imageGenerator;
414 if (useCompression) {
415 imageGenerator.loadCompressorPlugin(compressor);
416 }
417 imageGenerator.loadCompressorParameters(compressorParams);
418 imageGenerator.loadBEM(*bem);
419 imageGenerator.loadMachine(*mach);
420 imageGenerator.loadPrograms(tpefMap);
421 imageGenerator.setEntityName(entityStr);
422 imageGenerator.setDataStartOptions(options->dataStart());
423
424 if (Application::verboseLevel() > 0) {
426 << (boost::format(
427 "uncompressed instruction width: %d bits (%d bytes)\n" )
428 % bem->width() % std::ceil(bem->width() / 8.0)).str();
429 }
430
431 for (size_t i = 0; i < tpefTable.size(); i++) {
432
433 Binary* program = tpefTable[i];
434 string tpefFile = FileSystem::fileOfPath(options->tpefFile(i));
435 string imageFile = programImemImageFile(tpefFile, piFormat);
436 ofstream piStream(imageFile.c_str());
437 if (piFormat == "binary") {
438 imageGenerator.generateProgramImage(
439 tpefFile, piStream, ProgramImageGenerator::BINARY);
440 } else if (piFormat == "array") {
441 imageGenerator.generateProgramImage(
442 tpefFile, piStream, ProgramImageGenerator::ARRAY,
443 imemMAUsPerLine);
444 } else if (piFormat == "mif") {
445 imageGenerator.generateProgramImage(
446 tpefFile, piStream, ProgramImageGenerator::MIF,
447 imemMAUsPerLine);
448 } else if (piFormat == "vhdl") {
449 imageGenerator.generateProgramImage(
450 tpefFile, piStream, ProgramImageGenerator::VHDL,
451 imemMAUsPerLine);
452 } else if (piFormat == "coe") {
453 imageGenerator.generateProgramImage(
454 tpefFile, piStream, ProgramImageGenerator::COE,
455 imemMAUsPerLine);
456 } else if (piFormat == "hex") {
457 imageGenerator.generateProgramImage(
458 tpefFile, piStream, ProgramImageGenerator::HEX,
459 imemMAUsPerLine);
460 } else if (piFormat == "bin2n") {
461 imageGenerator.generateProgramImage(
462 tpefFile, piStream, ProgramImageGenerator::BIN2N,
463 imemMAUsPerLine);
464 } else {
465 assert(piFormat == "ascii" || piFormat == "");
466 imageGenerator.generateProgramImage(
467 tpefFile, piStream, ProgramImageGenerator::ASCII,
468 imemMAUsPerLine);
469 }
470 piStream.close();
471
472 if (piFormat == "ascii" || piFormat == "") {
473 copyImageToTb(imageFile, progeOutputDir, TB_IMEM_FILE);
474 }
475
476 if (generateDataImages) {
478 mach->addressSpaceNavigator();
479 for (int i = 0; i < asNav.count(); i++) {
480 AddressSpace* as = asNav.item(i);
481 if (!isInstructionMemory(*as)) {
482 string fileName =
484 tpefFile, diFormat, as->name());
485 ofstream stream(fileName.c_str());
486 if (diFormat == "binary") {
487 imageGenerator.generateDataImage(
488 tpefFile, *program, as->name(), stream,
490 } else if (diFormat == "array") {
491 imageGenerator.generateDataImage(
492 tpefFile, *program, as->name(), stream,
494 dmemMAUsPerLine, true);
495 } else if (diFormat == "mif") {
496 imageGenerator.generateDataImage(
497 tpefFile, *program, as->name(), stream,
499 dmemMAUsPerLine, true);
500 } else if (diFormat == "vhdl") {
501 imageGenerator.generateDataImage(
502 tpefFile, *program, as->name(), stream,
504 dmemMAUsPerLine, true);
505 } else if (diFormat == "coe") {
506 imageGenerator.generateDataImage(
507 tpefFile, *program, as->name(), stream,
509 dmemMAUsPerLine, true);
510 } else if (diFormat == "hex") {
511 imageGenerator.generateDataImage(
512 tpefFile, *program, as->name(), stream,
514 dmemMAUsPerLine, true);
515 } else if (diFormat == "bin2n") {
516 imageGenerator.generateDataImage(
517 tpefFile, *program, as->name(), stream,
519 dmemMAUsPerLine, true);
520 } else {
521 assert(diFormat == "ascii" || diFormat == "");
522 imageGenerator.generateDataImage(
523 tpefFile, *program, as->name(), stream,
525 dmemMAUsPerLine, true);
526 }
527 stream.close();
528
529 if (diFormat == "ascii" || piFormat == "") {
530 std::string dmemInitFile("dmem_");
531 dmemInitFile += as->name() + "_init.img";
533 fileName, progeOutputDir, dmemInitFile);
534 }
535 }
536 }
537 }
538 }
539
540 if (generateDecompressor) {
541 string decomp = DECOMPRESSOR_FILE;
542 if (!progeOutputDir.empty()) {
543 string temp =
544 progeOutputDir + DIR_SEP + "gcu_ic" + DIR_SEP
546 if ( (FileSystem::fileExists(temp)
549 decomp = temp;
550 }
551 }
552 createCompressor(decomp, imageGenerator, entityStr);
553 }
554
555 int compressedInstructionWidth = imageGenerator.imemMauWidth();
556 if (!progeOutputDir.empty()) {
557 string temp =
558 progeOutputDir + DIR_SEP + "vhdl" + DIR_SEP + entityStr +
559 "_" + IMEM_MAU_PKG;
560 if ( (FileSystem::fileExists(temp)
563 //vhdl
564 createMauPkg(0,compressedInstructionWidth, temp, entityStr);
565 }
566 temp =
567 progeOutputDir + DIR_SEP + "verilog" + DIR_SEP + entityStr +
568 "_" + VER_IMEM_MAU_PKG;
569 if ( (FileSystem::fileExists(temp)
572 //verilog
573 createMauPkg(1,compressedInstructionWidth, temp, entityStr);
574 }
575 } else {//if none exist generate in current folder for both HDLs
576 createMauPkg(0,compressedInstructionWidth, entityStr + "_" +
577 IMEM_MAU_PKG, entityStr); //vhdl
578 createMauPkg(1,compressedInstructionWidth,
579 entityStr + "_" + VER_IMEM_MAU_PKG, entityStr); //verilog
580 }
581
582 for (std::vector<Binary*>::iterator iter = tpefTable.begin();
583 iter != tpefTable.end(); iter++) {
584 delete *iter;
585 }
586 delete mach;
587 delete bem;
588
589 return EXIT_SUCCESS;
590
591 } catch (const Exception& exception) {
592 cerr << exception.errorMessageStack() << endl;
593 return EXIT_FAILURE;
594 }
595}
#define assert(condition)
const string VER_IMEM_MAU_PKG
void createCompressor(string fileName, ProgramImageGenerator &imageGenerator, string entityStr)
static bool isInstructionMemory(const TTAMachine::AddressSpace &as)
void parseParameter(const std::string &param, std::string &paramName, std::string &paramValue)
const string DECOMPRESSOR_FILE
const string IMEM_MAU_PKG
static Binary * loadTPEF(const std::string &tpefFile)
static Machine * loadMachine(const std::string &adfFile)
void copyImageToTb(const string &source, const string &progeDir, const string &newImage)
std::string programDataImageFile(const std::string &tpefFile, const std::string &format, const std::string &asName)
const int DEFAULT_IMEMWIDTH_IN_MAUS
void createMauPkg(int language, int imemMauWidth, string fileName, string entityNameStr)
std::string programImemImageFile(const std::string &tpefFile, const std::string &format)
const string TB_IMEM_FILE
static BinaryEncoding * loadBEM(const std::string &bemFile)
find Finds info of the inner loops in the program
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
static void setCmdLineOptions(CmdLineOptions *options_)
static int verboseLevel()
static std::ostream & logStream()
virtual int width(const TCEString &templateName) const
void parse(char *argv[], int argc)
virtual std::string argument(int index) const
virtual int numberOfArguments() const
std::vector< Parameter > ParameterTable
Table for passing plugin parameters.
std::string errorMessageStack(bool messagesOnly=false) const
Definition Exception.cc:138
static std::string fileOfPath(const std::string pathName)
virtual void printHelp() const
void loadPrograms(TPEFMap programs)
void setDataStartOptions(CmdLineOptionParser *options)
static std::vector< std::string > availableCompressors()
std::map< std::string, TPEF::Binary * > TPEFMap
void generateDataImage(const std::string &programName, TPEF::Binary &program, const std::string &addressSpace, std::ostream &stream, OutputFormat format, int mausPerLine, bool usePregeneratedImage)
void setEntityName(const std::string &entity)
void loadCompressorPlugin(const std::string &fileName)
void loadCompressorParameters(CodeCompressorPlugin::ParameterTable parameters)
@ BINARY
Real binary format.
@ VHDL
Array as a Vhdl package.
@ BIN2N
Binary format padded to 2**n.
@ MIF
MIF Memory Initialization File.
@ ARRAY
ASCII 1's and 0's in array form.
@ COE
COE memory initialization format.
@ HEX
HEX memory initialization format.
static void printCompressorDescription(const std::string &fileName, std::ostream &stream)
void generateProgramImage(const std::string &programName, std::ostream &stream, OutputFormat format, int mausPerLine=0)
void loadMachine(const TTAMachine::Machine &machine)
void loadBEM(const BinaryEncoding &bem)
virtual TCEString name() const
ComponentType * item(int index) const
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition Machine.cc:392
virtual boost::format text(int textId)

References TTAMachine::Machine::addressSpaceNavigator(), CmdLineParser::argument(), ProgramImageGenerator::ARRAY, ProgramImageGenerator::ASCII, assert, ProgramImageGenerator::availableCompressors(), ProgramImageGenerator::BIN2N, ProgramImageGenerator::BINARY, ProgramImageGenerator::COE, copyImageToTb(), TTAMachine::Machine::Navigator< ComponentType >::count(), createCompressor(), createMauPkg(), DECOMPRESSOR_FILE, DEFAULT_IMEMWIDTH_IN_MAUS, DIR_SEP, Exception::errorMessage(), Exception::errorMessageStack(), FileSystem::fileExists(), FileSystem::fileIsCreatable(), FileSystem::fileIsWritable(), FileSystem::fileOfPath(), BEMGenerator::generate(), ProgramImageGenerator::generateDataImage(), ProgramImageGenerator::generateProgramImage(), ProgramImageGenerator::HEX, IMEM_MAU_PKG, ProgramImageGenerator::imemMauWidth(), isInstructionMemory(), TTAMachine::Machine::Navigator< ComponentType >::item(), ProgramImageGenerator::loadBEM(), loadBEM(), ProgramImageGenerator::loadCompressorParameters(), ProgramImageGenerator::loadCompressorPlugin(), loadMachine(), ProgramImageGenerator::loadMachine(), ProgramImageGenerator::loadPrograms(), loadTPEF(), Application::logStream(), ProgramImageGenerator::MIF, TTAMachine::Component::name(), CmdLineParser::numberOfArguments(), options, CmdLineOptions::parse(), parseParameter(), ProgramImageGenerator::printCompressorDescription(), MachInfoCmdLineOptions::printHelp(), program, programDataImageFile(), programImemImageFile(), Application::setCmdLineOptions(), ProgramImageGenerator::setDataStartOptions(), ProgramImageGenerator::setEntityName(), TB_IMEM_FILE, Texts::TextGenerator::text(), PIGCLITextGenerator::TXT_ADF_REQUIRED, PIGCLITextGenerator::TXT_GENERATING_BEM, PIGCLITextGenerator::TXT_ILLEGAL_ARGS, VER_IMEM_MAU_PKG, Application::verboseLevel(), ProgramImageGenerator::VHDL, and BinaryEncoding::width().

Here is the call graph for this function:

◆ parseParameter()

void parseParameter ( const std::string &  param,
std::string &  paramName,
std::string &  paramValue 
)

Parses the given parameter which has form 'paramname=paramvalue" to different strings.

Parameters
paramThe parameter.
paramNameParameter name is stored here.
paramValueParameter value is stored here.
Exceptions
InvalidDataIf the given parameter is not in the correct form.

Definition at line 207 of file GenerateBits.cc.

208 {
209 string::size_type separatorPos = param.find("=", 0);
210 if (separatorPos == string::npos) {
211 string errorMsg =
212 "Compressor parameters must be in form "
213 "'parametername=parametervalue'.";
214 throw InvalidData(__FILE__, __LINE__, __func__, errorMsg);
215 }
216
217 paramName = param.substr(0, separatorPos);
218 paramValue = param.substr(separatorPos+1, param.length());
219}

References __func__.

Referenced by main().

◆ programDataImageFile()

std::string programDataImageFile ( const std::string &  tpefFile,
const std::string &  format,
const std::string &  asName 
)

Returns the name of the program data image file for the given TPEF file.

Parameters
tpefFileName of the TPEF file.
formatThe image output format
asNameName of the address space the image belongs to.
Returns
Name of the program image file.

Definition at line 179 of file GenerateBits.cc.

182 {
183
184 string imageFile = FileSystem::fileNameBody(tpefFile) + "_" + asName;
185 if (format == "mif") {
186 imageFile += ".mif";
187 } else if (format == "vhdl") {
188 imageFile += "_pkg.vhdl";
189 } else if (format == "coe") {
190 imageFile += ".coe";
191 } else {
192 imageFile += ".img";
193 }
194 return imageFile;
195}
static std::string fileNameBody(const std::string &fileName)

References FileSystem::fileNameBody().

Referenced by main().

Here is the call graph for this function:

◆ programImemImageFile()

std::string programImemImageFile ( const std::string &  tpefFile,
const std::string &  format 
)

Returns the name of the program's imem image file for the given TPEF file.

Parameters
tpefFileName of the TPEF file.
formatThe image output format
Returns
Name of the program image file.

Definition at line 154 of file GenerateBits.cc.

154 {
155
156 string imageFile = FileSystem::fileNameBody(tpefFile);
157 if (format == "mif") {
158 // altera tools want .mif ending for MIF files
159 imageFile += ".mif";
160 } else if (format == "vhdl") {
161 imageFile += "_imem_pkg.vhdl";
162 } else if (format == "coe") {
163 imageFile += ".coe";
164 } else {
165 imageFile += ".img";
166 }
167 return imageFile;
168}

References FileSystem::fileNameBody().

Referenced by main().

Here is the call graph for this function:

Variable Documentation

◆ DECOMPRESSOR_FILE

const string DECOMPRESSOR_FILE = "idecompressor.vhdl"

Definition at line 68 of file GenerateBits.cc.

Referenced by main().

◆ DEFAULT_IMEMWIDTH_IN_MAUS

const int DEFAULT_IMEMWIDTH_IN_MAUS = 1

Definition at line 65 of file GenerateBits.cc.

Referenced by GenerateProcessor::generateProcessor(), and main().

◆ DIR_SEP

const string DIR_SEP = FileSystem::DIRECTORY_SEPARATOR

Definition at line 71 of file GenerateBits.cc.

Referenced by copyImageToTb(), main(), and PluginTools::registerModule().

◆ IMEM_MAU_PKG

const string IMEM_MAU_PKG = "imem_mau_pkg.vhdl"

Definition at line 66 of file GenerateBits.cc.

Referenced by main().

◆ TB_DIR

const string TB_DIR = "tb"

Definition at line 70 of file GenerateBits.cc.

Referenced by copyImageToTb().

◆ TB_DMEM_FILE

const string TB_DMEM_FILE = "dmem_init.img"

Definition at line 73 of file GenerateBits.cc.

◆ TB_IMEM_FILE

const string TB_IMEM_FILE = "imem_init.img"

Definition at line 72 of file GenerateBits.cc.

Referenced by main().

◆ VER_IMEM_MAU_PKG

const string VER_IMEM_MAU_PKG = "imem_mau_pkg.vh"

Definition at line 67 of file GenerateBits.cc.

Referenced by main().