66 #include <boost/algorithm/string.hpp>    72                                    const DesignFlowManagerConstRef _design_flow_manager)
    82    switch(relationship_type)
   113    if(
parameters->isOption(OPT_testbench_input_file))
   118          THROW_ASSERT(tb_files.size() == 1, 
"XML testbench initialization must be in a single file.");
   125                         "<--User provided co-simulation files will be used for test vectors generation");
   129    else if(
parameters->isOption(OPT_testbench_input_string))
   131       const auto input_string = 
parameters->getOption<std::string>(OPT_testbench_input_string);
   140                   "<--Number of input test vectors: " + 
STR(
HLSMgr->RSim->test_vectors.size()));
   146    std::vector<std::map<std::string, std::string>> test_vectors;
   148    for(
auto& tb_string : tb_strings)
   151       std::string::iterator last_comma = tb_string.end();
   152       for(
auto it = tb_string.begin(), it_end = tb_string.end(); it != it_end; ++it)
   158          else if(*it == 
'=' && last_comma != it_end)
   164       test_vectors.push_back(std::map<std::string, std::string>());
   165       std::vector<std::string> testbench_parameters = 
SplitString(tb_string, 
"$");
   166       for(
const auto& parameter : testbench_parameters)
   169          std::vector<std::string> temp = 
SplitString(parameter, 
"=");
   172             THROW_ERROR(
"Error in processing --generate-tb arg");
   175          test_vectors.back()[temp[0]] = temp[1];
   182 std::vector<std::map<std::string, std::string>>
   185    const auto CGM = 
HLSMgr->CGetCallGraphManager();
   186    THROW_ASSERT(boost::num_vertices(*(CGM->CGetCallGraph())) != 0, 
"The call graph has not been computed yet");
   187    const auto top_symbols = 
parameters->getOption<std::vector<std::string>>(OPT_top_functions_names);
   188    THROW_ASSERT(top_symbols.size() == 1, 
"Expected single top function name");
   189    const auto top_fnode = 
HLSMgr->get_tree_manager()->GetFunction(top_symbols.front());
   192    if(!std::filesystem::exists(input_xml_filename))
   195                     "\" cannot be opened, creating a stub with random values");
   200       for(
const auto& function_parameter : BH->GetParameters())
   204             THROW_UNREACHABLE(
"Random testbench parameters generation is not available for pointer parameters. Please "   205                               "provide a valid testbench XML file.");
   208          const auto param = BH->PrintVariable(function_parameter->index);
   210          auto value = (rand() % 20);
   218       document.write_to_file_formatted(input_xml_filename);
   226          std::vector<std::map<std::string, std::string>> test_vectors;
   231          for(
const auto& iter : list)
   233             const auto* Enode = GetPointer<const xml_element>(iter);
   235             if(!Enode || Enode->get_name() != 
"testbench")
   240             std::map<std::string, std::string> test_vector;
   242             for(
const auto function_parameter : BH->get_parameters())
   244                std::string 
param = BH->PrintVariable(function_parameter);
   246                               "Parameter: " + param +
   247                                   (BH->is_a_pointer(function_parameter) ? 
" (memory access)" : 
" (input value)"));
   248                if((Enode)->get_attribute(param))
   250                   test_vector[
param] = 
STR((Enode)->get_attribute(param)->get_value());
   252                else if((Enode)->get_attribute(param + 
":init_file"))
   254                   const auto input_file_name = 
GetPath(input_xml_filename.parent_path()) + 
"/" +
   255                                                Enode->get_attribute(param + 
":init_file")->get_value();
   258                      test_vector[
param] = input_file_name;
   264                          std::string(std::istreambuf_iterator<char>(*input_file), std::istreambuf_iterator<char>());
   267                else if(!BH->is_a_pointer(function_parameter))
   269                   THROW_ERROR(
"Missing input value for parameter: " + param);
   272             test_vectors.emplace_back(std::move(test_vector));
   277    catch(
const char* msg)
   279       std::cerr << msg << std::endl;
   281    catch(
const std::string& msg)
   283       std::cerr << msg << std::endl;
   285    catch(
const std::exception& ex)
   287       std::cout << 
