68 #define MAX_BITWIDTH_SIZE 4096 70 #if defined(__clang__) 71 #pragma clang diagnostic push 72 #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" 73 #pragma clang diagnostic ignored "-Wsign-conversion" 74 #pragma clang diagnostic ignored "-Wswitch-enum" 76 #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" 77 #pragma GCC diagnostic ignored "-Wsign-conversion" 78 #pragma GCC diagnostic ignored "-Wswitch-enum" 81 #define PUGIXML_HEADER_ONLY 82 #include <pugixml.hpp> 84 #if defined(__clang__) 85 #pragma clang diagnostic pop 87 #pragma GCC diagnostic pop 102 if(
Param->isOption(OPT_context_switch))
125 return hlsMap.find(funId)->second;
136 const std::deque<vertex>& OperationsList = HLSMgr->CGetFunctionBehavior(functionId)->get_levels();
138 Operations.insert(OperationsList.begin(), OperationsList.end());
139 if(HLSMgr->hlsMap.find(functionId) == HLSMgr->hlsMap.end())
144 for(
const auto& globalRC : HLSMgr->global_resource_constraints)
146 if(HLS_C->get_number_fu(globalRC.first.first, globalRC.first.second) ==
INFINITE_UINT)
148 HLS_C->set_number_fu(globalRC.first.first, globalRC.first.second, globalRC.second.first);
151 HLSMgr->hlsMap[functionId] =
152 hlsRef(
new hls(HLSMgr->get_parameter(), functionId, Operations, HLSMgr->get_HLS_device(), HLS_C));
156 HLSMgr->hlsMap[functionId]->operations = Operations;
158 return HLSMgr->hlsMap[functionId];
163 std::string trimmed_value;
169 const auto rc = GetPointerS<const real_cst>(
GET_CONST_NODE(node));
170 std::string C_value = rc->valr;
175 if(C_value ==
"Nan" && rc->valx[0] ==
'-')
183 const auto vc = GetPointerS<const vector_cst>(
GET_CONST_NODE(node));
184 auto n_elm =
static_cast<unsigned int>(vc->list_of_valu.size());
185 auto elm_prec = precision / n_elm;
187 for(
unsigned int i = 0; i < n_elm; ++i)
194 const auto cc = GetPointerS<const complex_cst>(
GET_CONST_NODE(node));
195 const auto rcc = GetPointer<const real_cst>(
GET_CONST_NODE(cc->real));
196 std::string trimmed_value_r;
199 std::string C_value_r = rcc->valr;
200 if(C_value_r ==
"Inf")
202 C_value_r = rcc->valx;
210 const auto icc = GetPointer<const real_cst>(
GET_CONST_NODE(cc->imag));
211 std::string trimmed_value_i;
214 std::string C_value_i = icc->valr;
215 if(C_value_i ==
"Inf")
217 C_value_i = icc->valx;
225 trimmed_value = trimmed_value_i + trimmed_value_r;
231 return trimmed_value;
257 catch(
const char* msg)
259 std::cerr << msg << std::endl;
261 catch(
const std::string& msg)
263 std::cerr << msg << std::endl;
265 catch(
const std::exception& ex)
267 std::cout <<
"Exception caught: " << ex.what() << std::endl;
271 std::cerr <<
"unknown exception" << std::endl;
279 std::vector<io_binding_type> required;
299 auto fd = GetPointer<function_decl>(fun_node);
301 return fd->reading_memory || fd->writing_memory;
306 if(
Param->getOption<
bool>(OPT_gcc_serialize_memory_accesses))
330 " Requested size: " +
STR(prec));
334 #define __TO_ENUM_HELPER(r, data, elem) {BOOST_PP_STRINGIZE(elem), data::elem}, 335 #define TO_ENUM(enum_type, elem_list) \ 336 static const std::unordered_map<std::string, enum enum_type> to_enum = { \ 337 BOOST_PP_SEQ_FOR_EACH(__TO_ENUM_HELPER, enum_type, elem_list)} 343 return to_enum.at(attr);
350 return to_enum.at(attr);
357 return to_enum.at(attr);
362 pugi::xml_document doc;
364 auto result = doc.load_file(filename.c_str());
365 if(
result.status == pugi::xml_parse_status::status_file_not_found)
369 else if(
result.status != pugi::xml_parse_status::status_ok)
371 THROW_ERROR(
"Unable to parse XML file: " + filename);
373 if((n = doc.child(
"module")))
377 THROW_ASSERT(!f.attribute(
"symbol").empty(),
"Function symbol attribute missing from XML.");
378 auto& fa = _funcArchs[f.attribute(
"symbol").value()] =
380 for(
auto& a : f.attributes())
384 for(
auto& p : f.child(
"parameters"))
386 THROW_ASSERT(!p.attribute(
"port").empty(),
"Parameter name attribute missing from XML.");
387 auto& parm_attrs = fa->parms[p.attribute(
"port").value()];
388 for(
auto& a : p.attributes())
393 for(
auto& i : f.child(
"bundles"))
395 THROW_ASSERT(!i.attribute(
"name").empty(),
"Interface name attribute missing from XML.");
396 auto& iface_attr = fa->ifaces[i.attribute(
"name").value()];
397 for(
auto& a : i.attributes())
410 auto it = _funcArchs.find(funcSymbol);
411 if(it != _funcArchs.end())
420 _funcArchs[symbol] = arch;
425 _funcArchs.erase(funcSymbol);
std::string convert_fp_to_string(std::string num, unsigned long long precision)
convert a real number stored in a string into a string of bits with a given precision ...
static bool IsComplexType(const tree_nodeConstRef &type)
Return if treenode is a complex.
void xwrite(xml_element *node)
Writes the current memory allocation into an XML description.
Data structure representing the entire HLS information.
bool IsSingleWriteMemory() const
Return if single write memory is exploited.
static std::string name_function(const tree_managerConstRef &tm, const unsigned int index)
Return the name of the function.
void AddArchitecture(const std::string &symbol, FunctionArchitectureRef arch)
const tree_nodeRef CGetTreeReindex(const unsigned int i) const
Return a tree_reindex wrapping the i-th tree_node.
~HLS_manager() override
Destructor.
#define FUNC_ARCH_PARM_ATTR_ENUM
ModuleArchitecture(const std::string &filename)
const tree_managerRef TM
class representing the application information at low level
std::string get_constant_string(unsigned int node, unsigned long long precision)
Return the specified constant in string format.
BackendFlowRef back_flow
reference to the data-structure implementing the backend flow
const FunctionBehaviorConstRef CGetFunctionBehavior(unsigned int index) const
Returns the data-structure associated with the given identifier.
static bool is_parameter(const tree_managerConstRef &TM, const unsigned int index)
return true in case the index corresponds to a parameter in ssa form or not
G get_parameter(const std::string &key) const
Returns a parameter by key.
refcount< functions > functionsRef
refcount definition of the class
FunctionArchitectureRef GetArchitecture(const std::string &funcSymbol) const
void xwrite(xml_element *rootnode, const OpGraphConstRef data)
Writes current HLS results to XML node.
#define GET_INDEX_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
static enum func_attr to_func_attr(const std::string &attr)
static void get_required_values(std::vector< std::tuple< unsigned int, unsigned int >> &required, const tree_nodeRef &tn)
static hlsRef create_HLS(const HLS_managerRef HLSMgr, unsigned int functionId)
Creates the HLS flow starting from the given specification.
const ParameterConstRef Param
class containing all the parameters
A set of operation vertices.
HLS_deviceRef HLS_D
information about the target device/technology for the synthesis
#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.
refcount< HLS_constraints > HLS_constraintsRef
refcount definition of the class
unsigned int memory_version
The version of memory representation on which this step was applied.
const BackendFlowRef get_backend_flow()
Returns the backend flow.
const tree_nodeRef get_tree_node_const(unsigned int i) const
Return the reference to the i-th tree_node Constant version of get_tree_node.
const OpNodeInfoConstRef CGetOpNodeInfo(const vertex node) const
Returns the info associated with a node.
std::string convert_to_binary(G _value, unsigned long long precision)
unsigned int UpdateMemVersion()
Update the version of the memory intermediate representation.
#define MAX_BITWIDTH_SIZE
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
static bool is_virtual(const tree_managerConstRef &TM, const unsigned int index)
return true in case the ssa_name is virtual
#define FUNC_ARCH_IFACE_ATTR_ENUM
memoryRef Rmem
information about memory allocation
void write_to_file_formatted(const std::filesystem::path &filename)
Write the document to a file.
xml_element * create_root_node(const std::string &_name)
Creates the root node.
bool is_reading_writing_function(unsigned funID) const
is_reading_writing_function
Datastructure to describe functions allocation in high-level synthesis.
Data structure used to store all the HLS constraints.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
bool is_register_compatible(unsigned int var) const
helper function that return true in case the variable is register compatible
static bool IsVectorType(const tree_nodeConstRef &type)
Return true if the treenode is a vector.
static BackendFlowRef CreateFlow(const ParameterConstRef Param, const std::string &flow_name, const generic_deviceRef _device)
Creates the flow specification based on the given parameters.
#define GET_CONST_NODE(t)
struct definition of the field attr on function_decl, field_decl, var_decl tree node.
This file collects some utility functions and macros.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Data structure definition for HLS constraints.
static void check_bitwidth(unsigned long long prec)
check if the maximum bitwidth used for registers, busses, muxes, etc. is compatible with prec ...
used to avoid expansion of c library function or type
This file collects some utility functions.
hlsRef get_HLS(unsigned int funId) const
Returns the HLS data-structure associated with a specific function.
static bool is_ssa_name(const tree_managerConstRef &TM, const unsigned int index)
Return true in case index is a ssa_name.
static enum iface_attr to_iface_attr(const std::string &attr)
This file contains the definition of the configurable flow for generating and executing synthesis scr...
#define FUNC_ARCH_ATTR_ENUM
Data flow graph with feedback.
Class specification of the tree_reindex support class.
bool has_parameter(const std::string &key) const
Check if parameter exist.
bool has_base_address(unsigned int var) const
Check if there is a base address for the given variable.
HLS_deviceRef get_HLS_device() const
Returns the data-structure associated with the HLS target.
const OpGraphConstRef CGetOpGraph(FunctionBehavior::graph_type gt) const
This method returns the operation graphs.
#define INFINITE_UINT
UNSIGNED INT representing infinite.
const CallGraphManagerRef call_graph_manager
class representing the call graph of the application
std::map< unsigned int, hlsRef > hlsMap
map between the function id and the corresponding HLS data-structure
Data structures used in operations graph.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
static tree_nodeConstRef CGetType(const tree_nodeConstRef &node)
Return the treenode of the type of node.
Classes specification of the tree_node data structures not present in the gcc.
this class is used to manage the command-line or XML options.
void RemoveArchitecture(const std::string &funcSymbol)
std::vector< io_binding_type > get_required_values(unsigned int fun_id, const vertex &v) const
Returns the values required by a vertex.
#define TO_ENUM(enum_type, elem_list)
Some macro used to interface with the XML library.
void xwrite(const std::string &filename)
Writes the current HLS project into an XML file.
Data structure that contains all information about high level synthesis process.
static integer_cst_t GetConstValue(const tree_nodeConstRef &tn, bool is_signed=true)
Get value from integer constant.
refcount< hls > hlsRef
refcount definition of the class
HLS_manager(const ParameterConstRef Param, const HLS_deviceRef HLS_D)
Constructor.
Data structure definition for high-level synthesis flow.
static enum parm_attr to_parm_attr(const std::string &attr)
Datastructure to represent memory information in high-level synthesis.
functionsRef Rfuns
information about function allocation
Class specification of the manager of the tree structures extracted from the raw file.
unsigned int GetMemVersion() const
Return the version of the memory intermediate representation.
HLS specialization of generic_device.
A brief description of the C++ Header File.
static bool IsRealType(const tree_nodeConstRef &type)
Return true if the treenode is of real type.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...