OpenASIP
2.0
|
#include <HDLTemplateInstantiator.hh>
Public Member Functions | |
HDLTemplateInstantiator () | |
HDLTemplateInstantiator (const TCEString &entityStr) | |
void | setEntityString (const TCEString &entityStr) |
void | replacePlaceholder (const std::string &key, const std::string &replacer, bool append=false) |
void | replacePlaceholderFromFile (const std::string &key, const Path &filePath, bool append=false) |
void | instantiateTemplateFile (const std::string &templateFile, const std::string &dstFile) |
Private Types | |
typedef TCEString | PlaceholderKey |
typedef TCEString | Replacer |
typedef std::map< PlaceholderKey, Replacer > | ReplacerMap |
Private Member Functions | |
void | fillPlaceholders (TCEString &str) |
TCEString | findPlaceholder (const TCEString &str) |
TCEString | getPlaceholderKey (const TCEString &str) |
TCEString | getPlaceholderDefault (const TCEString &str) |
Private Attributes | |
TCEString | entityStr_ |
ReplacerMap | replacers_ |
Static Private Attributes | |
static const std::string | PLACEHOLDERSEPARATOR = "," |
static const std::string | PLACEHOLDERBEGIN |
static const std::string | PLACEHOLDEREND = ">>" |
Friends | |
class | HDLTemplateInstantiatorTest |
Helper class for instantiating HDL template files.
Definition at line 45 of file HDLTemplateInstantiator.hh.
|
private |
Definition at line 65 of file HDLTemplateInstantiator.hh.
|
private |
Definition at line 66 of file HDLTemplateInstantiator.hh.
|
private |
Definition at line 67 of file HDLTemplateInstantiator.hh.
HDLTemplateInstantiator::HDLTemplateInstantiator | ( | ) |
Definition at line 42 of file HDLTemplateInstantiator.cc.
HDLTemplateInstantiator::HDLTemplateInstantiator | ( | const TCEString & | entityStr | ) |
Definition at line 45 of file HDLTemplateInstantiator.cc.
|
private |
Fills all placeholder templates with added replace strings by key.
The placeholder markers are in form "<<placeholder,key>>" or "<<placeholder,key,default-value>>". If no replacer is not found for the key the placeholder template is replaced with empty string or default-value if defined.
str | The string to search and fill placeholders. |
Definition at line 153 of file HDLTemplateInstantiator.cc.
References findPlaceholder(), getPlaceholderDefault(), getPlaceholderKey(), replacers_, and TCEString::replaceString().
Referenced by instantiateTemplateFile().
Searches placeholder template over given string.
str | The string to search over for placeholder template. |
Definition at line 189 of file HDLTemplateInstantiator.cc.
References PLACEHOLDERBEGIN, and PLACEHOLDEREND.
Referenced by fillPlaceholders(), getPlaceholderDefault(), and getPlaceholderKey().
Searches placeholder template over given string and returns its default part.
The placeholder template is in form of <placeholder,keystring,default> and this function return default part.
Definition at line 247 of file HDLTemplateInstantiator.cc.
References assert, findPlaceholder(), PLACEHOLDEREND, PLACEHOLDERSEPARATOR, and StringTools::trim().
Referenced by fillPlaceholders().
Searches placeholder template over given string and returns its key.
The placeholder template is in form of <placeholder, keystring, default> and this function return keystring part.
str | The string to search over for placeholder template |
Definition at line 215 of file HDLTemplateInstantiator.cc.
References assert, findPlaceholder(), PLACEHOLDERBEGIN, PLACEHOLDEREND, PLACEHOLDERSEPARATOR, and StringTools::trim().
Referenced by fillPlaceholders().
void HDLTemplateInstantiator::instantiateTemplateFile | ( | const std::string & | templateFile, |
const std::string & | dstFile | ||
) |
Creates a target HDL file from a HDL template, replacing certain magic strings with certain variable contents.
Currently supported magic strings: ENTITY_STR The entity name string used to make entities unique. Same as the toplevel entity name.
Definition at line 113 of file HDLTemplateInstantiator.cc.
References __func__, entityStr_, fillPlaceholders(), and TCEString::replaceString().
Referenced by AlmaIFIntegrator::addAlmaifFiles(), ProGe::BlockSourceCopier::copyProcessorSpecific(), ProGeTestBenchGenerator::copyTestBenchFiles(), ProGeTestBenchGenerator::createProcArchVhdl(), ProGe::RV32MicroCodeGenerator::generateWrapper(), ProGe::BlockSourceCopier::instantiateHDLTemplate(), MemoryGenerator::instantiateTemplate(), ProGe::TestBenchBlock::write(), ProGe::SinglePortByteMaskSSRAMBlock::write(), ProGe::SinglePortSSRAMBlock::write(), and ProGe::LoopBufferBlock::write().
void HDLTemplateInstantiator::replacePlaceholder | ( | const std::string & | key, |
const std::string & | replacer, | ||
bool | append = false |
||
) |
Adds replace string for the template placeholder by key.
During HDL template instantiation all placeholders by the key will be replaced with given replace string.
key | The key to identify placeholder. |
replacer | The string to replace the placeholder. |
append | Appends the given string to the existing placeholder filler at the key. |
KeyAlreadyExists | If a placeholder is already filled by the key and append flag is false. |
Definition at line 62 of file HDLTemplateInstantiator.cc.
References replacers_, and THROW_EXCEPTION.
Referenced by AlmaIFIntegrator::addAlmaifFiles(), DefaultICDecoderGenerator::generate(), ProGe::RV32MicroCodeGenerator::generateOperationLatencyLogic(), ProGe::ProcessorGenerator::generateProcessor(), ProGe::RV32MicroCodeGenerator::generateWrapper(), AlmaIFIntegrator::initAlmaifBlock(), replacePlaceholderFromFile(), ProGe::TestBenchBlock::write(), and ProGe::LoopBufferBlock::write().
void HDLTemplateInstantiator::replacePlaceholderFromFile | ( | const std::string & | key, |
const Path & | filePath, | ||
bool | append = false |
||
) |
Adds replace string from file for the template placeholder by key.
During HDL template instantiation all placeholders by the key will be replaced with given replace string.
key | The key to identify placeholder. |
replacer | The string to replace the placeholder. |
append | Appends the given string to the existing placeholder filler at the key. |
Definition at line 89 of file HDLTemplateInstantiator.cc.
References replacePlaceholder(), and THROW_EXCEPTION.
Referenced by AlmaIFIntegrator::addAlmaifFiles(), AlmaIFIntegrator::connectCoreMemories(), DefaultICDecoderGenerator::generate(), AlmaIFIntegrator::initAlmaifBlock(), and ProGe::LoopBufferBlock::write().
|
inline |
Definition at line 51 of file HDLTemplateInstantiator.hh.
References entityStr_.
Referenced by ProGe::BlockSourceCopier::BlockSourceCopier(), ProGeTestBenchGenerator::copyTestBenchFiles(), ProGeTestBenchGenerator::createProcArchVhdl(), and MemoryGenerator::instantiateTemplate().
|
friend |
Definition at line 47 of file HDLTemplateInstantiator.hh.
|
private |
Definition at line 78 of file HDLTemplateInstantiator.hh.
Referenced by instantiateTemplateFile(), and setEntityString().
|
staticprivate |
Definition at line 75 of file HDLTemplateInstantiator.hh.
Referenced by findPlaceholder(), and getPlaceholderKey().
|
staticprivate |
Definition at line 76 of file HDLTemplateInstantiator.hh.
Referenced by findPlaceholder(), getPlaceholderDefault(), and getPlaceholderKey().
|
staticprivate |
Definition at line 74 of file HDLTemplateInstantiator.hh.
Referenced by getPlaceholderDefault(), and getPlaceholderKey().
|
private |
Definition at line 79 of file HDLTemplateInstantiator.hh.
Referenced by fillPlaceholders(), and replacePlaceholder().