31 #include <boost/optional.hpp>
32 #include <boost/property_tree/ptree.hpp>
33 #include <boost/property_tree/xml_parser.hpp>
34 #include <boost/regex.hpp>
41 using boost::property_tree::ptree;
46 bus.
name = pt.get_child(
47 "ipxact:abstractionDefinition.ipxact:busType"
50 ptree ports = pt.get_child(
51 "ipxact:abstractionDefinition."
54 for (
auto&& p : ports) {
55 if (p.first ==
"ipxact:port") {
57 p.second.get_child(
"ipxact:logicalName").data();
58 std::string width = p.second
61 "ipxact:onMaster.ipxact:width")
63 std::string direction =
67 "ipxact:onMaster.ipxact:direction")
69 std::string left = width +
"-1";
70 std::string right =
"0";
71 std::string defaultValue =
73 ? p.second.get_child(
"ipxact:wire.ipxact:defaultValue")
78 name, direction,
true, left, right, width, defaultValue});
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};
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")
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,
""});