71 const DesignFlowManagerConstRef _design_flow_manager,
const HLSFlowStep_Type _hls_flow_step_type)
72 :
HLSFunctionStep(_parameters, _HLSMgr, _funId, _design_flow_manager, _hls_flow_step_type)
83 switch(relationship_type)
113 const auto FB =
HLSMgr->CGetFunctionBehavior(
funId);
114 const auto BH = FB->CGetBehavioralHelper();
115 const auto function_name = BH->get_function_name();
116 const auto top_functions =
HLSMgr->CGetCallGraphManager()->GetRootFunctions();
117 const auto is_top = top_functions.find(BH->get_function_index()) != top_functions.end();
118 const auto module_name = is_top ?
"_" + function_name : function_name;
143 circuit->set_black_box(
false);
146 GetPointerS<module>(circuit)->set_description(
"Top component for " + function_name);
148 GetPointerS<module>(circuit)->set_authors(
"Component automatically generated by bambu");
151 const auto datapath_circuit = Datapath->get_circ();
152 THROW_ASSERT(datapath_circuit,
"Missing datapath circuit");
153 const auto controller_circuit = Controller->get_circ();
154 THROW_ASSERT(controller_circuit,
"Missing controller circuit");
159 datapath_circuit->set_owner(circuit);
160 GetPointerS<module>(circuit)->add_internal_object(datapath_circuit);
165 controller_circuit->set_owner(circuit);
166 GetPointerS<module>(circuit)->add_internal_object(controller_circuit);
174 GetPointerS<port_o>(clock_obj)->set_is_clock(
true);
203 sync_datapath_controller =
SM->
add_sign(
"done2start", circuit, bool_type);
216 THROW_ASSERT(done_obj,
"Done port not added in the top component");
217 const auto controller_done = controller_circuit->find_member(
DONE_PORT_NAME,
port_o_K, controller_circuit);
218 THROW_ASSERT(controller_done,
"Done signal not found in the controller");
231 const auto TM =
HLS->
HLS_D->get_technology_manager();
232 const auto reset_type =
parameters->getOption<std::string>(OPT_reset_type);
234 const auto delay_gate =
247 const auto done_signal_in =
SM->
add_sign(
"done_delayed_REG_signal_in", circuit,
248 GetPointerS<module>(delay_gate)->get_in_port(2)->get_typeRef());
249 SM->
add_connection(GetPointerS<module>(delay_gate)->get_in_port(2), done_signal_in);
251 done_signal_out =
SM->
add_sign(
"done_delayed_REG_signal_out", circuit,
252 GetPointerS<module>(delay_gate)->get_out_port(0)->get_typeRef());
253 SM->
add_connection(GetPointerS<module>(delay_gate)->get_out_port(0), done_signal_out);
260 done_signal_out =
SM->
add_sign(
"done_signal_out", circuit, bool_type);
275 THROW_ASSERT(controller_flow_start,
"controller flow start signal not found in the datapath");
286 THROW_ASSERT(controller_flow_done,
"controller flow done signal not found in the datapath");
288 const auto controller_flow_present_state =
290 THROW_ASSERT(controller_flow_present_state,
"controller flow present state signal not found in the datapath");
291 const auto controller_present_state = Controller->add_port(
293 const auto p_signal =
297 const auto controller_flow_next_state =
299 THROW_ASSERT(controller_flow_next_state,
"controller flow next state signal not found in the datapath");
300 const auto controller_next_state = Controller->add_port(
NEXT_STATE_PORT_NAME, port_o::OUT, controller_circuit,
301 controller_flow_next_state->get_typeRef());
302 const auto n_signal =
311 add_ports(circuit, clock_obj, reset_obj);
318 if(!is_top || (
parameters->isOption(OPT_expose_globals) &&
parameters->getOption<
bool>(OPT_expose_globals)))
331 const auto TM =
HLS->
HLS_D->get_technology_manager();
332 const auto register_library = TM->get_library(
register_STD);
337 GetPointerS<module>(reg_mod)->get_out_port(0)->type_resize(
GET_TYPE_SIZE(port_in));
350 SM->
add_sign(port_prefix +
"_SIGI2", circuit, GetPointerS<module>(reg_mod)->get_out_port(0)->get_typeRef());
351 SM->
add_connection(GetPointerS<module>(reg_mod)->get_out_port(0), r_signal);
359 const auto FB =
HLSMgr->CGetFunctionBehavior(
funId);
360 const auto BH = FB->CGetBehavioralHelper();
364 const auto function_parameters = BH->get_parameters();
366 const auto curr_address_bitsize =
HLSMgr->get_address_bitsize();
367 for(
const auto& function_parameter : function_parameters)
369 const auto prefix =
"in_port_";
370 const auto in_obj = Datapath->find_member(prefix + BH->PrintVariable(function_parameter),
port_o_K,
374 if(
HLSMgr->Rmem->has_base_address(function_parameter) &&
376 !
HLSMgr->Rmem->is_parm_decl_stored(function_parameter))
387 THROW_ERROR(
"Should never be reached, in_obj is not a port vector");
388 top_obj =
SM->
add_port_vector(FB->CGetBehavioralHelper()->PrintVariable(function_parameter), port_o::IN,
389 GetPointerS<port_o>(in_obj)->get_ports_size(), circuit, port_type);
393 top_obj =
SM->
add_port(FB->CGetBehavioralHelper()->PrintVariable(function_parameter), port_o::IN, circuit,
396 const auto is_pipelined =
HLSMgr->CGetFunctionBehavior(
funId)->is_simple_pipeline();
397 if(has_registered_inputs && !is_pipelined)
399 const auto port_prefix = GetPointerS<port_o>(in_obj)->get_id();
402 for(
auto p = 0
U; p < GetPointerS<port_o>(in_obj)->get_ports_size(); ++p)
405 port_prefix + GetPointerS<port_o>(in_obj)->get_port(p)->get_id(), circuit, clock_port,
406 reset_port, GetPointerS<port_o>(top_obj)->get_port(p));
419 const auto return_type_index = BH->GetFunctionReturnType(BH->get_function_index());
420 if(return_type_index)
427 const auto return_port = conn->get_port(return_type_index, conn_binding::OUT);
428 ret_obj = return_port->get_structural_obj();
436 if(
HLSMgr->Rmem->has_base_address(return_type_index) &&
438 !
HLSMgr->Rmem->is_parm_decl_stored(return_type_index))
463 const auto top_functions =
HLSMgr->CGetCallGraphManager()->GetRootFunctions();
464 const auto is_top = top_functions.count(BH->get_function_index());
465 bool master_port =
true;
469 std::map<unsigned long long, structural_objectRef> null_values;
471 for(
unsigned int j = 0; j < GetPointerS<module>(Datapath)->get_in_port_size(); j++)
474 if(GetPointerS<port_o>(port_in)->get_is_extern())
476 if(!GetPointer<port_o>(port_in)->get_is_memory() || !is_top || master_port)
483 GetPointerS<port_o>(port_in)->get_ports_size(), circuit, port_in->
get_typeRef());
496 if(null_values.find(
GET_TYPE_SIZE(port_in)) == null_values.end())
505 else if(GetPointerS<port_o>(port_in)->get_is_memory())
507 if(!is_top || master_port)
514 GetPointerS<port_o>(port_in)->get_ports_size(), circuit, port_in->
get_typeRef());
527 if(null_values.find(
GET_TYPE_SIZE(port_in)) == null_values.end())
536 else if(GetPointerS<port_o>(port_in)->get_port_interface() != port_o::port_interface::PI_DEFAULT)
543 GetPointerS<port_o>(port_in)->get_ports_size(), circuit, port_in->
get_typeRef());
556 for(
unsigned int j = 0; j < GetPointer<module>(Datapath)->get_out_port_size(); j++)
559 if(GetPointer<port_o>(port_out)->get_is_memory() && is_top && !master_port)
563 if(GetPointer<port_o>(port_out)->get_is_extern())
570 GetPointer<port_o>(port_out)->get_ports_size(), circuit, port_out->
get_typeRef());
581 else if(GetPointer<port_o>(port_out)->get_is_memory())
588 GetPointer<port_o>(port_out)->get_ports_size(), circuit, port_out->
get_typeRef());
599 else if(GetPointer<port_o>(port_out)->get_port_interface() != port_o::port_interface::PI_DEFAULT)
606 GetPointer<port_o>(port_out)->get_ports_size(), circuit, port_out->
get_typeRef());
620 for(
unsigned int j = 0; j < GetPointer<module>(Datapath)->get_in_out_port_size(); j++)
623 if(GetPointer<port_o>(port_in_out)->get_is_extern())
628 ext_port =
SM->
add_port_vector(GetPointer<port_o>(port_in_out)->get_id(), port_o::IO,
629 GetPointer<port_o>(port_in_out)->get_ports_size(), circuit,
634 ext_port =
SM->
add_port(GetPointer<port_o>(port_in_out)->get_id(), port_o::IO, circuit,
655 for(
const auto& l : selector.second)
658 THROW_ASSERT(datapath_obj,
"missing structural object associated with the selector " + l.second->get_string());
659 std::string datapath_name = datapath_obj->
get_id();
660 structural_objectRef controller_obj = GetPointer<commandport_obj>(l.second)->get_controller_obj();
666 std::string controller_name = controller_obj->
get_id();
668 THROW_ASSERT(src,
"Missing select port in the controller");
670 THROW_ASSERT(tgt,
"Missing select port in the datapath");
static void propagate_memory_parameters(const structural_objectRef src, const structural_managerRef tgt)
Propagates the memory parameters from the source (innermost) module to the target (outermost) one...
void add_connection(structural_objectRef src, structural_objectRef dest)
Create a connection between a source structural object and a destination structural object...
structural_managerRef SM
reference to the resulting circuit
#define PRESENT_STATE_PORT_NAME
#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;.
DesignFlowStep_Status InternalExec() override
Execute the step.
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 NEXT_STATE_PORT_NAME
structural_managerRef datapath
Store the datapath description.
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.
Base class for all command ports into datapath.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
#define GENERATED_LICENSE
const structural_objectRef get_circ() const
Get a reference to circ field.
RelationshipType
The relationship type.
const std::map< unsigned int, Selectors > & GetSelectors() const
Source must be executed to satisfy target.
const unsigned int funId
identifier of the function to be processed (0 means that it is a global step)
Base class for the top entity 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
void add_ports(structural_objectRef circuit, structural_objectRef clock_port, structural_objectRef reset_port)
Adds the input/output ports to the circuit.
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...
top_entity(const ParameterConstRef _parameters, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager, const HLSFlowStep_Type=HLSFlowStep_Type::TOP_ENTITY_CREATION)
Constructor.
Class specification of the manager of the technology library data structures.
redefinition of map to manage ordered/unordered structures
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
Base class for all resources into datapath.
#define CLOCK_PORT_NAME
standard name for ports
structural_managerRef top
Store the top description.
bool registered_inputs
true when the module has registered inputs
virtual std::string get_kind_text() const =0
Virtual function used to get the string name of a structural_object instance.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
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.
~top_entity() override
Destructor.
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.
Target must be reexecuted.
#define flipflop_AR
flipflop with asynchronous reset
redefinition of set to manage ordered/unordered structures
#define LIBRARY_STD
standard library where all built-in ports are defined.
Datastructure to describe functions allocation in high-level synthesis.
virtual void add_input_register(structural_objectRef port_in, const std::string &port_prefix, structural_objectRef circuit, structural_objectRef clock_port, structural_objectRef reset_port, structural_objectRef e_port)
Add the register to store input parameters.
static void fix_port_properties(structural_objectRef port_i, structural_objectRef cir_port)
copy the port properties from port_i to cir_port
virtual enum so_kind get_kind() const =0
Virtual function used to find the real type of a structural_object instance.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
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_constant(std::string id, structural_objectRef owner, structural_type_descriptorRef type, std::string value, unsigned int treenode=0)
Create a new constant;.
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.
structural_managerRef controller
Store the controller description.
#define GET_TYPE_SIZE(structural_obj)
Macro returning the size of the type of a structural object.
bool registered_done_port
true when the done port is registered
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.
structural_managerRef control_flow_checker
Store the description of the control flow checker.
#define register_STD
simple register without reset
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.
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...
#define DONE_PORT_NAME_CFC
It collects all the common strings covering PandA copyrights issues.
unsigned int functionId
this is the identifier of the function to be implemented
Class implementation of the structural_manager.
void add_command_signals(structural_objectRef circuit)
Adds the command signals to the circuit.
int debug_level
The debug level.
refcount< const HLSFlowStepSpecialization > HLSFlowStepSpecializationConstRef
const refcount definition of the class
#define flipflop_SR
flipflop with synchronous reset
#define DEBUG_LEVEL_VERBOSE
verbose debugging print is performed.
Data structure definition for high-level synthesis flow.
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.
conn_bindingRef Rconn
Store the refcounted interconnection of datapath elements.
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.
#define GENERATED_COPYRIGHT
Datastructure to represent memory information in high-level synthesis.
HLS specialization of generic_device.
A brief description of the C++ Header File.
#define START_PORT_NAME_CFC
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...