92 unsigned int function_id,
vertex ,
94 const std::vector<ModuleGenerator::parameter>& ,
95 const std::vector<ModuleGenerator::parameter>& _ports_in,
96 const std::vector<ModuleGenerator::parameter>& _ports_out,
97 const std::vector<ModuleGenerator::parameter>& )
100 const auto top_fid = HLSMgr->CGetCallGraphManager()->GetRootFunction(function_id);
101 const auto top_fname = HLSMgr->CGetFunctionBehavior(top_fid)->CGetBehavioralHelper()->GetMangledFunctionName();
102 const auto func_arch = HLSMgr->module_arch->GetArchitecture(top_fname);
103 THROW_ASSERT(func_arch,
"Expected function architecture for function " + top_fname);
104 const auto arraySize =
105 std::accumulate(func_arch->parms.begin(), func_arch->parms.end(), 0ULL, [&](
auto& a,
auto& it) {
106 const auto& parm_attrs = it.second;
107 if(parm_attrs.at(FunctionArchitecture::parm_bundle) == bundle_name)
109 THROW_ASSERT(parm_attrs.find(FunctionArchitecture::parm_elem_count) != parm_attrs.end(),
"");
110 return a + std::stoull(parm_attrs.at(FunctionArchitecture::parm_elem_count));
115 const auto isAlignedPowerOfTwo = _ports_in[
i_in4].alignment == ceil_pow2(_ports_in[
i_in4].alignment);
116 const auto addressMaxValue = _ports_in[
i_in4].alignment * arraySize - 1
U;
117 const auto nbitAddress =
118 addressMaxValue <= 1ULL ? 1
U : (64u -
static_cast<unsigned>(__builtin_clzll(addressMaxValue)));
120 out <<
"//" << (isAlignedPowerOfTwo ?
"T" :
"F") <<
"\n";
121 out <<
"assign " << _ports_out[
o_ce0].name <<
" = " << _ports_in[
i_start].name <<
"[0];\n";
122 out <<
"assign " << _ports_out[
o_ce1].name <<
" = " << _ports_in[
i_start].name <<
"[1];\n";
124 if(isAlignedPowerOfTwo)
126 out <<
"assign " << _ports_out[
o_address0].name <<
" = " << _ports_in[
i_in4].name <<
"[BITSIZE_" 127 << _ports_in[
i_in4].name <<
"*0+:" << nbitAddress <<
"] / " << _ports_in[
i_in4].alignment <<
";\n";
128 out <<
"assign " << _ports_out[
o_address1].name <<
" = " << _ports_in[
i_in4].name <<
"[BITSIZE_" 129 << _ports_in[
i_in4].name <<
"*1+:" << nbitAddress <<
"] / " << _ports_in[
i_in4].alignment <<
";\n";
133 out <<
"assign " << _ports_out[
o_address0].name <<
" = " << _ports_in[
i_in4].name <<
"[2+(BITSIZE_" 134 << _ports_in[
i_in4].name <<
")*0+:" << nbitAddress - 2U <<
"] / " << _ports_in[
i_in4].alignment / 4 <<
";\n";
135 out <<
"assign " << _ports_out[
o_address1].name <<
" = " << _ports_in[
i_in4].name <<
"[2+BITSIZE_" 136 << _ports_in[
i_in4].name <<
"*1+:" << nbitAddress - 2U <<
"] / " << _ports_in[
i_in4].alignment / 4 <<
";\n";
139 if(_ports_in.size() >
i_q1)
141 out <<
"assign " << _ports_out[
o_out1].name <<
"[BITSIZE_" << _ports_out[
o_out1].name <<
"*0+:BITSIZE_" 142 << _ports_out[
o_out1].name <<
"] = " << _ports_in[
i_q0].name <<
";\n";
143 out <<
"assign " << _ports_out[
o_out1].name <<
"[BITSIZE_" << _ports_out[
o_out1].name <<
"*1+:BITSIZE_" 144 << _ports_out[
o_out1].name <<
"] = " << _ports_in[
i_q1].name <<
";\n";
147 if(_ports_out.size() >
o_d1)
149 out <<
"assign " << _ports_out[
o_we0].name <<
" = " << _ports_in[
i_start].name <<
"[0] & (|" 150 << _ports_in[
i_in1].name <<
"[BITSIZE_" << _ports_in[
i_in1].name <<
"*0+:BITSIZE_" << _ports_in[
i_in1].name
152 out <<
"assign " << _ports_out[
o_d0].name <<
" = " << _ports_in[
i_in3].name <<
"[BITSIZE_" 153 << _ports_in[
i_in3].name <<
"*0+:BITSIZE_" << _ports_in[
i_in3].name <<
"];\n";
154 out <<
"assign " << _ports_out[
o_we1].name <<
" = " << _ports_in[
i_start].name <<
"[1] & (|" 155 << _ports_in[
i_in1].name <<
"[BITSIZE_" << _ports_in[
i_in1].name <<
"*1+:BITSIZE_" << _ports_in[
i_in1].name
157 out <<
"assign " << _ports_out[
o_d1].name <<
" = " << _ports_in[
i_in3].name <<
"[BITSIZE_" 158 << _ports_in[
i_in3].name <<
"*1+:BITSIZE_" << _ports_in[
i_in3].name <<
"];\n";
Data structure representing the entire HLS information.
#define STR_CST_interface_parameter_keyword
interface_parameter_keyword
const std::string & get_id() const
Return the identifier associated with the structural_object.
Definition of the class representing a generic C application.
mathematical utility function not provided by standard libraries
This class writes different HDL based descriptions (VHDL, Verilog, SystemC) starting from a structura...
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
ReadWriteDP_arrayModuleGenerator(const HLS_managerRef &HLSMgr)
This class describes all classes used to represent a structural object.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
void InternalExec(std::ostream &out, structural_objectRef mod, unsigned int function_id, vertex op_v, const HDLWriter_Language language, const std::vector< ModuleGenerator::parameter > &_p, const std::vector< ModuleGenerator::parameter > &_ports_in, const std::vector< ModuleGenerator::parameter > &_ports_out, const std::vector< ModuleGenerator::parameter > &_ports_inout) final
A brief description of the C++ Header File.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...