"Exception caught: " << ex.what() << std::endl;
   291       std::cerr << 
"unknown exception" << std::endl;
   293    THROW_ERROR(
"Error parsing the test vectors file " + input_xml_filename.string());
   294    return std::vector<std::map<std::string, std::string>>();
 #define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed. 
 
const HLS_managerRef HLSMgr
information about all the HLS synthesis 
 
Data structure representing the entire HLS information. 
 
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;. 
 
File containing functions and utilities to support the printing of debug messagges. 
 
#define DEBUG_LEVEL_PEDANTIC
very verbose debugging print is performed. 
 
std::vector< std::map< std::string, std::string > > ParseUserString(const std::string &input_string) const
Parse a user defined string extracting the test vectors. 
 
#define STR_CST_string_separator
The character used to separate concatenated string. 
 
#define GET_CLASS(obj)
Macro returning the actual type of an object. 
 
const std::vector< std::string > SplitString(const std::string &input, const std::string &separators)
Function which splits a string into tokens. 
 
TestVectorParser(const ParameterConstRef _parameters, const HLS_managerRef _HLSMgr, const DesignFlowManagerConstRef _design_flow_manager)
 
RelationshipType
The relationship type. 
 
Source must be executed to satisfy target. 
 
exceptions managed by PandA 
 
#define THROW_WARNING(str_expr)
helper function used to throw a warning in a standard way: though it uses PRINT_DBG_MEX, the debug level used is such that the message is always printed 
 
#define STR(s)
Macro which performs a lexical_cast to a string. 
 
Auxiliary methods for manipulating string. 
 
bool HasToBeExecuted() const override
Check if this step has actually to be executed. 
 
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached 
 
DesignFlowStep_Status Exec() override
Execute the step. 
 
Factory for hls flow step. 
 
static bool IsBooleanType(const tree_nodeConstRef &type)
Return true if the treenode is of bool type. 
 
Classes to describe design flow graph. 
 
Target must be reexecuted. 
 
redefinition of set to manage ordered/unordered structures 
 
xml_element * create_root_node(const std::string &_name)
Creates the root node. 
 
utility function used to read files. 
 
bool ends_with(const std::string &str, const std::string &pattern)
 
const ParameterConstRef parameters
Set of input parameters. 
 
DesignFlowStep_Status
The status of a step. 
 
This file collects some utility functions and macros. 
 
fileIO_istreamRef fileIO_istream_open(const std::string &name)
this function returns an istream compressed or not. 
 
std::list< xml_nodeRef > node_list
type for list of xml nodes 
 
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way 
 
This file collects some utility functions. 
 
std::string GetPath(std::filesystem::path path)
 
Class specification of the tree_reindex support class. 
 
std::vector< std::map< std::string, std::string > > ParseXMLFile(const std::filesystem::path &input_xml) const
Parse a user defined xml file extracting the test vectors. 
 
This class contains the methods to create a frontend flow step. 
 
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
 
this class is used to manage the command-line or XML options. 
 
node_list const  & get_children()
Obtain the list of child nodes. 
 
int debug_level
The debug level. 
 
refcount< const HLSFlowStepSpecialization > HLSFlowStepSpecializationConstRef
const refcount definition of the class 
 
#define GET_INDEX_CONST_NODE(t)
 
const CustomUnorderedSet< std::tuple< HLSFlowStep_Type, HLSFlowStepSpecializationConstRef, HLSFlowStep_Relationship > > ComputeHLSRelationships(const DesignFlowStep::RelationshipType relationship_type) const override
Return the set of analyses in relationship with this design step. 
 
static bool IsPointerType(const tree_nodeConstRef &type)
Return true if treenode index is a pointer. 
 
This class contains the base representation for a generic frontend flow step which works on the whole...
 
xml_element * add_child_element(const std::string &name)
Add a child element to this node. 
 
Class specification of the manager of the tree structures extracted from the raw file. 
 
A brief description of the C++ Header File. 
 
#define DEBUG_LEVEL_MINIMUM
minimum debugging print is performed. 
 
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...