59 const DesignFlowManagerConstRef _design_flow_manager,
61 :
module_interface(_Param, _HLSMgr, _funId, _design_flow_manager, _hls_flow_step_type)
74 THROW_ERROR(
"Top component has not been created yet!");
78 std::string module_name = wrappedObj->
get_id();
91 GetPointer<module>(interfaceObj)->add_internal_object(wrappedObj);
93 GetPointer<module>(interfaceObj)
94 ->set_description(
"Minimal interface for top component: " + wrappedObj->
get_typeRef()->
id_type);
96 GetPointer<module>(interfaceObj)->set_authors(
"Component automatically generated by bambu");
102 clock_port = SM_cs_interface->
add_port(GetPointer<port_o>(port_ck)->get_id(), port_o::IN, interfaceObj,
107 reset_port = SM_cs_interface->
add_port(GetPointer<port_o>(port_rst)->get_id(), port_o::IN, interfaceObj,
117 HLS->
top = SM_cs_interface;
125 for(
unsigned int j = 0; j < GetPointer<module>(top_module)->get_in_port_size(); j++)
128 if(!GetPointer<port_o>(port_i)->get_is_memory())
130 std::string port_name = GetPointer<port_o>(port_i)->get_id();
138 for(
unsigned int j = 0; j < GetPointer<module>(top_module)->get_out_port_size(); j++)
141 if(!GetPointer<port_o>(port_i)->get_is_memory())
143 std::string port_name = GetPointer<port_o>(port_i)->get_id();
156 std::string memory_ctrl_model;
157 if(
parameters->getOption<
unsigned int>(OPT_channels_number) != 1)
159 memory_ctrl_model =
"memory_ctrl";
163 memory_ctrl_model =
"memory_ctrl_single_input";
165 std::string memory_ctrl_name =
"memory_ctrl_top";
166 std::string memory_ctrl_library =
HLS->
HLS_D->get_technology_manager()->get_library(memory_ctrl_model);
168 memory_ctrl_name, memory_ctrl_model, memory_ctrl_library, circuit,
HLS->
HLS_D->get_technology_manager());
182 GetPointer<module>(mem_ctrl_mod)
183 ->SetParameter(
"NUM_CHANNEL",
STR(
parameters->getOption<
unsigned int>(OPT_channels_number)));
184 GetPointer<module>(mem_ctrl_mod)
185 ->SetParameter(
"NUM_BANK",
STR(
parameters->getOption<
unsigned int>(OPT_memory_banks_number)));
186 auto addr_task =
ceil_log2(
parameters->getOption<
unsigned long long int>(OPT_context_switch));
191 GetPointer<module>(mem_ctrl_mod)->SetParameter(
"ADDR_TASKS",
STR(addr_task));
192 auto addr_kern =
ceil_log2(
parameters->getOption<
unsigned long long>(OPT_num_accelerators));
197 GetPointer<module>(mem_ctrl_mod)->SetParameter(
"ADDR_ACC",
STR(addr_kern));
205 auto memory_channel =
parameters->getOption<
unsigned int>(OPT_channels_number);
206 auto num_banks =
parameters->getOption<
unsigned int>(OPT_memory_banks_number);
207 for(
unsigned int j = 0; j < GetPointer<module>(mem_ctrl_mod)->get_in_port_size(); j++)
210 if(GetPointer<port_o>(port_i)->get_is_memory())
212 std::string port_name = GetPointer<port_o>(port_i)->get_id();
213 if(port_name.substr(0, 3) ==
"IN_")
223 for(
unsigned int j = 0; j < GetPointer<module>(mem_ctrl_mod)->get_out_port_size(); j++)
226 if(GetPointer<port_o>(port_i)->get_is_memory())
228 std::string port_name = GetPointer<port_o>(port_i)->get_id();
229 if(port_name.substr(0, 4) ==
"OUT_")
243 auto bus_data_bitsize =
HLSMgr->Rmem->get_bus_data_bitsize();
244 auto bus_addr_bitsize =
HLSMgr->get_address_bitsize();
245 auto bus_size_bitsize =
HLSMgr->Rmem->get_bus_size_bitsize();
246 auto bus_tag_bitsize = GetPointer<memory_cs>(
HLSMgr->Rmem)->get_bus_tag_bitsize();
248 if(GetPointer<port_o>(port)->get_is_data_bus())
252 else if(GetPointer<port_o>(port)->get_is_addr_bus())
256 else if(GetPointer<port_o>(port)->get_is_size_bus())
260 else if(GetPointer<port_o>(port)->get_is_tag_bus())
265 GetPointer<port_o>(port)->add_n_ports(vector_size, port);
274 auto num_channel =
parameters->getOption<
unsigned int>(OPT_channels_number);
279 for(
unsigned int j = 0; j < GetPointer<module>(memory_module)->get_in_port_size();
283 if(GetPointer<port_o>(port_i)->get_is_memory() && GetPointer<port_o>(port_i)->get_is_global() &&
284 GetPointer<port_o>(port_i)->get_is_extern())
286 std::string port_name = GetPointer<port_o>(port_i)->get_id();
290 THROW_ASSERT(!memory_ctrl_port || GetPointer<port_o>(memory_ctrl_port),
"should be a port");
300 for(
unsigned int j = 0; j < GetPointer<module>(memory_module)->get_out_port_size();
304 if(GetPointer<port_o>(port_i)->get_is_memory() && !GetPointer<port_o>(port_i)->get_is_global() &&
305 !GetPointer<port_o>(port_i)->get_is_extern())
307 std::string port_name = GetPointer<port_o>(port_i)->get_id();
311 THROW_ASSERT(!memory_ctrl_port || GetPointer<port_o>(memory_ctrl_port),
"should be a port");
319 for(
unsigned int j = 0; j < GetPointer<module>(memory_ctrl)->get_in_port_size();
323 std::string port_name = GetPointer<port_o>(port_i)->get_id();
324 if(GetPointer<port_o>(port_i)->get_is_memory() && GetPointer<port_o>(port_i)->get_is_global() &&
325 GetPointer<port_o>(port_i)->get_is_extern() && port_name.substr(0, 3) ==
"IN_")
328 THROW_ASSERT(!cir_port || GetPointer<port_o>(cir_port),
"should be a port or null");
331 cir_port = SM->
add_port_vector(port_name, port_o::IN, GetPointer<port_o>(port_i)->get_ports_size(), circuit,
340 for(
unsigned int j = 0; j < GetPointer<module>(memory_ctrl)->get_out_port_size();
344 std::string port_name = GetPointer<port_o>(port_i)->get_id();
345 if(GetPointer<port_o>(port_i)->get_is_memory() && !GetPointer<port_o>(port_i)->get_is_global() &&
346 !GetPointer<port_o>(port_i)->get_is_extern() && port_name.substr(0, 4) ==
"OUT_")
350 THROW_ASSERT(!cir_port || GetPointer<port_o>(cir_port),
"should be a port or null");
353 cir_port = SM->
add_port_vector(port_name, port_o::OUT, GetPointer<port_o>(port_i)->get_ports_size(),
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...
#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;.
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.
#define GENERATED_LICENSE
const structural_objectRef get_circ() const
Get a reference to circ field.
void set_owner(const structural_objectRef new_owner)
set the owner of the structural object
mathematical utility function not provided by standard libraries
const unsigned int funId
identifier of the function to be processed (0 means that it is a global step)
This class manages the circuit structures.
const HLS_deviceRef HLS_D
reference to the information representing the target for the synthesis
void resize_dimension_bus_port(unsigned int vector_size, structural_objectRef port)
resize_dimension_bus_port
DesignFlowStep_Status InternalExec() override
Execute the step.
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...
Class specification of the manager of the technology library data structures.
void instantiate_component_parallel(const structural_managerRef SM, structural_objectRef clock_port, structural_objectRef reset_port)
instantiate_component_parallel
#define STR(s)
Macro which performs a lexical_cast to a string.
void add_parameter_port(const structural_managerRef SM, structural_objectRef circuit, structural_objectRef top_module)
add_parameter_port
#define CLOCK_PORT_NAME
standard name for ports
structural_managerRef top
Store the top description.
virtual std::string get_kind_text() const =0
Virtual function used to get the string name of a structural_object instance.
T ceil_log2(T x)
Return the smallest n such that 2**n >= X.
~cs_interface() override
Destructor.
void set_top_info(const std::string &id, const technology_managerRef &LM, const std::string &Library="")
const std::string get_path() const
Return a unique identifier of the structural object.
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 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.
This file collects some utility functions and macros.
#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_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.
void resize_memory_ctrl_ports(structural_objectRef mem_ctrl_mod)
resize_memory_ctrl_ports
void manage_extern_global_port_top(const structural_managerRef SM, const structural_objectRef memory_module, const structural_objectRef circuit)
manage_memory_ports_parallel_chained_parallel
std::string id_type
Original type id of the structural object.
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.
void set_id(const std::string &s)
Set the identifier associated with the structural_object.
static structural_objectRef add_sign(std::string id, structural_objectRef owner, structural_type_descriptorRef sign_type, unsigned int treenode=0)
Create a new signal.
hlsRef HLS
HLS data structure of the function to be analyzed.
Class to generate the interface for the context switch project.
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.
Class implementation of the structural_manager.
int debug_level
The debug level.
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.
#define GENERATED_COPYRIGHT
Datastructure to represent memory information in high-level synthesis.
HLS specialization of generic_device.
void set_type(const structural_type_descriptorRef &s)
Set the type of the structural_object.
cs_interface(const ParameterConstRef Param, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager, const HLSFlowStep_Type hls_flow_step_type=HLSFlowStep_Type::INTERFACE_CS_GENERATION)
Constructor.
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 ...