Parse IP-XACT component description.
88 using boost::property_tree::ptree;
92 boost::optional<ptree&> parameters =
93 pt.get_child_optional(
"ipxact:component.ipxact:parameters");
94 ptree ports = pt.get_child(
"ipxact:component.ipxact:model.ipxact:ports");
95 module.name = pt.get_child(
"ipxact:component.ipxact:name").data();
99 for (
auto&& p : *parameters) {
100 if (p.first ==
"ipxact:parameter") {
102 p.second.get_child(
"<xmlattr>.parameterId").data();
104 p.second.get_child(
"<xmlattr>.type").data();
105 std::string name = p.second.get_child(
"ipxact:name").data();
106 std::string value = p.second.get_child(
"ipxact:value").data();
107 Parameter parameter = {id, type, name, value};
108 module.parameters.emplace_back(parameter);
114 for (
auto&& p : ports) {
115 if (p.first ==
"ipxact:port") {
116 std::string name = p.second.get_child(
"ipxact:name").data();
117 std::string direction =
118 p.second.get_child(
"ipxact:wire.ipxact:direction").data();
120 direction.begin(), direction.end(), direction.begin(),
122 std::transform(name.begin(), name.end(), name.begin(), ::tolower);
124 std::string left =
"0";
125 std::string right =
"0";
126 std::string width =
"0";
127 ptree wire = p.second.get_child(
"ipxact:wire");
128 for (
auto&& w : wire) {
129 if (w.first ==
"ipxact:vectors") {
131 left = w.second.get_child(
"ipxact:vector.ipxact:left")
134 right = w.second.get_child(
"ipxact:vector.ipxact:right")
139 for (
auto&& m : module.parameters) {
140 boost::regex expr(
"\\b" + m.id +
"\\b");
141 width = boost::regex_replace(width, expr, m.value);
142 left = boost::regex_replace(left, expr, m.name);
147 module.ports.emplace_back(
148 Port{name, direction, vector, left, right, width,
""});