OpenASIP  2.0
Classes | Functions
ipxact Namespace Reference

Classes

struct  BusInfo
 
struct  ModuleInfo
 
struct  Parameter
 
struct  Port
 

Functions

BusInfo parseBus (std::string file)
 
ModuleInfo parseComponent (std::string file)
 

Function Documentation

◆ parseBus()

BusInfo ipxact::parseBus ( std::string  file)

Parse IP-XACT abstraction bus definition.

Definition at line 39 of file IPXact.cc.

39  {
40  BusInfo bus;
41  using boost::property_tree::ptree;
42 
43  ptree pt;
44  read_xml(file, pt);
45 
46  bus.name = pt.get_child(
47  "ipxact:abstractionDefinition.ipxact:busType"
48  ".<xmlattr>.name")
49  .data();
50  ptree ports = pt.get_child(
51  "ipxact:abstractionDefinition."
52  "ipxact:ports");
53 
54  for (auto&& p : ports) {
55  if (p.first == "ipxact:port") {
56  std::string name =
57  p.second.get_child("ipxact:logicalName").data();
58  std::string width = p.second
59  .get_child(
60  "ipxact:wire."
61  "ipxact:onMaster.ipxact:width")
62  .data();
63  std::string direction =
64  p.second
65  .get_child(
66  "ipxact:wire."
67  "ipxact:onMaster.ipxact:direction")
68  .data();
69  std::string left = width + "-1";
70  std::string right = "0";
71  std::string defaultValue =
72  direction == "out"
73  ? p.second.get_child("ipxact:wire.ipxact:defaultValue")
74  .data()
75  : "";
76 
77  bus.ports.emplace_back(Port{
78  name, direction, true, left, right, width, defaultValue});
79  }
80  }
81 
82  return bus;
83 }

References ipxact::BusInfo::name, and ipxact::BusInfo::ports.

Referenced by FUGen::createExternalInterfaces().

◆ parseComponent()

ModuleInfo ipxact::parseComponent ( std::string  file)

Parse IP-XACT component description.

Definition at line 86 of file IPXact.cc.

86  {
87  ModuleInfo module;
88  using boost::property_tree::ptree;
89 
90  ptree pt;
91  read_xml(file, pt);
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();
96 
97  // get parameters if any.
98  if (parameters) {
99  for (auto&& p : *parameters) {
100  if (p.first == "ipxact:parameter") {
101  std::string id =
102  p.second.get_child("<xmlattr>.parameterId").data();
103  std::string type =
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);
109  }
110  }
111  }
112 
113  // get ports
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();
119  std::transform(
120  direction.begin(), direction.end(), direction.begin(),
121  ::tolower);
122  std::transform(name.begin(), name.end(), name.begin(), ::tolower);
123  bool vector = false;
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") {
130  vector = true;
131  left = w.second.get_child("ipxact:vector.ipxact:left")
132  .data();
133  width = left;
134  right = w.second.get_child("ipxact:vector.ipxact:right")
135  .data();
136  }
137  }
138  // replace uuids in left and 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);
143  right = "0"; // boost::regex_replace(right, expr, m.name);
144  }
145  width += "+1";
146 
147  module.ports.emplace_back(
148  Port{name, direction, vector, left, right, width, ""});
149  }
150  }
151 
152  return module;
153 }

References ipxact::ModuleInfo::name, ipxact::ModuleInfo::parameters, and ipxact::ModuleInfo::ports.

Referenced by FUGen::buildReplaces(), and FUGen::createOperationResources().