16 std::ifstream area_ini(ini_path +
"/area.ini");
20 std::string area_ini_str(
21 (std::istreambuf_iterator<char>(area_ini)),
22 std::istreambuf_iterator<char>()
28 cgrame_warn(ini_path +
"area.ini not found. Skipping...");
31 std::ifstream timing_ini(ini_path +
"/timing.ini");
35 std::string timing_ini_str(
36 (std::istreambuf_iterator<char>(timing_ini)),
37 std::istreambuf_iterator<char>()
43 cgrame_warn(ini_path +
"timing.ini not found. Skipping...");
46 std::ifstream power_ini(ini_path +
"/power.ini");
50 std::string power_ini_str(
51 (std::istreambuf_iterator<char>(power_ini)),
52 std::istreambuf_iterator<char>()
58 cgrame_warn(ini_path +
"power.ini not found. Skipping...");
71 double module_area = 0.0;
73 std::string delim =
"_";
74 size_t index = module_name.find(delim);
75 std::string module_basename = module_name.substr(0, index);
76 std::string module_suffix = module_name.substr(index + 1, module_name.length());
77 std::string model_key = module_basename +
"." + module_suffix;
79 if (module_basename ==
"func")
84 cgrame_msg(
"Area model of \"" + model_key +
"\" found.");
93 std::vector<std::string> ops;
96 end = module_name.find(delim, start);
97 std::string op = module_name.substr(start,
end - start);
100 }
while (
end != std::string::npos);
101 std::string bus_width = ops[0];
102 for (
int i = 1; i < ops.size(); i++)
104 std::string k =
"op." + ops[i] +
"_" + bus_width;
106 throw cgrame_error(
"Area model of \"" + k +
"\" does not exist...");
107 cgrame_msg(
"Area model of \"" + k +
"\" found.");
112 cgrame_msg(
"Area model of \"" + model_key +
"\" generated.");
114 m->
area = module_area;
120 bool determined =
false;
125 cgrame_msg(
"Area model of \"" + model_key +
"\" found.");
126 m->
area = module_area;
131 throw cgrame_error(
"Area model of \"" + model_key +
"\" does not exist...");
134 unsigned int i_last = m->
submodules.size() - 1;
137 std::string inst_name = sm.first;
138 Module* submodule = sm.second;
144 cgrame_msg(
"Area model of \"" + model_key +
"\" generated.");
146 m->
area = module_area;
154 cgrame_msg(
"Populating hierarchical module area.");
155 double total_area =
_setModuleArea(&(target->getTopLevelModule()), 0,
true);
158 std::string filename =
"/tmp/CGRAME_AreaReport.rpt";
159 std::streambuf* original_sbuf = std::cout.rdbuf();
160 std::ofstream rpt_filebuf(filename);
161 std::cout.rdbuf(rpt_filebuf.rdbuf());
166 std::cout.rdbuf(original_sbuf);
167 cgrame_msg(
"Area estimation completed. Report dumped to: `/tmp/CGRAME_AreaReport.rpt`");
175 std::string treeDrawing;
177 if (n->hierarchyLevel != 0)
178 treeDrawing = (n->isLastInHierarchy)?
" └─ ":
" ├─ ";
179 if (n->parent != NULL)
184 if (n->hierarchyLevel == 0)
186 if (n->isLastInHierarchy)
187 treeDrawing =
" " + treeDrawing;
189 treeDrawing =
" │ " + treeDrawing;
190 }
while(n->hierarchyLevel > 0);
192 std::cout << treeDrawing;
199 auto submodule = sm.second;
208 std::vector<MRRG::NodeDescriptor> fu_nodes;
216 fu_nodes.push_back(n);
224 for(
auto & node_a : m.at(val))
226 for(
auto & node_b : m.at(val))
228 if (node_a == node_b)
continue;
231 auto fanout = node_a->fanout;
232 if (std::find(fanout.begin(), fanout.end(), node_b) != fanout.end())
235 res.insert(std::pair<MRRG::NodeDescriptor, MRRG::NodeDescriptor> (node_a, node_b));
236 partial.insert(std::pair<MRRG::NodeDescriptor, MRRG::NodeDescriptor> (node_a, node_b));
263 std::vector<MRRG::NodeDescriptor> src_list;
264 for(
auto it = res.begin(); it != res.end(); it = res.upper_bound(it->first))
265 if (std::find(src_list.begin(), src_list.end(), it->first) == src_list.end())
266 src_list.push_back(it->first);
269 for(
auto i = 0; i < fu_nodes.size(); i++)
272 for(
auto it_i = res.begin(); it_i != res.end(); it_i = res.upper_bound(it_i->first))
274 auto node = it_i->first;
277 if (std::find(fu_nodes.begin(), fu_nodes.end(), node) != fu_nodes.end())
continue;
279 bool has_no_src =
true;
280 for(
auto it_j = res.begin(); it_j != res.end(); it_j++)
282 auto des = it_j->second;
293 for(
auto & fu_node : fu_nodes)
295 auto pos = std::find(src_list.begin(), src_list.end(), node);
296 if (std::find(node->fanin.begin(), node->fanin.end(), fu_node) != node->fanin.end())
298 res.insert(std::pair<MRRG::NodeDescriptor, MRRG::NodeDescriptor> (fu_node, node));
299 if (pos != src_list.end())
307 for(
auto it = res.begin(); it != res.end(); it++)
309 auto node = it->second;
312 if (std::find(fu_nodes.begin(), fu_nodes.end(), node) != fu_nodes.end())
continue;
314 bool has_no_des = (std::find(src_list.begin(), src_list.end(), node) == src_list.end());
318 for(
auto & fu_node : fu_nodes)
320 if (std::find(node->fanout.begin(), node->fanout.end(), fu_node) != node->fanout.end())
322 res.insert(std::pair<MRRG::NodeDescriptor, MRRG::NodeDescriptor> (node, fu_node));
323 src_list.push_back(node);
333 std::cout <<
"digraph MappedMRRG {" << std::endl;
336 std::cout <<
"\"" << *m.at(op).front() <<
"\";" << std::endl;
340 for(
auto & node : m.at(val))
342 std::cout <<
"\"" << *node <<
"\";" << std::endl;
345 for(
auto it = res.begin(); it != res.end(); it = res.upper_bound(it->first))
348 while (i != res.upper_bound(it->first))
351 auto des = i->second;
352 std::cout <<
"\"" << *src <<
"\" -> \"" << *des <<
"\";" << std::endl;
356 std::cout <<
"}\n" << std::endl;
372 sta_interface->createTatumTimingGraph(mapped_mrrg);
375 sta_interface->initializeTatumEngine(mapped_mrrg);
381 sta_interface->reportSetupAnalysis();
391 if (area_ini.parse(file_str))
393 for (
const auto& entry : area_ini)
395 std::string key = entry.first;
396 double val = stod(entry.second);
402 throw cgrame_error(
"Error parsing area.ini. Please verify syntax");
416 if (timing_ini.parse(file_str))
418 for (
const auto& entry : timing_ini)
420 std::string key = entry.first;
421 double val = stod(entry.second);
427 throw cgrame_error(
"Error parsing timing.ini. Please verify syntax");