Go to the documentation of this file.
39 #include <boost/format.hpp>
49 using std::ostringstream;
55 "testbench.vhdl.template";
58 componentDeclaration_(), componentBinding_(), signalDeclaration_(),
59 componentInstantiation_(), inputArrays_(), opcodeArrays_(),
60 loadSignalArrays_(), outputArrays_(), testbenchCode_() {
69 std::ostringstream& stream,
70 std::vector<uint32_t>& dataArray, std::string portName,
int portWidth) {
74 <<
"_data_array is array (natural range <>) of" << std::endl
76 <<
"std_logic_vector(" << portWidth - 1 <<
" downto 0);"
78 <<
"constant " << portName <<
"_data : "
79 << portName <<
"_data_array :=" << std::endl;
81 for (std::size_t i = 0; i < dataArray.size(); ++i) {
82 uint32_t input = dataArray.at(i);
83 std::string inputAsBinaryLiteral =
92 stream <<
"\"" << inputAsBinaryLiteral <<
"\"";
93 if (i == dataArray.size() - 1) {
98 stream <<
"\t -- @" << i <<
" = " << input << std::endl;
105 int totalCycles,
int outputIgnoreCycles) {
108 <<
INDENT INDENT <<
"constant IGNORE_OUTPUT_COUNT : integer := "
109 << outputIgnoreCycles <<
";" << std::endl;
111 <<
INDENT INDENT <<
"constant TOTAL_CYCLE_COUNT : integer := "
112 << totalCycles <<
";" << std::endl;
120 string vhdlTemplate =
"";
124 (boost::format(vhdlTemplate)
145 for (
unsigned int i = 0; i < paths.size(); i++) {
158 string notFound =
"";
164 const std::string& fileName, std::string& vhdlTemplate)
const {
166 ifstream input(fileName.c_str());
167 if (!input.is_open()) {
169 "The VHDL template file " + fileName +
175 while (getline(input, line)) {
176 vhdlTemplate += line;
177 vhdlTemplate +=
"\n";
std::ostringstream & bindingStream()
std::string clkPort() const
std::ostringstream & tbCodeStream()
void writeTestbench(std::ofstream &file, HDB::HWBlockImplementation *impl)
std::ostringstream & opcodeArrayStream()
std::ostringstream & instantiationStream()
void writeTbConstants(int totalCycles, int outputIgnoreCycles)
std::ostringstream componentDeclaration_
std::ostringstream inputArrays_
std::ostringstream & inputArrayStream()
virtual void writeStimulusArray(std::ostringstream &stream, std::vector< uint32_t > &dataArray, std::string portName, int portWidth)
static std::vector< std::string > implementationTesterTemplatePaths()
std::string rstPort() const
static const std::string TB_TEMPLATE_
std::ostringstream componentBinding_
std::ostringstream & declarationStream()
static std::string toBinary(unsigned int source, unsigned int stringWidth=0)
std::ostringstream loadSignalArrays_
std::ostringstream & signalStream()
std::ostringstream componentInstantiation_
std::ostringstream opcodeArrays_
virtual ~TestbenchGenerator()
static const std::string DIRECTORY_SEPARATOR
std::string findVhdlTemplate() const
static bool fileExists(const std::string fileName)
std::ostringstream & loadArrayStream()
void loadVhdlTemplate(const std::string &fileName, std::string &vhdlTemplate) const
std::string glockPort() const
std::ostringstream signalDeclaration_
std::ostringstream & outputArrayStream()
std::ostringstream outputArrays_
std::ostringstream testbenchCode_