11 using namespace bil::xdlparser_detail;
14 XDLParserImp::XDLParserImp():
15 m_headerParsed(false),
20 m_primitiveTypesMap(),
24 m_quoteBuffer =
new char[QUOTE_BUFFER_SIZE+1];
30 delete[] m_quoteBuffer;
35 void XDLParserImp::setupSyntax()
52 void XDLParserImp::fillDeviceLookups()
59 size_t count = tiles.size();
60 for (
size_t i = 0; i < count; ++i)
62 const Tile& tile = tiles[i];
63 m_tileMap.insert(std::make_pair(tile.
name(), i));
68 count = tileTypes.size();
69 m_wirePIPMaps.resize(count);
70 for (
size_t i = 0; i < count; ++i)
74 const TileType& tileType = tileTypes[i];
79 size_t wireCount = wires.size();
80 for (
size_t j = 0; j < wireCount; ++j)
82 const Wire& wire = wires[j];
83 wireMap.insert(std::make_pair(wire.
name(), j));
89 size_t pipCount = pips.size();
90 for (
size_t j = 0; j < pipCount; ++j)
92 const PIP& pip = pips[j];
93 pipMap.insert(std::make_pair(pip, j));
99 count = primitiveTypes.size();
100 m_pinMaps.resize(count);
101 for (
size_t i = 0; i < count; ++i)
105 m_primitiveTypesMap.insert(std::make_pair(primitiveType.
name(), i));
110 const Pins& pins = primitiveType.
pins();
111 size_t pinCount = pins.size();
112 for (
size_t j = 0; j < pinCount; ++j)
114 const Pin& pin = pins[j];
121 void XDLParserImp::clearAll()
124 m_headerParsed =
false;
135 clearTemporaryData();
139 void XDLParserImp::clearTemporaryData()
143 m_wirePIPMaps.clear();
145 m_primitiveTypesMap.clear();
146 m_instanceMap.clear();
151 void XDLParserImp::addInstance(
const char* instanceName)
154 nameIndexMap_t::iterator lb = m_instanceMap.lower_bound(instanceName);
155 if ((m_instanceMap.end() != lb) && (instanceName == lb->first))
throw Exception();
158 size_t count = m_instances->size();
160 m_instance = &((*m_instances)[count]);
161 (m_instance->
name()).assign(instanceName);
164 m_instanceMap.insert(lb, std::make_pair(instanceName, count));
168 void XDLParserImp::addNet(
const char* netName)
171 nameSet_t::iterator lb = m_netSet.lower_bound(netName);
172 if ((m_netSet.end() != lb) && (netName == *lb))
throw Exception();
175 size_t count = m_nets->size();
176 m_nets->push_back(
Net());
177 m_net = &((*m_nets)[count]);
178 (m_net->
name()).assign(netName);
181 m_netSet.insert(lb, netName);
185 size_t XDLParserImp::findTile(
const char* tileName)
const
188 nameIndexMap_t::const_iterator it = m_tileMap.find(tileName);
189 if (m_tileMap.end() == it)
throw Exception();
195 size_t XDLParserImp::findWire(
const char* wireName,
const nameIndexMap_t& wireMap)
const
198 nameIndexMap_t::const_iterator it = wireMap.find(wireName);
199 if (wireMap.end() == it)
throw Exception();
205 size_t XDLParserImp::findPIP(
const PIP& pip,
const pipIndexMap_t& pipMap)
const
208 pipIndexMap_t::const_iterator it = pipMap.find(pip);
209 if (pipMap.end() == it)
throw Exception();
215 size_t XDLParserImp::findPrimitiveSite(
const char* siteName,
size_t tileIndex)
const
218 const Tile& tile = m_tiles->at(tileIndex);
221 size_t count = sites.size();
222 for (
size_t i = 0; i < count; ++i)
223 if (0 == ((sites[i]).name()).compare(siteName))
230 size_t XDLParserImp::findPrimitiveType(
const char* typeName)
const
233 nameIndexMap_t::const_iterator it = m_primitiveTypesMap.find(typeName);
234 if (m_primitiveTypesMap.end() == it)
throw Exception();
240 size_t XDLParserImp::findInstance(
const char* instanceName)
const
243 nameIndexMap_t::const_iterator it = m_instanceMap.find(instanceName);
244 if (m_instanceMap.end() == it)
throw Exception();
250 size_t XDLParserImp::findPin(
const char* pinName,
size_t instanceIndex)
const
253 const Instance& instance = m_instances->at(instanceIndex);
257 nameIndexMap_t::const_iterator it = pinMap.find(pinName);
258 if (pinMap.end() == it)
throw Exception();