#include <ProGeTestBenchGenerator.hh>
|
void | copyTestBenchFiles (const std::string &dstDirectory) |
|
void | createFile (const std::string &fileName) |
|
std::string | getSignalMapping (const std::string &fuName, const std::string &epName, bool widthIsOne, const std::string &memoryName, const std::string &memoryLine) |
|
void | createTBConstFile (std::string dstDirectory, const std::string &dmemImage="dmem_init.img", const std::string &dataWidth="", const std::string &addrWidth="") |
|
void | createProcArchVhdl (const std::string &dstDirectory, const std::string &topLevelVhdl, const std::string &signalMappings) |
|
Class for test bench generating objects.
Base class for script generating.
Definition at line 54 of file ProGeTestBenchGenerator.hh.
◆ ProGeTestBenchGenerator()
ProGeTestBenchGenerator::ProGeTestBenchGenerator |
( |
| ) |
|
◆ ~ProGeTestBenchGenerator()
ProGeTestBenchGenerator::~ProGeTestBenchGenerator |
( |
| ) |
|
|
virtual |
◆ copyTestBenchFiles()
void ProGeTestBenchGenerator::copyTestBenchFiles |
( |
const std::string & |
dstDirectory | ) |
|
|
private |
Copies general testbench files to given destination directory.
- Parameters
-
dstDirectory | Destination directory for test bench files. |
Definition at line 571 of file ProGeTestBenchGenerator.cc.
581 sourceDir = sourceDir +
DS +
"tb";
582 std::list<string> foundSourceFiles;
584 string vhdlRegex = ((
language_==
VHDL)?
".*\\.vhdl$":
".*\\.v*$");
586 std::list<string>::iterator it = foundSourceFiles.begin();
587 while (it != foundSourceFiles.end()) {
598 "legacy_testbench.vhdl.tmpl":
"legacy_testbench.v.tmpl"),
604 sourceDir +
DS +
"proc_ent.vhdl.tmpl",
605 dstDirectory +
DS +
"proc_ent.vhdl");
References FileSystem::copy(), FileSystem::createDirectory(), Environment::dataDirPath(), FileSystem::DIRECTORY_SEPARATOR, DS, FileSystem::fileIsDirectory(), FileSystem::findFromDirectory(), HDLTemplateInstantiator::instantiateTemplateFile(), HDLTemplateInstantiator::setEntityString(), and ProGe::VHDL.
◆ createFile()
void ProGeTestBenchGenerator::createFile |
( |
const std::string & |
fileName | ) |
|
|
private |
◆ createProcArchVhdl()
void ProGeTestBenchGenerator::createProcArchVhdl |
( |
const std::string & |
dstDirectory, |
|
|
const std::string & |
topLevelVhdl, |
|
|
const std::string & |
signalMappings |
|
) |
| |
|
private |
Creates a new proc_arch vhdl file from a template file.
Writes a new toplevel and core signal mapping.
- Parameters
-
dstDirectory | Directory where new proc_arch file is created. |
topLevelVhdl | Toplevel vhdl file where toplevel is read for writing to the proc_arch file. |
signalMappings | Core signal mappings as a string to be writen to the proc_arch file. |
- Exceptions
-
Definition at line 351 of file ProGeTestBenchGenerator.cc.
355 string eMsg =
"File was not readable: " + topLevelVhdl;
360 string startRE,endRE;
362 startRE = std::string(
".*entity.") +
entityStr_ +
".is.*";
363 endRE = std::string(
".*end.") +
entityStr_ +
";.*";
365 startRE = std::string(
".*module.") +
entityStr_;
366 endRE = std::string(
".*endmodule.*");
372 topLevelVhdl, startRE, endRE, block,
false);
374 if (!ok || block ==
"")
377 "Could not read processor entity from ") +
384 ((
language_==
VHDL)?
"proc_arch.vhdl.tmpl":
"proc_arch.v.tmpl");
398 string eMsg =
"File was not readable: " + procArch;
404 startRE = std::string(
".*component.") +
entityStr_ +
".*";
405 endRE = std::string(
".*end.component;.*");
409 string eMsg =
"Could not write toplevel to: " + procArch;
416 startRE = std::string(
".*core.:.") +
entityStr_ +
".*";
417 endRE =
".*datamem.:.synch_dualport_sram.*";
419 startRE =
entityStr_ + std::string(
".*core.*");
420 endRE =
".*synch_dualport_sram.*";
425 string eMsg =
"Could not write core to: " + procArch;
References __func__, FileSystem::appendReplaceFile(), Environment::dataDirPath(), FileSystem::DIRECTORY_SEPARATOR, FileSystem::fileIsReadable(), FileSystem::fileIsWritable(), HDLTemplateInstantiator::instantiateTemplateFile(), FileSystem::readBlockFromFile(), HDLTemplateInstantiator::setEntityString(), and ProGe::VHDL.
◆ createTBConstFile()
void ProGeTestBenchGenerator::createTBConstFile |
( |
std::string |
dstDirectory, |
|
|
const std::string & |
dmemImage = "dmem_init.img" , |
|
|
const std::string & |
dataWidth = "" , |
|
|
const std::string & |
addrWidth = "" |
|
) |
| |
|
private |
Creates test bench constants package vhdl file.
- Parameters
-
dstDirectory | Directory where the file is created. |
dataWidth | Memory data width. |
addrWidth | Memory address width. |
Definition at line 499 of file ProGeTestBenchGenerator.cc.
504 :
"testbench_constants_pkg.vh");
508 std::ofstream stream(dstFile.c_str(), std::ofstream::out);
510 stream <<
"package testbench_constants is" << endl
511 <<
"-- width of the data memory" << endl
512 <<
"constant DMEMDATAWIDTH : positive := "
513 << ((dataWidth.empty()) ?
"1" : dataWidth) <<
";" << endl
515 <<
"-- address width of the data memory" << endl
516 <<
"constant DMEMADDRWIDTH : positive := "
517 << ((addrWidth.empty()) ?
"1" : addrWidth) <<
";" << endl
519 <<
"-- simulation run time" << endl
520 <<
"constant RUNTIME : time := 5234 * 10 ns;" << endl
522 <<
"-- memory init files" << endl
523 <<
"constant DMEM_INIT_FILE : string := "
524 << ((dataWidth.empty())
530 <<
"constant IMEM_INIT_FILE : string := "
534 <<
"end testbench_constants;" << endl;
536 stream <<
"// width of the data memory" << endl
537 <<
"parameter DMEMDATAWIDTH = "
538 << ((dataWidth.empty()) ?
"1" : dataWidth) <<
"," << endl
540 <<
"// address width of the data memory" << endl
541 <<
"parameter DMEMADDRWIDTH = "
542 << ((addrWidth.empty()) ?
"1" : addrWidth) <<
"," << endl
544 <<
"// simulation run time" << endl
545 <<
"parameter RUNTIME = `SIMTIME,// ns" << endl
547 <<
"// memory init files" << endl
548 <<
"parameter DMEM_INIT_FILE = "
549 << ((dataWidth.empty())
555 <<
"parameter IMEM_INIT_FILE = "
556 << ((addrWidth.empty())
References FileSystem::DIRECTORY_SEPARATOR, and ProGe::VHDL.
◆ generate()
Generates testbench to given destination directory.
At the moment multiple address spaces for FUs are not supported. Only one data memory and instruction memory are usable. There is no code for generating new memory components, this is a todo item for later. There is also additional limit that at most two function units can use the one address space. Most of the TODO comments mark the places where code needs to be changed to accomodate the removal of these limitations.
- Parameters
-
mach | Machine for which test bench is generated |
implementation | Implementation of the machine |
dstDirectory | Destination directory where test bench is generated |
progeOutDir | Processor generators output directory |
- Exceptions
-
Definition at line 119 of file ProGeTestBenchGenerator.cc.
127 std::map<string, std::vector<FunctionUnit*> > ASFUs;
131 const unsigned int FUSPERAS = 2;
135 for (
int i = 0; i < FUNav.
count(); ++i) {
138 if (
FU->hasAddressSpace()) {
141 std::map<string, std::vector<FunctionUnit*> >::iterator it
142 = ASFUs.find(AS->
name());
143 if (it != ASFUs.end()) {
146 if (it->second.size() < FUSPERAS) {
147 it->second.push_back(
FU);
151 "More than two FUs use same address space.\n");
155 std::vector<FunctionUnit*> FUList;
156 FUList.push_back(
FU);
157 ASFUs.insert(make_pair(AS->
name(), FUList));
162 if (ASFUs.size() > 1) {
164 string eMsg =
"More than one address space used by FUs.";
179 const string MEMORYNAME =
"dmem";
180 std::map<string, std::vector<FunctionUnit*> >::iterator it
182 std::map<string, std::vector<FunctionUnit*> >::iterator it_secLast
183 = (ASFUs.empty()) ? ASFUs.end() : --(ASFUs.end());
185 while (it != ASFUs.end()) {
188 for (
unsigned int i = 0; i < it->second.size(); ++i) {
197 HDBManager& manager = HDBRegistry::instance().hdb(
213 ((i > 0) ?
"b" :
"a")));
215 if (it == it_secLast && (i+1) == it->second.size() &&
218 LSUMap.append(
");\n");
220 LSUMap.append(
",\n");
230 string dmemImageFilename(
"dmem_");
231 if (ASFUs.size() == 1) {
233 ASFUs.begin()->second.at(0)->addressSpace()->name();
234 dmemImageFilename +=
"_";
236 dmemImageFilename +=
"init.img";
241 if (string::npos != param.
name.find(
"dataw")
242 && param.
type ==
"integer") {
244 if (param.
value.length() < 1) {
250 dataWidth = param.
value;
253 && param.
type ==
"integer") {
258 static_cast<int>(ceil(log(AS->
end()) / log(2))));
271 if (widthFormula.empty()) {
272 addrWidth = internalAddrWidth;
282 dstDirectory, dmemImageFilename, dataWidth, addrWidth);
292 if (language ==
VHDL) {
298 "imem_en_x => imem_en_x,\n"
299 "imem_addr => imem_addr,\n"
300 "imem_data => imem_data,\n"
305 LSUMapConst.append(
",\n"
306 "db_pc_start => (others => '0'),\n"
307 "db_tta_nreset => '1',\n"
315 ".imem_en_x (imem_en_x),\n"
316 ".imem_addr (imem_addr),\n"
317 ".imem_data (imem_data)";
320 if (LSUMap.length() < 1) {
321 LSUMapConst.append(
");\n");
323 LSUMapConst.append(
",\n");
325 LSUMapConst.append(LSUMap);
330 ((language ==
VHDL) ?
"vhdl" :
"verilog") +
332 ((language ==
VHDL) ?
".vhdl" :
".v");
References __func__, ADDR_WIDTH, TTAMachine::Machine::Navigator< ComponentType >::count(), FileSystem::DIRECTORY_SEPARATOR, TTAMachine::AddressSpace::end(), Exception::errorMessage(), HDB::FUImplementation::externalPort(), HDB::FUImplementation::externalPortCount(), FU, HDB::HDBManager::fuByEntryID(), IDF::MachineImplementation::fuImplementation(), TTAMachine::Machine::functionUnitNavigator(), IDF::UnitImplementationLocation::hdbFile(), IDF::MachineImplementation::icDecoderParameterValue(), IDF::UnitImplementationLocation::id(), HDB::FUEntry::implementation(), implementation, TTAMachine::Machine::Navigator< ComponentType >::item(), HDB::Parameter::name, HDB::ExternalPort::name(), TTAMachine::Component::name(), HDB::FUImplementation::parameter(), HDB::FUImplementation::parameterCount(), TTAMachine::HWOperation::port(), StringTools::replaceAllOccurrences(), Conversion::toString(), HDB::Parameter::type, HDB::Parameter::value, ProGe::VHDL, TTAMachine::BaseFUPort::width(), and HDB::ExternalPort::widthFormula().
Referenced by ProGe::ProGeUI::generateTestBench().
◆ getSignalMapping()
std::string ProGeTestBenchGenerator::getSignalMapping |
( |
const std::string & |
fuName, |
|
|
const std::string & |
epName, |
|
|
bool |
widthIsOne, |
|
|
const std::string & |
memoryName, |
|
|
const std::string & |
memoryLine |
|
) |
| |
|
private |
Creates core signal mapping for FUs external port -> data memory.
Maps signals according to some defined naming "standard".
- Parameters
-
fuName | Function unit name. |
epName | External port name. |
widthIsOne | True if port width is one, false otherwise. |
memoryName | Memory name. |
memoryLine | Memory port that is used (for dual port memory a or b). |
- Returns
- Signal mapping as a string.
- Exceptions
-
InvalidName | External port name was invalid (not matching). |
Definition at line 446 of file ProGeTestBenchGenerator.cc.
449 const string sep =
"_";
452 string fuSignalName(
"fu" + sep);
454 fuSignalName.append(fuName + sep + epName + ((widthIsOne) ?
"(0)" :
""));
456 fuSignalName.append(fuName + sep + epName);
459 string memSignalName(memoryName + sep);
461 if (epName ==
"data_in") {
462 memSignalName.append(
"q" + sep + memoryLine);
464 if (epName ==
"data_out") {
465 memSignalName.append(
"d" + sep + memoryLine);
467 if (epName ==
"addr") {
468 memSignalName.append(epName + sep + memoryLine);
470 if (epName ==
"mem_en_x") {
471 memSignalName.append(
"en" + sep + memoryLine + sep +
"x");
473 if (epName ==
"wr_en_x") {
474 memSignalName.append(
"wr" + sep + memoryLine + sep +
"x");
476 if (epName ==
"wr_mask_x") {
477 memSignalName.append(
"bit" + sep +
"wr" + sep + memoryLine + sep
480 string eMsg =
"External port name didn't match any: " + epName;
486 return string(fuSignalName +
" => " + memSignalName);
488 return string(
"."+fuSignalName +
"(" + memSignalName +
")");
References __func__, and ProGe::VHDL.
◆ entityStr_
TCEString ProGeTestBenchGenerator::entityStr_ |
|
private |
◆ language_
The documentation for this class was generated from the following files:
void copyTestBenchFiles(const std::string &dstDirectory)
void createFile(const std::string &fileName)
static bool removeFileOrDirectory(const std::string &path)
static bool createDirectory(const std::string &path)
virtual TCEString name() const
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
FUExternalPort & externalPort(int index) const
static bool findFromDirectory(const std::string ®ex, const std::string &directory, STLCONT &found)
static std::string toString(const T &source)
int parameterCount() const
std::string icDecoderParameterValue(const std::string &name) const
virtual FUPort * port(int operand) const
static bool fileIsDirectory(const std::string fileName)
static bool fileIsWritable(const std::string fileName)
virtual FunctionUnitNavigator functionUnitNavigator() const
static void copy(const std::string &source, const std::string &target)
std::string type
Type of the parameter.
void createProcArchVhdl(const std::string &dstDirectory, const std::string &topLevelVhdl, const std::string &signalMappings)
static bool createFile(const std::string &file)
std::string errorMessage() const
void createTBConstFile(std::string dstDirectory, const std::string &dmemImage="dmem_init.img", const std::string &dataWidth="", const std::string &addrWidth="")
static bool readBlockFromFile(const std::string &sourceFile, const std::string &blockStartRE, const std::string &blockEndRE, std::string &readBlock, const bool includeMatchingLines=true)
static const std::string DIRECTORY_SEPARATOR
std::string name
Name of the parameter.
void setEntityString(const TCEString &entityStr)
Parameter parameter(int index) const
static bool appendReplaceFile(const std::string &targetFile, const std::string &ARStartRE, const std::string &writeToFile, const std::string &AREndRE="", const bool discardBlockBorder="true")
std::string getSignalMapping(const std::string &fuName, const std::string &epName, bool widthIsOne, const std::string &memoryName, const std::string &memoryLine)
std::string value
Value of the parameter.
ComponentType * item(int index) const
virtual std::string hdbFile() const
void instantiateTemplateFile(const std::string &templateFile, const std::string &dstFile)
FUImplementationLocation & fuImplementation(const std::string &fu) const
FUImplementation & implementation() const
static bool fileIsReadable(const std::string fileName)
FUEntry * fuByEntryID(RowID id) const
virtual ULongWord end() const
std::string widthFormula() const
int externalPortCount() const
virtual int width() const
static std::string dataDirPath(const std::string &prog)