73 #include "config_BOOST_INCLUDE_DIR.hpp" 83 : HLSMgr(_HLSMgr),
parameters(_parameters), debug_level(_parameters->get_class_debug_level(
GET_CLASS(*this)))
89 #define NAMESEPARATOR "_" 100 return std::max(8ULL, ceil_pow2(value));
104 unsigned int firstIndexToSpecialize,
const std::vector<std::tuple<unsigned int, unsigned int>>& required_variables,
107 std::string fu_name =
"";
109 for(
const auto& required_variable : required_variables)
111 if(
index >= firstIndexToSpecialize)
113 const auto typeRef =
getDataType(std::get<0>(required_variable), FB);
114 const auto dataSize = typeRef->vector_size != 0
U ? typeRef->vector_size : typeRef->size;
124 const std::vector<std::tuple<unsigned int, unsigned int>>& required_variables,
HDLWriter_Language language)
127 "ModuleGeneratorManager @ Loading generator class '" << hdl_template <<
"'...");
130 THROW_ASSERT(module_generator,
"Unknown module generator required: " + hdl_template);
134 std::vector<ModuleGenerator::parameter> _p;
135 if(required_variables.size())
138 const auto FB =
HLSMgr->CGetFunctionBehavior(function_id);
139 for(
const auto& required_variable : required_variables)
141 const auto typeRef =
getDataType(std::get<0>(required_variable), FB);
143 param.
name =
"in" +
STR(portNum + 1
U);
144 param.
type = typeRef->get_name();
145 const auto dataSize = typeRef->vector_size != 0
U ? typeRef->vector_size : typeRef->size;
148 _p.push_back(std::move(param));
153 std::stringstream HDLOutput;
154 module_generator->Exec(HDLOutput, mod, function_id, op_v, _p, language);
160 return HDLOutput.str();
165 original_port->
copy(gen_port);
171 const std::string& libraryId,
const std::string& new_fu_name,
172 std::map<std::string, technology_nodeRef>& new_fu)
176 if(new_fu.count(new_fu_name))
182 const auto HLS_D =
HLSMgr->get_HLS_device();
184 const auto libraryManager = HLS_D->get_technology_manager()->get_library_manager(libraryId);
185 const auto techNode_obj = libraryManager->get_fu(fu_name);
187 const auto structManager_obj = GetPointerS<const functional_unit>(techNode_obj)->CM;
188 const auto fu_obj = structManager_obj->get_circ();
189 const auto fu_module = GetPointer<const module>(fu_obj);
192 const auto required_variables =
194 std::vector<HLS_manager::io_binding_type>();
196 const auto multiplicitiy = fu_module->get_multi_unit_multiplicity();
203 const auto top_module = GetPointerS<module>(
top);
204 top_module->set_generated();
206 top_module->set_description(fu_module->get_description());
207 top_module->set_copyright(fu_module->get_copyright());
208 top_module->set_authors(fu_module->get_authors());
209 top_module->set_license(fu_module->get_license());
210 for(
const auto& module_parameter : fu_module->GetParameters())
212 top_module->
AddParameter(module_parameter.first, fu_module->GetDefaultParameter(module_parameter.first));
213 top_module->SetParameter(module_parameter.first, module_parameter.second);
215 top_module->set_multi_unit_multiplicity(multiplicitiy);
225 for(
auto i = 0
U; i < fu_module->get_in_port_size(); i++)
227 const auto curr_port = fu_module->get_in_port(i);
228 const auto port_name = curr_port->get_id();
233 if(GetPointerS<port_o>(curr_port)->get_is_var_args())
237 for(
const auto& required_variable : required_variables)
239 if(indexPort >= (i - toSkip))
241 const auto gen_port_name =
"in" +
STR(portNum + i - toSkip);
242 const auto var = std::get<0>(required_variable);
245 if(dt->vector_size == 0)
257 const auto ps = GetPointerS<port_o>(curr_port)->get_ports_size();
258 THROW_ASSERT(multiplicitiy == ps,
"unexpected condition " +
STR(multiplicitiy) +
" " +
STR(ps));
263 gen_port = CM->
add_port(gen_port_name, port_o::IN,
top, dt);
267 param_list = param_list +
" " + gen_port_name;
280 const auto ps = GetPointerS<const port_o>(curr_port)->get_ports_size();
281 THROW_ASSERT(multiplicitiy == ps,
"unexpected condition");
282 gen_port = CM->
add_port_vector(port_name, port_o::IN, ps,
top, curr_port->get_typeRef());
286 gen_port = CM->
add_port_vector(port_name, port_o::IN, n_ports,
top, curr_port->get_typeRef());
291 gen_port = CM->
add_port(port_name, port_o::IN,
top, curr_port->get_typeRef());
300 for(
auto i = 0
U; i < fu_module->get_out_port_size(); i++)
302 const auto curr_port = fu_module->get_out_port(i);
308 const auto ps = GetPointerS<const port_o>(curr_port)->get_ports_size();
309 THROW_ASSERT(multiplicitiy == ps,
"unexpected condition");
310 gen_port = CM->
add_port_vector(curr_port->get_id(), port_o::OUT, ps,
top, curr_port->get_typeRef());
314 gen_port = CM->
add_port_vector(curr_port->get_id(), port_o::OUT, n_ports,
top, curr_port->get_typeRef());
319 gen_port = CM->
add_port(curr_port->get_id(), port_o::OUT,
top, curr_port->get_typeRef());
326 const auto np = fu_module->get_NP_functionality();
327 const auto required_language =
341 THROW_ERROR(
"Missing VHDL GENERATOR for " + fu_name);
358 const auto hdl_template = fu_module->get_NP_functionality()->get_NP_functionality(
363 ve, required_variables, writer);
372 const auto fu = GetPointerS<functional_unit>(new_techNode_obj);
373 if(GetPointerS<const functional_unit>(techNode_obj)->area_m)
377 fu->functional_unit_name = new_fu_name;
379 const auto op_vec = GetPointerS<const functional_unit>(techNode_obj)->get_operations();
380 for(
const auto& techNode_fu : op_vec)
382 fu->add(techNode_fu);
385 new_fu.insert(std::make_pair(new_fu_name, new_techNode_obj));
393 const std::string& new_fu_name)
395 const auto HLS_D =
HLSMgr->get_HLS_device();
396 const auto TechM = HLS_D->get_technology_manager();
398 const auto libraryManager = TechM->get_library_manager(libraryId);
399 const auto techNode_obj = libraryManager->get_fu(fu_name);
401 const auto structManager_obj = GetPointerS<const functional_unit>(techNode_obj)->CM;
402 const auto fu_obj = structManager_obj->get_circ();
403 const auto fu_module = GetPointer<const module>(fu_obj);
405 const auto multiplicitiy = fu_module->get_multi_unit_multiplicity();
410 TechM->add_resource(libraryId, new_fu_name, CM);
411 const auto fu = GetPointerS<functional_unit>(TechM->get_fu(new_fu_name, libraryId));
413 fu->area_m->set_area_value(0);
414 const auto& op_vec = GetPointerS<functional_unit>(techNode_obj)->get_operations();
415 for(
const auto& techNode_fu : op_vec)
417 fu->add(techNode_fu);
424 const auto top_module = GetPointerS<module>(
top);
425 top_module->set_generated();
427 top_module->set_description(fu_module->get_description());
428 top_module->set_copyright(fu_module->get_copyright());
429 top_module->set_authors(fu_module->get_authors());
430 top_module->set_license(fu_module->get_license());
431 for(
const auto& module_parameter : fu_module->GetParameters())
433 top_module->AddParameter(module_parameter.first, fu_module->GetDefaultParameter(module_parameter.first));
434 top_module->SetParameter(module_parameter.first, module_parameter.second);
436 top_module->set_multi_unit_multiplicity(multiplicitiy);
437 const auto NP_parameters =
447 for(
auto i = 0
U; i < fu_module->get_in_port_size(); i++)
449 const auto curr_port = fu_module->get_in_port(i);
450 THROW_ASSERT(!GetPointer<const port_o>(curr_port)->get_is_var_args(),
"unexpected condition");
452 const auto port_name = curr_port->
get_id();
457 const auto ps = GetPointerS<const port_o>(curr_port)->get_ports_size();
458 THROW_ASSERT(multiplicitiy == ps,
"unexpected condition");
459 gen_port = CM->
add_port_vector(port_name, port_o::IN, ps,
top, curr_port->get_typeRef());
463 gen_port = CM->
add_port_vector(port_name, port_o::IN, n_ports,
top, curr_port->get_typeRef());
468 gen_port = CM->
add_port(port_name, port_o::IN,
top, curr_port->get_typeRef());
474 for(
auto i = 0
U; i < fu_module->get_out_port_size(); i++)
476 const auto curr_port = fu_module->get_out_port(i);
482 const auto ps = GetPointerS<const port_o>(curr_port)->get_ports_size();
483 THROW_ASSERT(multiplicitiy == ps,
"unexpected condition");
484 gen_port = CM->
add_port_vector(curr_port->get_id(), port_o::OUT, ps,
top, curr_port->get_typeRef());
488 gen_port = CM->
add_port_vector(curr_port->get_id(), port_o::OUT, n_ports,
top, curr_port->get_typeRef());
493 gen_port = CM->
add_port(curr_port->get_id(), port_o::OUT,
top, curr_port->get_typeRef());
500 const auto np = fu_module->get_NP_functionality();
501 const auto required_language =
514 THROW_ERROR(
"Missing VHDL GENERATOR for " + fu_name);
530 const auto hdl_template = fu_module->get_NP_functionality()->get_NP_functionality(
533 std::vector<std::tuple<unsigned int, unsigned int>> required_variables;
535 required_variables, writer);
structural_type_descriptorRef getDataType(unsigned int variable, const FunctionBehaviorConstRef function_behavior) const
unsigned long long type_size
Data structure representing the entire HLS information.
static refcount< ModuleGenerator > Create(const std::string &s, T &&... args)
void * top(node_stack *head)
Collect information about resource area.
refcount< structural_type_descriptor > structural_type_descriptorRef
RefCount type definition of the structural_type_descriptor class structure.
#define PRINT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
Structure representing the most relevant information about the type of a structural object...
const std::string & get_id() const
Return the identifier associated with the structural_object.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
const structural_objectRef get_circ() const
Get a reference to circ field.
void specialize_fu(const std::string &fu_name, vertex ve, const FunctionBehaviorConstRef FB, const std::string &libraryId, const std::string &new_fu_name, std::map< std::string, technology_nodeRef > &new_fu)
mathematical utility function not provided by standard libraries
This class manages the circuit structures.
ModuleGeneratorManager(const HLS_managerRef HLSMgr, const ParameterConstRef parameters)
Constructor.
unsigned int get_function_index() const
Return the index of the function.
Class specification of the manager of the technology library data structures.
This class specifies the characteristic of a particular functional unit.
unsigned long long alignment
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
unsigned long long size
The size of the object (in bit). The objects having a size are: ports, signals, channels, data, and actions.
virtual void AddParameter(const std::string &name, const std::string &default_value)
Add a parameter.
#define CLOCK_PORT_NAME
standard name for ports
static void add_NP_functionality(structural_objectRef cir, NP_functionality::NP_functionaly_type dt, std::string functionality_description)
Add a not-parsed functionality.
void add_port_parameters(structural_objectRef generated_port, structural_objectRef original_port)
void set_top_info(const std::string &id, const technology_managerRef &LM, const std::string &Library="")
This class writes different HDL based descriptions (VHDL, Verilog, SystemC) starting from a structura...
Class specification of the data structures used to manage technology information. ...
static structural_objectRef add_port(const std::string &id, port_o::port_direction pdir, structural_objectRef owner, structural_type_descriptorRef type_descr, unsigned int treenode=0)
Create a new port.
static unsigned long long resize_to_8_or_greater(unsigned long long value)
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
utility function used to read files.
const BehavioralHelperConstRef CGetBehavioralHelper() const
Returns the helper associated with the function.
Classes specification of the tree_node data structures.
const ParameterConstRef parameters
The set of input parameters.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
This file collects some utility functions.
std::string GenerateHDL(const std::string &hdl_template, structural_objectRef mod, unsigned int function_id, vertex op_v, const std::vector< std::tuple< unsigned int, unsigned int >> &required_variables, HDLWriter_Language language)
const int debug_level
The debug level.
This class describes all classes used to represent a structural object.
const structural_type_descriptorRef & get_typeRef() const
Return the type descriptor of the structural_object.
static area_infoRef factory(const ParameterConstRef &Param)
Factory method.
Class specification of the tree_reindex support class.
virtual void copy(structural_objectRef dest) const
Perform a copy of the structural object.
virtual ~ModuleGeneratorManager()
Destructor.
Data structures used in operations graph.
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.
unsigned int GetChannelsNumber() const
Class implementation of the structural_manager.
std::string get_specialized_name(unsigned int firstIndexToSpecialize, const std::vector< std::tuple< unsigned int, unsigned int >> &required_variables, const FunctionBehaviorConstRef FB) const
Class specification of the manager for each library.
void create_generic_module(const std::string &fu_name, vertex ve, const FunctionBehaviorConstRef FB, const std::string &libraryId, const std::string &new_fu_name)
#define DEBUG_LEVEL_VERBOSE
verbose debugging print is performed.
static structural_objectRef add_port_vector(std::string id, port_o::port_direction pdir, unsigned int n_ports, structural_objectRef owner, structural_type_descriptorRef type_descr, unsigned int treenode=0)
Create a new port_vector.
Datastructure to represent memory information in high-level synthesis.
Class specification of the manager of the tree structures extracted from the raw file.
HLS specialization of generic_device.
A brief description of the C++ Header File.
unsigned long long vector_size
The number of the elements of a vector.
const HLS_managerRef HLSMgr
The HLS manager.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...