87 const std::vector<ModuleGenerator::parameter>& ,
88 const std::vector<ModuleGenerator::parameter>& _ports_in,
89 const std::vector<ModuleGenerator::parameter>& _ports_out,
90 const std::vector<ModuleGenerator::parameter>& )
93 const auto top_fid = HLSMgr->CGetCallGraphManager()->GetRootFunction(function_id);
94 const auto top_fname = HLSMgr->CGetFunctionBehavior(top_fid)->CGetBehavioralHelper()->GetMangledFunctionName();
95 const auto func_arch = HLSMgr->module_arch->GetArchitecture(top_fname);
96 THROW_ASSERT(func_arch,
"Expected function architecture for function " + top_fname);
97 const auto arraySize =
98 std::accumulate(func_arch->parms.begin(), func_arch->parms.end(), 0ULL, [&](
auto& a,
auto& it) {
99 const auto& parm_attrs = it.second;
100 if(parm_attrs.at(FunctionArchitecture::parm_bundle) == bundle_name)
102 THROW_ASSERT(parm_attrs.find(FunctionArchitecture::parm_elem_count) != parm_attrs.end(),
"");
103 return a + std::stoull(parm_attrs.at(FunctionArchitecture::parm_elem_count));
108 const auto isAlignedPowerOfTwo = _ports_in[
i_in4].alignment == ceil_pow2(_ports_in[
i_in4].alignment);
109 const auto addressMaxValue = _ports_in[
i_in4].alignment * arraySize - 1
U;
110 const auto nbitAddress =
111 addressMaxValue <= 1U ? 1
U : (64u -
static_cast<unsigned>(__builtin_clzll(addressMaxValue)));
113 out <<
"//" << (isAlignedPowerOfTwo ?
"T" :
"F") <<
"\n";
114 out <<
"assign " << _ports_out[
o_ce].name <<
" = " << _ports_in[
i_start].name <<
"[0];\n";
116 if(isAlignedPowerOfTwo)
118 out <<
"assign " << _ports_out[
o_address].name <<
" = " << _ports_in[
i_in4].name <<
"[BITSIZE_" 119 << _ports_in[
i_in4].name <<
"*0+:" << nbitAddress <<
"] / " << _ports_in[
i_in4].alignment <<
";\n";
123 out <<
"assign " << _ports_out[
o_address].name <<
" = " << _ports_in[
i_in4].name <<
"[2+BITSIZE_" 124 << _ports_in[
i_in4].name <<
"*0+:" << nbitAddress - 2U <<
"] / " << _ports_in[
i_in4].alignment / 4 <<
";\n";
127 if(_ports_in.size() >
i_q)
129 out <<
"assign " << _ports_out[
o_out1].name <<
"[BITSIZE_" << _ports_out[
o_out1].name <<
"*0+:BITSIZE_" 130 << _ports_out[
o_out1].name <<
"] = " << _ports_in[
i_q].name <<
";\n";
133 if(_ports_out.size() >
o_d)
135 out <<
"assign " << _ports_out[
o_we].name <<
" = " << _ports_in[
i_start].name <<
"[0] & (|" 136 << _ports_in[
i_in1].name <<
"[BITSIZE_" << _ports_in[
i_in1].name <<
"*0+:BITSIZE_" << _ports_in[
i_in1].name
138 out <<
"assign " << _ports_out[
o_d].name <<
" = " << _ports_in[
i_in3].name <<
"[BITSIZE_" << _ports_in[
i_in3].name
139 <<
"*0+: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.
mathematical utility function not provided by standard libraries
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
This class writes different HDL based descriptions (VHDL, Verilog, SystemC) starting from a structura...
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
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...
ReadWrite_arrayModuleGenerator(const HLS_managerRef &HLSMgr)
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 ...