73 #include <boost/algorithm/string/predicate.hpp> 74 #include <boost/graph/adjacency_list.hpp> 75 #include <boost/graph/filtered_graph.hpp> 76 #include <boost/graph/graph_traits.hpp> 77 #include <boost/graph/graphviz.hpp> 78 #include <boost/iterator/iterator_facade.hpp> 79 #include <boost/smart_ptr/shared_ptr.hpp> 81 #include "config_HAVE_TECHNOLOGY_BUILT.hpp" 84 : Param(_Param), debug_level(_Param->get_class_debug_level(
GET_CLASS(*this)))
106 std::string(
"Object id cannot contain the \"/\" character"));
107 return owner->
find_member(
id, type, owner) !=
nullptr;
112 auto* p = GetPointer<port_o>(src);
113 for(
unsigned int i = 0; i < p->get_connections_size(); i++)
115 if(p->get_connection(i) ==
sign)
127 auto* circ = GetPointer<component_o>(
circuit);
129 circ->set_treenode(treenode);
130 circ->set_type(module_type);
134 const std::string& Library)
181 cc->set_treenode(treenode);
182 cc->set_type(obj_type);
183 auto* own = GetPointer<module>(owner);
184 THROW_ASSERT(own,
"Signal, port or interface couldn't own internal object");
185 own->add_internal_object(cc);
191 unsigned int treenode)
197 cp->set_treenode(treenode);
198 cp->set_type(type_descr);
204 auto* own = GetPointer<module>(owner);
209 own->add_in_port(cp);
210 #if HAVE_TECHNOLOGY_BUILT 212 cp->add_attribute(
"direction", direction);
218 own->add_out_port(cp);
219 #if HAVE_TECHNOLOGY_BUILT 221 cp->add_attribute(
"direction", direction);
223 if(GetPointer<module>(owner))
228 #if HAVE_TECHNOLOGY_BUILT 231 for(
auto& token : tokens)
235 equation = token.substr(token.find(
'=') + 1, token.size());
239 cp->add_attribute(
"function",
function);
247 own->add_in_out_port(cp);
252 own->add_gen_port(cp);
256 case port_o::TLM_INOUT:
257 case port_o::TLM_OUT:
258 case port_o::UNKNOWN:
260 THROW_ERROR(std::string(
"port type not supported"));
274 THROW_ERROR(std::string(
"Signal, port or interface couldn't own a port"));
288 auto* own = GetPointer<module>(owner);
289 own->change_port_direction(port_object, pdir);
302 THROW_ERROR(std::string(
"object not yet managed"));
309 unsigned int treenode)
313 "the object " +
id +
" is already present in " + owner->
get_path());
316 cp->set_treenode(treenode);
317 cp->set_type(type_descr);
320 GetPointer<port_o>(cp)->add_n_ports(n_ports, cp);
327 auto* own = GetPointer<module>(owner);
332 own->add_in_port(cp);
337 own->add_out_port(cp);
342 own->add_in_out_port(cp);
347 own->add_gen_port(cp);
351 case port_o::TLM_INOUT:
352 case port_o::TLM_OUT:
353 case port_o::UNKNOWN:
355 THROW_ERROR(std::string(
"port type not supported"));
369 THROW_ERROR(std::string(
"Signal, port or interface couldn't own a port"));
380 "the object " +
id +
" is already present in " + owner->
get_path());
383 cs->set_treenode(treenode);
384 cs->set_type(sign_type);
387 GetPointer<signal_o>(cs)->add_n_signals(n_signs, cs);
393 auto* own = GetPointer<module>(owner);
394 own->add_internal_object(cs);
408 THROW_ERROR(std::string(
"Only a module can own a signal vector"));
418 "the object " +
id +
" is already present in " + owner->
get_path());
421 cs->set_treenode(treenode);
422 cs->set_type(sign_type);
428 auto* own = GetPointer<module>(owner);
429 own->add_internal_object(cs);
434 auto* own = GetPointer<bus_connection_o>(owner);
435 own->add_connection(cs);
447 THROW_ERROR(std::string(
"Signal, port or interface couldn't own signal"));
454 auto*
sign(GetPointer<signal_o>(signal));
457 if(
sign->get_connected_objects_size() > 0)
464 switch(owner->get_kind())
468 GetPointer<module>(owner)->remove_internal_object(signal);
480 THROW_ERROR(
"Signal removal not implemented for this owner type");
489 auto* from(GetPointer<signal_o>(from_signal));
490 auto* to(GetPointer<signal_o>(to_signal));
491 THROW_ASSERT(from && to && from->get_owner() == to->get_owner(),
"Need two valid signals with the same owner");
492 THROW_ASSERT(from->is_connected(member),
"Not a member of from_signal");
494 THROW_ASSERT(!to->is_connected(member),
"Already a member of to_signal");
499 "moving member " + member->
get_path() +
" from " + from_signal->
get_path() +
" to " +
506 auto* p(GetPointer<port_o>(member));
507 from->remove_port(member);
508 p->remove_connection(from_signal);
510 p->add_connection(to_signal);
511 to->add_port(member);
531 unsigned int treenode)
535 "the object " +
id +
" is already present in " + owner->
get_path());
538 c_obj->set_treenode(treenode);
539 c_obj->set_type(type);
540 auto* own = GetPointer<module>(owner);
541 THROW_ASSERT(own,
"Signal, port or interface couldn't own internal object");
542 own->add_internal_object(c_obj);
547 std::string functionality_description)
550 const auto com = GetPointer<module>(cir);
554 com->set_NP_functionality(f);
560 auto* com = GetPointer<module>(
get_circ());
561 com->SetParameter(name, value);
566 auto* ad = GetPointer<action_o>(pr);
567 ad->add_event_to_sensitivity(obj);
573 "Missing src or dest: " + (src ? src->
get_path() :
"!src") +
" " + (dest ? dest->
get_path() :
"!dest"));
580 auto* p_s = GetPointerS<port_o>(src);
587 "A direct connection between ports of the same object is not allowed. Put a signal in between...: " +
590 "Ports have to be compatible: " + src->
get_path() +
" -> " + dest->
get_path());
592 "Port " + src->
get_id() +
" already bound to " + dest->
get_id());
594 "Port " + dest->
get_id() +
" already bound to " + src->
get_id());
595 auto* p_d = GetPointerS<port_o>(dest);
596 p_s->add_connection(dest);
597 p_d->add_connection(src);
603 "Ports and signals have to be compatible: " + src->
get_path() +
" -> " + dest->
get_path());
604 p_s->add_connection(dest);
605 auto* c_d = GetPointerS<signal_o>(dest);
612 "A direct connection between port and channel of the same object is not allowed.");
614 "Port " + src->
get_id() +
" already bound to " + dest->
get_id());
616 p_s->add_connection(dest);
617 auto* c_d = GetPointerS<channel_o>(dest);
626 "Port " + src->
get_id() +
" already bound to " + dest->
get_id());
628 p_s->add_connection(dest);
629 auto* c_d = GetPointerS<constant_o>(dest);
630 c_d->add_connection(src);
650 auto* p_s = GetPointerS<port_o>(src);
657 "A direct connection between ports of the same object is not allowed. Put a signal in between...: " +
660 "Ports have to be compatible: " + src->
get_path() +
" -> " + dest->
get_path());
662 "Port " + src->
get_id() +
" already bound to " + dest->
get_id());
664 "Port " + dest->
get_id() +
" already bound to " + src->
get_id());
665 auto* p_d = GetPointerS<port_o>(dest);
666 p_s->add_connection(dest);
667 p_d->add_connection(src);
673 "Ports and signals have to be compatible: " + src->
get_path() +
" -> " + dest->
get_path());
674 p_s->add_connection(dest);
675 auto* c_d = GetPointerS<signal_o>(dest);
698 auto* s_s = GetPointerS<signal_o>(src);
707 auto* p_d = GetPointerS<port_o>(dest);
708 p_d->add_connection(src);
731 auto* s_s = GetPointerS<signal_o>(src);
737 "Ports and signals have to be compatible: " + src->
get_path() +
" -> " + dest->
get_path());
739 auto* p_d = GetPointerS<port_o>(dest);
740 p_d->add_connection(src);
763 auto* c_s = GetPointerS<constant_o>(src);
769 "Incompatible object types: " + src->
get_id() +
" -> " + dest->
get_id());
772 c_s->add_connection(dest);
773 auto* p_d = GetPointerS<port_o>(dest);
774 p_d->add_connection(src);
809 const auto output_directory =
Param->getOption<std::string>(OPT_dot_directory);
810 std::ofstream f((output_directory + file_name).c_str());
823 THROW_ERROR(std::string(
"Not supported graph type"));
833 auto* circ = GetPointer<component_o>(
circuit);
838 os <<
"Error : empty circuit.\n";
845 THROW_ASSERT(gi,
"graph property not associated with the circuit graph");
851 auto* top_c = GetPointer<module>(obj);
852 if(top_c->get_internal_objects_size() == 0 && obj->
get_owner())
854 for(
unsigned int i = 0; i < top_c->get_in_port_size(); i++)
856 auto* temp = GetPointer<port_o>(top_c->get_in_port(i));
861 if(temp->get_kind() ==
port_o_K && temp->get_connections_size() == 0 && !permissive)
863 THROW_ERROR(std::string(
"Error : component " + obj->
get_id() +
" input port " + temp->get_id() +
866 else if(temp->get_kind() ==
port_o_K && temp->get_connections_size() == 0 && permissive)
870 THROW_WARNING(
"component " + obj->
get_id() +
" input port " + temp->get_id() +
" is not bound");
875 for(
unsigned int w = 0; w < temp->get_ports_size(); w++)
877 auto* tempi = GetPointer<port_o>(temp->get_port(w));
878 THROW_ASSERT(tempi,
"Expected a port got something of different");
879 if(tempi->get_connections_size() == 0 && !permissive)
882 std::string(
"Component " + obj->
get_id() +
" input port " + tempi->get_id() +
" is not bound\n"));
884 else if(tempi && tempi->get_connections_size() == 0 && permissive)
888 THROW_WARNING(
"component " + obj->
get_id() +
" input port " + tempi->get_id() +
" is not bound");
894 for(
unsigned int i = 0; i < top_c->get_out_port_size(); i++)
896 auto* temp = GetPointer<port_o>(top_c->get_out_port(i));
901 if(temp->get_kind() ==
port_o_K && temp->get_connections_size() == 0 && !permissive)
903 THROW_ERROR(std::string(
"Error : component " + obj->
get_id() +
" output port " + temp->get_id() +
906 else if(temp->get_kind() ==
port_o_K && temp->get_connections_size() == 0 && permissive)
910 THROW_WARNING(
"component " + obj->
get_id() +
" output port " + temp->get_id() +
" is not bound");
915 for(
unsigned int w = 0; w < temp->get_ports_size(); w++)
917 auto* tempi = GetPointer<port_o>(temp->get_port(w));
918 THROW_ASSERT(tempi,
"Expected a port got something of different");
919 if(tempi->get_connections_size() == 0 && !permissive)
921 THROW_ERROR(std::string(
"Error : component " + obj->
get_id() +
" output port " + tempi->get_id() +
924 else if(tempi->get_connections_size() == 0 && permissive)
928 THROW_WARNING(
"component " + obj->
get_id() +
" output port " + tempi->get_id() +
" is not bound");
934 for(
unsigned int i = 0; i < top_c->get_in_out_port_size(); i++)
936 auto* temp = GetPointer<port_o>(top_c->get_in_out_port(i));
941 if(temp->get_kind() ==
port_o_K && temp->get_connections_size() == 0 && !permissive)
943 THROW_ERROR(std::string(
"Error : component " + obj->
get_id() +
" in/output port " + temp->get_id() +
946 else if(temp->get_kind() ==
port_o_K && temp->get_connections_size() == 0 && permissive)
950 THROW_WARNING(
"component " + obj->
get_id() +
" in/output port " + temp->get_id() +
" is not bound");
955 for(
unsigned int w = 0; w < temp->get_ports_size(); w++)
957 auto* tempi = GetPointer<port_o>(temp->get_port(w));
958 THROW_ASSERT(tempi,
"Expected a port got something of different");
959 if(tempi->get_connections_size() == 0 && !permissive)
961 THROW_ERROR(std::string(
"Error : component " + obj->
get_id() +
" in/output port " + tempi->get_id() +
964 else if(tempi->get_connections_size() == 0 && permissive)
975 for(
unsigned int i = 0; i < top_c->get_gen_port_size(); i++)
977 auto* temp = GetPointer<port_o>(top_c->get_gen_port(i));
982 if(temp->get_kind() ==
port_o_K && temp->get_connections_size() == 0 && !permissive)
984 THROW_ERROR(std::string(
"Error : component " + obj->
get_id() +
" generic port " + temp->get_id() +
987 else if(temp->get_kind() ==
port_o_K && temp->get_connections_size() == 0 && permissive)
991 THROW_WARNING(
"component " + obj->
get_id() +
" generic port " + temp->get_id() +
" is not bound");
996 for(
unsigned int w = 0; w < temp->get_ports_size(); w++)
998 auto* tempi = GetPointer<port_o>(temp->get_port(w));
999 THROW_ASSERT(tempi,
"Expected a port got something of different");
1000 if(tempi->get_connections_size() == 0 && !permissive)
1002 THROW_ERROR(std::string(
"Error : component " + obj->
get_id() +
" generic port " + tempi->get_id() +
1003 " is not bound\n"));
1005 else if(tempi->get_connections_size() == 0 && permissive)
1009 THROW_WARNING(
"component " + obj->
get_id() +
" generic port " + tempi->get_id() +
" is not bound");
1016 for(
unsigned int i = 0; i < top_c->get_internal_objects_size(); i++)
1018 switch(top_c->get_internal_object(i)->get_kind())
1023 if(!top_c->get_internal_object(i)->get_black_box())
1040 THROW_ERROR(
"Internal object not foreseen: " + std::string(top_c->get_internal_object(i)->get_kind_text()));
1067 const std::string& fu_name,
1068 const std::string& library_name,
1070 const technology_managerConstRef TM)
1073 "Expected a component or a channel got something of different");
1076 std::string(
"gate not found: ") + fu_name +
" " + std::string(
" in library: ") + library_name);
1077 if(GetPointer<functional_unit_template>(port_tec_node))
1079 port_tec_node = GetPointer<functional_unit_template>(port_tec_node)->FU;
1082 THROW_ASSERT(GetPointer<functional_unit>(port_tec_node),
"GetPointer<functional_unit>(port_tec_node) is null");
1083 THROW_ASSERT(GetPointer<functional_unit>(port_tec_node)->CM,
1084 "GetPointer<functional_unit>(port_tec_node)->CM is null for " + fu_name);
1085 structural_objectRef curr_lib_instance = GetPointer<functional_unit>(port_tec_node)->CM->get_circ();
1092 curr_lib_instance->
copy(curr_gate);
1093 curr_gate->set_id(
id);
1096 GetPointer<module>(owner)->add_internal_object(curr_gate);
1104 template <
class Graph>
1106 typename boost::graph_traits<Graph>::vertex_descriptor
B,
int selector,
Graph& g,
1109 typename boost::graph_traits<Graph>::out_edge_iterator oi, oi_end;
1110 typename boost::graph_traits<Graph>::edge_descriptor e;
1112 for(boost::tie(oi, oi_end) = boost::out_edges(A, g); oi != oi_end; oi++)
1123 boost::tie(e, inserted) = boost::add_edge(A, B,
EdgeProperty(selector), g);
1141 boost::graph_traits<graphs_collection>::vertex_descriptor en,
1142 boost::graph_traits<graphs_collection>::vertex_descriptor ex,
bool is_critical =
false)
1145 "Expected a port got something of different");
1147 "Expected a port got something of different");
1153 boost::graph_traits<graphs_collection>::vertex_descriptor src,
1154 tgt = boost::graph_traits<graphs_collection>::null_vertex();
1162 owner1 = owner1->get_owner();
1166 owner2 = owner2->get_owner();
1170 if(GetPointerS<port_o>(p_obj2)->get_is_clock() || GetPointerS<port_o>(p_obj2)->get_is_clock())
1175 if(owner1 == owner2)
1177 if(GetPointerS<port_o>(p_obj1)->get_port_direction() == port_o::OUT &&
1178 GetPointerS<port_o>(p_obj2)->get_port_direction() == port_o::IN)
1180 std::swap(p_obj1, p_obj2);
1189 if(owner1 && owner1->get_owner() == owner2)
1191 src = module_vertex_rel.at(owner1);
1192 if(GetPointerS<port_o>(p_obj2)->get_port_direction() == port_o::OUT)
1196 else if(GetPointerS<port_o>(p_obj2)->get_port_direction() == port_o::IN)
1200 else if(GetPointerS<port_o>(p_obj2)->get_port_direction() == port_o::IO)
1202 if(GetPointerS<port_o>(p_obj1)->get_port_direction() == port_o::IN)
1215 if(GetPointerS<port_o>(p_obj1)->get_port_direction() == port_o::IN)
1217 std::swap(src, tgt);
1218 std::swap(p_obj1, p_obj2);
1222 else if(owner2 && owner2->get_owner() == owner1)
1225 tgt = module_vertex_rel.find(owner2)->second;
1229 src = module_vertex_rel.find(owner1)->second;
1230 tgt = module_vertex_rel.find(owner2)->second;
1232 if(GetPointerS<port_o>(p_obj1)->get_port_direction() == port_o::IN &&
1233 GetPointerS<port_o>(p_obj2)->get_port_direction() == port_o::OUT)
1235 std::swap(src, tgt);
1236 std::swap(p_obj1, p_obj2);
1240 if(GetPointerS<port_o>(p_obj1)->get_port_direction() == port_o::IN &&
1241 GetPointerS<port_o>(p_obj2)->get_port_direction() == port_o::IN)
1247 THROW_ASSERT(GetPointerS<port_o>(p_obj1)->get_port_direction() == port_o::OUT &&
1248 GetPointerS<port_o>(p_obj2)->get_port_direction() == port_o::IN,
1249 "Not supported situation: " + p_obj1->get_path() +
" <-> " + p_obj2->get_path());
1257 if ((pp1->get_port_direction() == port_o::IN && pp2->get_port_direction() != port_o::IN) ||
1258 (pp1->get_port_direction() != port_o::OUT && pp2->get_port_direction() == port_o::OUT)
1260 std::swap(pp1, pp2);
1264 if (owner2 && owner1 == owner2->get_owner())
1266 THROW_ASSERT(module_vertex_rel.find(owner2) != module_vertex_rel.end(),
"module not found");
1267 v2 = module_vertex_rel.find(owner2)->second;
1268 if (pp1->get_port_direction() != port_o::OUT or pp2->get_port_direction() == port_o::IN)
1274 std::swap(pp1, pp2);
1277 else if (owner1 && owner2 == owner1->get_owner())
1279 THROW_ASSERT(module_vertex_rel.find(owner1) != module_vertex_rel.end(),
"module not found");
1280 v1 = module_vertex_rel.find(owner1)->second;
1281 if (pp2->get_port_direction() != port_o::OUT or pp1->get_port_direction() == port_o::IN)
1285 std::swap(pp1, pp2);
1292 THROW_ASSERT(module_vertex_rel.find(owner1) != module_vertex_rel.end(),
"module not found");
1293 v1 = module_vertex_rel.find(owner1)->second;
1294 THROW_ASSERT(module_vertex_rel.find(owner2) != module_vertex_rel.end(),
"module not found");
1295 v2 = module_vertex_rel.find(owner2)->second;
1300 if ((pp1->get_port_direction() == port_o::IO || pp1->get_port_direction() == port_o::GEN) && (pp2->get_port_direction() == port_o::IO || pp2->get_port_direction() == port_o::GEN))
1305 else if ((pp1->get_port_direction() == port_o::IN && pp2->get_port_direction() == port_o::IN && ((v1 == en && v2 != en) || (v1 != en && v2 == en))) ||
1306 (pp1->get_port_direction() == port_o::OUT && pp2->get_port_direction() == port_o::OUT && ((v1 == ex && v2 != ex) || (v1 != ex && v2 == ex))) ||
1307 pp1->get_port_direction() != pp2->get_port_direction()
1311 if (pp1 != GetPointer<port_o>(p1))
1313 if (pp1->get_is_clock() || pp2->get_is_clock())
1320 if (pp1->get_is_clock() || pp2->get_is_clock())
1341 boost::graph_traits<graphs_collection>::vertex_descriptor en,
1342 boost::graph_traits<graphs_collection>::vertex_descriptor ex,
bool is_critical =
false)
1354 switch(p2->get_kind())
1367 auto* conn = GetPointer<signal_o>(p2);
1368 for(
unsigned int k = 0;
k < conn->get_connected_objects_size();
k++)
1370 if(conn->get_port(
k) != p1)
1382 boost::graph_traits<graphs_collection>::vertex_descriptor v1;
1385 owner1 = owner1->get_owner();
1387 THROW_ASSERT(module_vertex_rel.find(owner1) != module_vertex_rel.end(),
"module not found");
1388 v1 = module_vertex_rel.find(owner1)->second;
1398 boost::graph_traits<graphs_collection>::vertex_descriptor v1, v2;
1401 owner1 = owner1->get_owner();
1403 if(owner1 == owner2)
1409 THROW_ASSERT(module_vertex_rel.find(owner1) != module_vertex_rel.end(),
"module not found");
1410 v1 = module_vertex_rel.find(owner1)->second;
1412 THROW_ASSERT(module_vertex_rel.find(p2) != module_vertex_rel.end(),
"module not found");
1413 v2 = module_vertex_rel.find(p2)->second;
1424 THROW_ERROR(
"unexpected object type: " + std::string(p2->get_kind_text()));
1436 std::string v_en_name =
"PI";
1444 if(GetPointer<port_o>(port)->get_critical())
1453 std::string v_ex_name =
"PO";
1460 if(GetPointer<port_o>(port)->get_critical())
1468 graph_info->Entry = v_en;
1469 graph_info->Entry_name = v_en_name;
1470 graph_info->Exit = v_ex;
1471 graph_info->Exit_name = v_ex_name;
1474 std::map<structural_objectRef, boost::graph_traits<graphs_collection>::vertex_descriptor> module_vertex_rel;
1494 " - Creating the node for the instance " + mod_int->get_path());
1520 if(mod_inst->get_in_port_size())
1523 for(
unsigned int j = 0; j < mod_inst->get_in_port_size(); j++)
1539 if(!(GetPointer<signal_o>(bounded) && !(GetPointer<signal_o>(bounded)->is_full_connected())))
1542 " - Adding direct edge from " + bounded->
get_path() +
" to " +
1544 bool is_critical =
false;
1547 if((GetPointer<port_o>(bounded)->get_critical()) or
1548 (GetPointer<signal_o>(bounded) && GetPointer<signal_o>(bounded)->get_critical()))
1553 add_directed_edge(bg, module_vertex_rel, in_port, bounded, v_en, v_ex, is_critical);
1558 auto* pv = GetPointer<port_o>(mod_inst->get_in_port(j));
1560 for(
unsigned int k = 0;
k < pv->get_ports_size();
k++)
1564 " - Port: " + in_port_i->
get_path());
1566 GetPointer<port_o>(pv->get_port(
k))->find_bounded_object();
1572 " - Bounded object: " + bounded->get_path() +
" - " +
1573 bounded->get_kind_text());
1574 if(!(GetPointer<signal_o>(bounded) && !(GetPointer<signal_o>(bounded)->is_full_connected())))
1577 " - Adding direct edge from " + bounded->get_path() +
" to " +
1582 "Critical paths are not correctly identified when port vectors are involved");
1591 if(mod_inst->get_out_port_size())
1593 for(
unsigned int j = 0; j < mod_inst->get_out_port_size(); j++)
1610 " - Adding direct edge from " + out_port->
get_path() +
" to " +
1612 bool is_critical =
false;
1613 if(GetPointer<port_o>(out_port)->get_critical())
1615 if(GetPointer<port_o>(target)->get_critical())
1620 add_directed_edge(bg, module_vertex_rel, out_port, target, v_en, v_ex, is_critical);
1624 auto* pv = GetPointer<port_o>(
out_port);
1630 "---Adding direct edge from " + pv->get_path() +
" to " +
1636 for(
unsigned int k = 0;
k < pv->get_ports_size();
k++)
1638 const port_o* p = GetPointer<port_o>(pv->get_port(
k));
1645 "---Adding direct edge from " + p->
get_path() +
" to " + target->get_path());
1649 "Critical paths are not correctly identified when port vectors are involved");
1660 if(mod_inst->get_in_out_port_size())
1662 for(
unsigned int j = 0; j < mod_inst->get_in_out_port_size(); j++)
1665 " * In/Out port: " + mod_inst->get_in_out_port(j)->get_path());
1667 GetPointer<port_o>(mod_inst->get_in_out_port(j))->find_bounded_object();
1672 if(mod_inst->get_in_out_port(j)->get_kind() ==
port_o_K)
1674 add_directed_edge(bg, module_vertex_rel, mod_inst->get_in_out_port(j), bounded, v_en, v_ex);
1678 auto* pv = GetPointer<port_o>(mod_inst->get_in_out_port(j));
1679 for(
unsigned int k = 0;
k < pv->get_ports_size();
k++)
1682 GetPointer<port_o>(pv->get_port(
k))->find_bounded_object();
1693 if(mod_inst->get_gen_port_size())
1695 for(
unsigned int j = 0; j < mod_inst->get_gen_port_size(); j++)
1698 " * Generic port: " + mod_inst->get_gen_port(j)->get_path());
1700 GetPointer<port_o>(mod_inst->get_gen_port(j))->find_bounded_object();
1705 if(mod_inst->get_gen_port(j)->get_kind() ==
port_o_K)
1707 add_directed_edge(bg, module_vertex_rel, mod_inst->get_gen_port(j), bounded, v_en, v_ex);
1711 auto* pv = GetPointer<port_o>(mod_inst->get_gen_port(j));
1712 for(
unsigned int k = 0;
k < pv->get_ports_size();
k++)
1715 GetPointer<port_o>(pv->get_port(
k))->find_bounded_object();
1749 for(
const auto& iter : list)
1751 const auto* Enode = GetPointer<const xml_element>(iter);
1756 CM->get_circ()->xload(Enode, CM->get_circ(), CM);
1768 auto* pin = GetPointer<port_o>(obj);
1769 for(
unsigned int j = 0; j < pin->get_connections_size(); j++)
1772 if(GetPointer<port_o>(comp))
1776 if(GetPointer<signal_o>(comp))
1778 GetPointer<signal_o>(comp)->remove_port(obj);
1788 auto* obj_mod = GetPointer<module>(obj);
1791 for(
unsigned int i = 0; i < obj_mod->get_in_port_size(); i++)
1800 for(
unsigned int p = 0; p < GetPointer<port_o>(comp_port)->get_ports_size(); p++)
1807 for(
unsigned int i = 0; i < obj_mod->get_out_port_size(); i++)
1816 for(
unsigned int p = 0; p < GetPointer<port_o>(comp_port)->get_ports_size(); p++)
1824 auto*
top = GetPointer<module>(top_obj);
1825 top->remove_internal_object(obj);
1826 for(
const auto&
k :
remove)
1828 top->remove_internal_object(
k);
1840 auto* p_old = GetPointer<port_o>(old_obj);
1841 THROW_ASSERT(p_old,
"Only port can change their connection");
1842 THROW_ASSERT(new_obj,
"New connection has to be a valid one");
1844 for(
unsigned int i = 0; i < p_old->get_connections_size(); i++)
1849 if(GetPointer<signal_o>(conn_comp) and
1850 GetPointer<signal_o>(conn_comp)->get_owner()->get_kind() !=
signal_vector_o_K and
1855 if(GetPointer<port_o>(conn_comp) and conn_comp->
get_owner() != owner and
1856 conn_comp->
get_owner()->get_owner() != owner and
1861 if(GetPointer<port_o>(new_obj) and !GetPointer<port_o>(new_obj)->is_connected(conn_comp))
1865 if(GetPointer<port_o>(conn_comp))
1867 GetPointer<port_o>(conn_comp)->substitute_connection(old_obj, new_obj);
1869 else if(GetPointer<signal_o>(conn_comp))
1871 GetPointer<signal_o>(conn_comp)->substitute_port(old_obj, new_obj);
void add_connection(structural_objectRef src, structural_objectRef dest)
Create a connection between a source structural object and a destination structural object...
void remove_module(structural_objectRef obj)
static void xload(const xml_element *node, structural_managerRef const &CM)
Load a structural manager from an xml file.
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
void remove_empty_signal(structural_objectRef &signal)
Remove an existing signal from the SM.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
void * top(node_stack *head)
File containing functions and utilities to support the printing of debug messagges.
refcount< NP_functionality > NP_functionalityRef
RefCount type definition of the connection class structure.
const structural_objectRef get_internal_object(unsigned int n) const
Return the ith internal objects.
#define PRINT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
const std::string & get_id() const
Return the identifier associated with the structural_object.
void remove_connection(structural_objectRef src, structural_objectRef dest)
structural_objectRef find_bounded_object(const structural_objectConstRef f_owner=structural_objectConstRef()) const
Find the object bounded to the port.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
static const unsigned int PARAMETRIC_PORT
so_kind
Enumerative type for structural object classes, it is used with get_kind() function to know the actua...
This class describes a port associated with a component or a channel.
const structural_objectRef get_circ() const
Get a reference to circ field.
const std::vector< std::string > SplitString(const std::string &input, const std::string &separators)
Function which splits a string into tokens.
#define GET_NODE_INFO(data, NodeInfo, vertex_index)
structural_manager(const structural_manager &inst)=delete
This class describes a generic channel.
static bool check_object(std::string id, structural_objectRef owner, so_kind type)
Verify if the component is already associated with owner.
unsigned int get_out_port_size() const
Return the number of output ports.
bool get_critical() const
return if the component is critical or not
std::string get_NP_functionality(NP_functionaly_type type) const
Return the description provided the type.
Node, edge and graph description of the graph associated with a structural description.
Class specification of the graph structures.
int debug_level
debug level
static void add_directed_edge(graphs_collection *bg, const std::map< structural_objectRef, boost::graph_traits< graphs_collection >::vertex_descriptor > &module_vertex_rel, const structural_objectRef &p1, const structural_objectRef &p2, boost::graph_traits< graphs_collection >::vertex_descriptor en, boost::graph_traits< graphs_collection >::vertex_descriptor ex, bool is_critical=false)
Add a directed edge between the nodes associated with p1 and p2.
exceptions managed by PandA
const ParameterConstRef Param
class containing all the parameters
const structural_objectRef get_in_port(unsigned int n) const
Return the ith input port.
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...
The property associated with edge.
unsigned int get_internal_objects_size() const
Return the number of internal objects.
#define EDGE_ADD_FROM_PORT(data, edge_index, from)
Add a from port to the edge.
Class specification of the manager of the technology library data structures.
Base class description of data information associated with each node of a graph.
redefinition of map to manage ordered/unordered structures
#define GET_TYPE_NAME(structural_obj)
Macro returning the string name of a type.
#define CHANNEL_SELECTOR
Channel line selector.
void print(std::ostream &os) const
Function that prints the circuit data structure.
virtual void xwrite(xml_element *Enode)
Add a structural_object to an xml tree.
#define THROW_WARNING(str_expr)
helper function used to throw a warning in a standard way: though it uses PRINT_DBG_MEX, the debug level used is such that the message is always printed
Auxiliary methods for manipulating string.
port_direction
Enumerative type describing the direction of a port.
void add_sensitivity(structural_objectRef obj, structural_objectRef pr)
Add an object to the sensitivity list of process/service.
static bool check_type(structural_type_descriptorRef src_type, structural_type_descriptorRef dest_type)
Check if two type descriptors are consistent.
void INIT(bool permissive=false)
virtual std::string get_kind_text() const =0
Virtual function used to get the string name of a structural_object instance.
#define TYPE_EXIT
constant identifying the node type of an exit node.
void check_structure(structural_objectRef obj, bool permissive=false)
perform some check on the circuit manager.
structural_objectRef create(std::string id, so_kind ctype, structural_objectRef owner, structural_type_descriptorRef obj_type, unsigned int treenode=0)
Create a new object of the circuit.
bool starts_with(const std::string &str, const std::string &pattern)
static void add_NP_functionality(structural_objectRef cir, NP_functionality::NP_functionaly_type dt, std::string functionality_description)
Add a not-parsed functionality.
void add_NP_functionality(NP_functionaly_type type, const std::string &functionality_description)
Add a non SystemC based description.
#define GET_TO_PORT(data, edge_index)
Helper macro returning the to port/channel.
unsigned map[NUM_VERTICES]
#define ENTRY
Superclass include.
void set_top_info(const std::string &id, const technology_managerRef &LM, const std::string &Library="")
~structural_manager()
Destructor.
static const uint32_t k[]
void circuit_add_edge(typename boost::graph_traits< Graph >::vertex_descriptor A, typename boost::graph_traits< Graph >::vertex_descriptor B, int selector, Graph &g, const structural_objectRef from1, structural_objectRef to1, bool is_critical=false)
this template function adds an edge to the bulk graph and possibly a label to the edge...
void remove_port_connection(const structural_objectRef &obj)
Class specification of the data structures used to manage technology information. ...
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.
const structural_objectRef get_out_port(unsigned int n) const
Return the ith output port.
static const unsigned int PARAMETRIC_SIGNAL
const vertex & get_PI(structural_objectRef level) const
Return the PI vertex of the circuit, at a specific level.
#define DATA_SELECTOR
Data line selector.
bool check_type(structural_objectRef src_type, structural_objectRef dest_type)
Check if two type structural object are consistent.
redefinition of set to manage ordered/unordered structures
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
bool check_bound(structural_objectRef src, structural_objectRef sign)
Function that check if a signal (or port) is already bound on a port.
General class used to describe a graph in PandA.
virtual enum so_kind get_kind() const =0
Virtual function used to find the real type of a structural_object instance.
#define GET_CLASS_NAME(meth)
Macro returning the name of a class.
std::list< xml_nodeRef > node_list
type for list of xml nodes
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
structural_objectRef circuit
Structure that represent circuit.
graph * data_graph
Graph only composed by the data flow in the circuit.
refcount< NodeInfo > NodeInfoRef
RefCount type definition of the NodeInfo class structure.
static void add_directed_edge_single(graphs_collection *bg, const std::map< structural_objectRef, boost::graph_traits< graphs_collection >::vertex_descriptor > &module_vertex_rel, const structural_objectRef &p1, const structural_objectRef &p2, boost::graph_traits< graphs_collection >::vertex_descriptor en, boost::graph_traits< graphs_collection >::vertex_descriptor ex, bool is_critical=false)
Add a directed edge between the nodes associated with p1 and p2.
Base class for graph property.
#define HIERARCHY_SEPARATOR
Information associated with a circuit graph node.
GraphInfoRef GetGraphInfo()
FIXME: this method should become protected and called by equivalent method in subclasses Get the grap...
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.
Template definition of refcount.
void SetParameter(const std::string &name, const std::string &value)
Specify a parameter for the top module.
refcount< GraphInfo > GraphInfoRef
RefCount type definition of the GraphInfo class structure.
unsigned int get_in_port_size() const
Return the number of input ports.
This class describes a simple logic/RTL signal.
std::string id_type
Original type id of the structural object.
void reconnect_signal_member(structural_objectRef &member, structural_objectRef &from_signal, structural_objectRef &to_signal)
Disconnects a member from from_signal and reconnects it to to_signal.
const structural_type_descriptorRef & get_typeRef() const
Return the type descriptor of the structural_object.
graph * circuit_graph
Graph containing all lines of the circuit.
static structural_objectRef add_sign(std::string id, structural_objectRef owner, structural_type_descriptorRef sign_type, unsigned int treenode=0)
Create a new signal.
const structural_objectRef get_owner() const
Return the owner.
#define GET_FROM_PORT(data, edge_index)
Helper macro returning the from port.
virtual void copy(structural_objectRef dest) const
Perform a copy of the structural object.
int debug_level
debug level for the object
void change_connection(structural_objectRef old_obj, structural_objectRef new_obj, structural_objectRef owner)
static void change_port_direction(structural_objectRef port_object, port_o::port_direction pdir, structural_objectRef owner)
Change the direction of the port.
refcount< structural_object > structural_objectRef
RefCount type definition of the structural_object class structure.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
this class is used to manage the command-line or XML options.
NP_functionaly_type
functionality type descriptors.
#define EDGE_ADD_TO_PORT(data, edge_index, _to)
Add a to port/channel to the edge.
node_list const & get_children()
Obtain the list of child nodes.
#define TYPE_ENTRY
constant identifying the node type of an entry node.
Class implementation of the structural_manager.
This class describes a generic component.
graphs_collection * og
Bulk graph used to represent all graphs.
Class specification of the manager for each library.
#define CLOCK_SELECTOR
Clock line selector.
This class describes a constant value.
#define PURE_DATA_SELECTOR
All but clock lines selector.
void build_graph(const structural_objectRef &top, graphs_collection *bg)
build a graph starting from a structural object.
#define DEBUG_LEVEL_VERBOSE
verbose debugging print is performed.
Information associated with the whole graph of a circuit.
Not parsed functionality descriptor of a module.
#define ALL_LINES_SELECTOR
All lines selector.
This class describes a generic module.
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.
const std::string get_name() const
Returns the name of the type descriptor.
virtual boost::graph_traits< boost_graphs_collection >::vertex_descriptor AddVertex(const NodeInfoRef info)
Add a vertex to this graph with a property.
xml_element * add_child_element(const std::string &name)
Add a child element to this node.
void xwrite(xml_element *rootnode, const technology_nodeRef &tn=technology_nodeRef()) const
Add a component to an xml tree.
void WriteDot(const std::string &file_name, circuit_graph_type gt, graph *g=nullptr) const
Function that writes the dot file of the graph by using the AT&T dot format.
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 EDGE_SET_CRITICAL(data, edge_index, critical)
Set the edge as critical.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...