79 unsigned int _funId,
const DesignFlowManagerConstRef _design_flow_manager,
81 :
datapath_creator(_parameters, _HLSMgr, _funId, _design_flow_manager, _hls_flow_step_type)
99 const auto FB =
HLSMgr->CGetFunctionBehavior(
funId);
100 const auto fsymbol = FB->CGetBehavioralHelper()->GetMangledFunctionName();
115 GetPointer<module>(datapath_cir)
116 ->set_description(
"Datapath RTL description for " + FB->CGetBehavioralHelper()->get_function_name());
118 GetPointer<module>(datapath_cir)->set_authors(
"Component automatically generated by bambu");
146 const auto func_arch =
HLSMgr->module_arch->GetArchitecture(fsymbol);
147 const auto is_dataflow_top = func_arch &&
148 func_arch->attrs.find(FunctionArchitecture::func_dataflow) != func_arch->attrs.end() &&
149 func_arch->attrs.find(FunctionArchitecture::func_dataflow)->second ==
"top";
153 const auto CGM =
HLSMgr->CGetCallGraphManager();
154 const auto dataflow_module_ids = CGM->get_called_by(
funId);
155 std::map<std::string, const FunctionArchitecture::iface_attrs*> iface_attrs;
156 std::map<std::string, std::vector<structural_objectRef>> iface_ports;
158 const auto port_name = port->get_id();
161 const auto bundle_id = port_name.substr(1, port_name.find(
'_', 11) - 1);
162 iface_ports[bundle_id].push_back(port);
166 for(
unsigned int n = 0; n < GetPointer<module>(datapath_cir)->get_internal_objects_size(); ++n)
168 const auto member = GetPointer<module>(datapath_cir)->get_internal_object(n);
171 const auto march =
HLSMgr->module_arch->GetArchitecture(msymbol);
173 "Expected function architecture for function " + msymbol);
177 for(
const auto& [bundle, attrs] : march->ifaces)
179 iface_attrs.emplace(bundle, &attrs);
181 for(
unsigned int p = 0; p < GetPointer<module>(member)->get_in_port_size(); ++p)
183 manage_port(GetPointer<module>(member)->get_in_port(p));
185 for(
unsigned int p = 0; p < GetPointer<module>(member)->get_out_port_size(); ++p)
187 manage_port(GetPointer<module>(member)->get_out_port(p));
189 for(
unsigned int p = 0; p < GetPointer<module>(member)->get_in_out_port_size(); ++p)
191 manage_port(GetPointer<module>(member)->get_in_out_port(p));
196 for(
auto& [iface, ports] : iface_ports)
198 const auto attrs = iface_attrs.at(iface);
200 const auto& iface_mode = attrs->at(FunctionArchitecture::iface_mode);
202 if(iface_mode ==
"fifo")
209 THROW_ERROR(
"Dataflow interface not supported: " + iface_mode);
211 const auto if_clock = GetPointer<module>(dataflow_if)->find_member(
"clock",
port_o_K, dataflow_if);
212 const auto if_reset = GetPointer<module>(dataflow_if)->find_member(
"reset",
port_o_K, dataflow_if);
215 for(
auto& port : ports)
217 const auto port_name = port->get_id();
218 const auto port_suffix = port_name.substr(iface.size() + 2);
219 const auto if_port = GetPointer<module>(dataflow_if)->find_member(port_suffix,
port_o_K, dataflow_if);
220 THROW_ASSERT(if_port,
"Expected port " + port_suffix +
" in dataflow interface module " +
229 GetPointerS<port_o>(port)->get_ports_size(), datapath_cir,
230 port->get_typeRef());
235 if_sign =
HLS->
datapath->
add_sign(iface +
"_" + port_suffix, datapath_cir, port->get_typeRef());
249 unsigned int n_elements = GetPointer<module>(datapath_cir)->get_internal_objects_size();
267 if(
parameters->getOption<
bool>(OPT_print_dot))
269 HLS->
datapath->
WriteDot(FB->CGetBehavioralHelper()->get_function_name() +
"/HLS_Datapath.dot",
278 const auto circuit = SM->
get_circ();
285 clock_obj = SM->add_port(
CLOCK_PORT_NAME, port_o::IN, circuit, port_type);
286 GetPointer<port_o>(clock_obj)->set_is_clock(
true);
291 reset_obj = SM->add_port(
RESET_PORT_NAME, port_o::IN, circuit, port_type);
299 bool need_start_done =
false;
303 const auto curr_address_bitsize =
HLSMgr->get_address_bitsize();
306 const std::list<unsigned int>& function_parameters = BH->
get_parameters();
307 for(
auto const function_parameter : function_parameters)
310 "-->Adding port for parameter: " + BH->
PrintVariable(function_parameter) +
" IN");
318 if(
HLSMgr->Rmem->has_base_address(function_parameter) &&
320 !
HLSMgr->Rmem->is_parm_decl_stored(function_parameter))
328 if(
HLSMgr->Rmem->has_base_address(function_parameter) && (
HLSMgr->Rmem->is_parm_decl_stored(function_parameter) ||
329 HLSMgr->Rmem->is_parm_decl_copied(function_parameter)))
331 need_start_done =
true;
334 std::string prefix =
"in_port_";
340 port_obj->set_structural_obj(p_obj);
341 port_obj->set_out_sign(p_obj);
347 unsigned int num = 0;
354 std::string
value = std::get<0>(c.first);
355 std::string
param = std::get<1>(c.first);
356 std::string trimmed_value;
357 unsigned long long precision;
358 if(param.size() == 0)
360 trimmed_value =
"\"" + std::get<0>(c.first) +
"\"";
361 precision =
static_cast<unsigned int>(value.size());
365 trimmed_value =
param;
367 precision = GetPointer<dataport_obj>(constant_obj)->get_bitsize();
371 std::string name =
"out_const_" + std::to_string(num);
384 if(return_type_index)
398 port_obj->set_structural_obj(p_obj);
void add_connection(structural_objectRef src, structural_objectRef dest)
Create a connection between a source structural object and a destination structural object...
#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;.
refcount< structural_type_descriptor > structural_type_descriptorRef
RefCount type definition of the structural_type_descriptor class structure.
File containing functions and utilities to support the printing of debug messagges.
#define PRINT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
#define DEBUG_LEVEL_PEDANTIC
very verbose debugging print is performed.
structural_managerRef datapath
Store the datapath description.
This file contains the structures needed to manage a graph that will represent the state transition g...
Structure representing the most relevant information about the type of a structural object...
const ParameterConstRef Param
class containing all the parameters
virtual void add_ports()
Adds the input/output ports of the module.
Base class for all command ports into datapath.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
#define GENERATED_LICENSE
Generic class managing datapath creation algorithms.
const structural_objectRef get_circ() const
Get a reference to circ field.
virtual void add_to_SM(const HLS_managerRef HLSMgr, const hlsRef HLS, const structural_managerRef SM)
Add the interconnection to the structural representation of the datapath.
generic_objRef get_port(unsigned int var, direction_type dir)
Returns reference to generic object associated to a given variable, for a specific port direction...
const std::map< const_param, generic_objRef > & get_constant_objs() const
const unsigned int funId
identifier of the function to be processed (0 means that it is a global step)
DesignFlowStep_Status InternalExec() override
Execute the step.
Base class for usual datapath creation.
This class manages the circuit structures.
const HLS_deviceRef HLS_D
reference to the information representing the target for the synthesis
exceptions managed by PandA
unsigned int get_function_index() const
Return the index of the function.
virtual structural_objectRef find_member(const std::string &id, so_kind type, const structural_objectRef owner) const =0
Return the object named id of a given type which belongs to or it is associated with the object...
virtual std::string print_type(unsigned int type, bool global=false, bool print_qualifiers=false, bool print_storage=false, unsigned int var=0, const var_pp_functorConstRef vppf=var_pp_functorConstRef(), const std::string &prefix="", const std::string &tail="") const
Print a type and its variable in case var is not zero.
virtual void add_to_SM(const HLS_managerRef HLSMgr, const hlsRef HLS, structural_objectRef clock_port, structural_objectRef reset_port)
Instance the functional unit inside the structural representation of the datapath.
void set_structural_obj(const structural_objectRef &SM_)
Sets structural_object associated to this object.
#define PRINT_DBG_STRING(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed; no newline is added;...
Class specification of the manager of the technology library data structures.
redefinition of map to manage ordered/unordered structures
Class adopt to represent a mux connection.
#define GET_TYPE_NAME(structural_obj)
Macro returning the string name of a type.
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
static void add_memory_parameter(const structural_managerRef SM, const std::string &name, const std::string &value)
Adds the given memory parameter to the corresponding object.
port_direction
Enumerative type describing the direction of a port.
Base class for all resources into datapath.
#define CLOCK_PORT_NAME
standard name for ports
void INIT(bool permissive=false)
fu_bindingRef Rfu
Store the refcounted functional unit binding of the operations.
bool starts_with(const std::string &str, const std::string &pattern)
const std::list< unsigned int > get_parameters() const
Return the list of index of original parameters of the function.
Data structure used to store the register binding of variables.
Base class for multiplexer into datapath.
void set_top_info(const std::string &id, const technology_managerRef &LM, const std::string &Library="")
Data structure used to store the interconnection binding of datapath elements.
Data structure used to store the schedule of the operations.
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.
unsigned int GetFunctionReturnType(unsigned int function) const
Return the index associated with the type of the return of the function.
#define LIBRARY_STD
standard library where all built-in ports are defined.
void set_black_box(bool bb)
Set the black box property associated with the structural_object.
void SetParameter(const std::string &name, const std::string &value)
Set a parameter value.
const BehavioralHelperConstRef CGetBehavioralHelper() const
Returns the helper associated with the function.
Base class for all dataports into datapath.
Classes specification of the tree_node data structures.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
#define DEBUG_LEVEL_NONE
no debugging print is performed.
reg_bindingRef Rreg
Store the refcounted register binding of the variables.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
std::string PrintVariable(unsigned int var) const
Print the name of the variable associated to the index.
#define LIBRARY_STD_DATAFLOW
standard library for dataflow interface modules
refcount< structural_manager > structural_managerRef
RefCount type definition of the structural_manager class structure.
void type_resize(unsigned long long new_bit_size)
Just resize the size of the bits of the object.
structural_objectRef add_module_from_technology_library(const std::string &id, const std::string &fu_name, const std::string &library_name, const structural_objectRef owner, const technology_managerConstRef TM)
Create a new object starting from a library component.
~classic_datapath() override
Destructor.
void set_out_sign(const structural_objectRef &out_sign_)
Sets structural_object of output signal associated to this object.
void add_to_SM(structural_objectRef clock_port, structural_objectRef reset_port)
Add components to the datapath required by the FSM.
This class describes all classes used to represent a structural object.
Class specification of the tree_reindex support class.
static structural_objectRef add_sign(std::string id, structural_objectRef owner, structural_type_descriptorRef sign_type, unsigned int treenode=0)
Create a new signal.
Data structure used to store the functional-unit binding of the vertexes.
void add_clock_reset(structural_objectRef &clock_obj, structural_objectRef &reset_obj)
Adds the clock and reset ports to the structural description of the circuit.
hlsRef HLS
HLS data structure of the function to be analyzed.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
It collects all the common strings covering PandA copyrights issues.
virtual void add_to_SM(structural_objectRef clock_port, structural_objectRef reset_port)
Add the resulting registers to the structural description of the datapath.
this class is used to manage the command-line or XML options.
unsigned int functionId
this is the identifier of the function to be implemented
Class implementation of the structural_manager.
StateTransitionGraphManagerRef STG
Store the refcounted state transition graph.
enum { IN=0, OUT } direction_type
direction port identifier
static void resize_std_port(unsigned long long bitsize_variable, unsigned long long n_elements, int debug_level, structural_objectRef port)
auxiliary function used to resize the standard ports
int debug_level
The debug level.
#define flipflop_SR
flipflop with synchronous reset
#define DEBUG_LEVEL_VERBOSE
verbose debugging print is performed.
Data structure definition for high-level synthesis flow.
const std::string get_name() const
Returns the name of the type descriptor.
conn_bindingRef Rconn
Store the refcounted interconnection of datapath elements.
#define GENERATED_COPYRIGHT
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.
void WriteDot(const std::string &file_name, circuit_graph_type gt, graph *g=nullptr) const
Function that writes the dot file of the graph by using the AT&T dot format.
A brief description of the C++ Header File.
classic_datapath(const ParameterConstRef _parameters, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager, const HLSFlowStep_Type hls_flow_step_type=HLSFlowStep_Type::CLASSIC_DATAPATH_CREATOR)
Constructor.
#define STD_GET_SIZE(structural_obj)
Macro returning the size of a type.
static structural_objectRef add_sign_vector(std::string id, unsigned int n_signs, structural_objectRef owner, structural_type_descriptorRef sign_type, unsigned int treenode=0)
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...