23 #include <boost/filesystem/convenience.hpp>
24 #include <boost/algorithm/string.hpp>
29 namespace architecture {
40 using boost::uint32_t;
45 uint32_t familyDatabaseBytesRead = 0;
46 uint32_t deviceDatabaseBytesRead = 0;
50 string deviceFilename = inDeviceName +
".db";
51 boost::to_lower(deviceFilename);
53 mLog() <<
"Reading device " << inDeviceName <<
" (" <<
mDevicePath <<
")..." << endl;
55 deviceDatabaseStream.exceptions(fstream::eofbit | fstream::failbit | fstream::badbit);
63 familyDatabaseStream.exceptions(fstream::eofbit | fstream::failbit | fstream::badbit);
73 bool extendedAnchorTileCount
75 deviceDatabaseBytesRead
81 mOut() <<
"Read " << familyDatabaseBytesRead <<
" bytes from " <<
mFamilyName << endl;
82 mOut() <<
"Read " << deviceDatabaseBytesRead <<
" bytes from " <<
mDeviceName << endl;
91 catch(fstream::failure f) {
92 mErr() <<
"An unprocessed ifstream::failure exception was thrown: " << f.what() << endl;
101 char scratch[1 << 10];
102 boost::uint16_t nameLength = 0;
108 if(sectionName !=
">>>> Family >>>>")
throw -1;
111 inStream.
read(nameLength);
112 if(nameLength >
sizeof(scratch))
throw -1;
113 inStream.
read(scratch, nameLength);
114 scratch[nameLength] = 0;
124 char scratch[1 << 10];
125 uint16_t nameLength = 0;
131 if(sectionName !=
">>>> Speeds >>>>")
throw -1;
134 uint16_t speedGradeCount;
135 inStream.
read(speedGradeCount);
136 mOut() <<
"\tReading " << speedGradeCount <<
" speed grade"
137 << (speedGradeCount != 1 ?
"s" :
"") <<
" (";
139 for(uint16_t i = 0; i < speedGradeCount; i++) {
141 inStream.
read(nameLength);
142 if(nameLength >
sizeof(scratch))
throw -1;
143 inStream.
read(scratch, nameLength);
144 scratch[nameLength] = 0;
146 mOut() << scratch << (i + 1 < speedGradeCount ?
", " :
"");
148 mOut() <<
") ... " << std::endl;
163 if(!compactSegmentReference.
isDefined())
return;
167 if(compactSegmentReference.
isTrivial()) {
168 trivialSegmentReference.
setSize(1);
173 = compactSegmentReference.
isTrivial() ? trivialSegmentReference
179 = segmentReference.
begin();
181 = segmentReference.
end();
189 TileIndex csTileIndex = csTileOffset + anchorTileIndex;
191 outTilewires.push_back(
Tilewire(csTileIndex, csWireIndex));
215 bool inUseTied,
bool inUseRegular,
bool inUseIrregular,
bool inUseRoutethrough) {
227 while(sp < se) outSinks.push_back(
Tilewire(tileIndex, *sp++));
243 wireIndex, sinkWireIndex);
244 if(irregularArc != 0 && !segment.
isDefined()) {
245 mErr() <<
"WARNING: Irregular arc " << inTilewire <<
" >> "
246 <<
Tilewire(tileIndex, sinkWireIndex)
247 <<
" is defined, but the sink segment is undefined." << std::endl;
249 if(irregularArc == 0)
continue;
251 outSinks.push_back(
Tilewire(tileIndex, sinkWireIndex));
256 if(inUseRoutethrough) {
260 while(rsp < rse) outSinks.push_back(
Tilewire(tileIndex, *rsp++));
265 bool inUseTied,
bool inUseRegular,
bool inUseIrregular,
bool inUseRoutethrough) {
277 while(sp < se) outSources.push_back(
Tilewire(tileIndex, *sp++));
293 sourceWireIndex, wireIndex);
294 if(irregularArc != 0 && !segment.
isDefined()) {
295 mErr() <<
"WARNING: Irregular arc " << inTilewire <<
" >> "
296 <<
Tilewire(tileIndex, sourceWireIndex)
297 <<
" is defined, but the source segment is undefined." << std::endl;
299 if(irregularArc == 0)
continue;
301 outSources.push_back(
Tilewire(tileIndex, sourceWireIndex));
306 if(inUseRoutethrough) {
310 while(rsp < rse) outSources.push_back(
Tilewire(tileIndex, *rsp++));
316 bool inUseIrregular,
bool inUseRoutethrough) {
321 TilewireVector::const_iterator sep = segment.begin();
322 TilewireVector::const_iterator see = segment.end();
330 TilewireVector::const_iterator sip = sinks.begin();
331 TilewireVector::const_iterator sie = sinks.end();
332 while(sip < sie) outArcs.push_back(
Arc(tilewire, *sip++));
338 bool inUseIrregular,
bool inUseRoutethrough) {
343 TilewireVector::const_iterator sep = segment.begin();
344 TilewireVector::const_iterator see = segment.end();
352 TilewireVector::const_iterator sop = sources.begin();
353 TilewireVector::const_iterator soe = sources.end();
354 while(sop < soe) outArcs.push_back(
Arc(*sop++, tilewire));
Encapsulation of a wire belonging to a compact segment.
const WireIndex & getWireIndex(void) const
Returns the wire index.
Encapsulation of a tile index in an unsigned 32-bit integer.
static const boost::filesystem::path & getDevicesPath(void)
Returns the absolute path to the family and device database directory.
string mDeviceName
The name of the device.
CompactSegmentIndex getCompactSegmentIndex(void) const
EExpandDirection
Enumeration to indicate in which directions segments should be expanded.
const const xilinx::WireIndex * const_iterator
Constant T iterator type.
Encapsulation of an arc between two tilewires.
void autosize(void)
Size the wire usage according to the number of device tiles.
WireIndex getWireIndex(void) const
size_t readVersions(DigestStream &inStream, bool inShowVersion=false)
Read the version information.
std::istream & read(uint8_t &outValue)
Read and return a uint8_t.
std::vector< Tilewire > TilewireVector
Vector of Tilewire objects.
Tiles mTiles
The family and device tile data.
xilinx::TileOffset TileOffset
Imported type name.
void activatePackage(const string &inName)
Activate the specified device package.
TileOffset getTileOffset(void) const
Header for the DirectoryTree class.
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
T * end(void)
Returns the non-constant end iterator.
boost::filesystem::path mDevicePath
the device database path.
const WireArray & getIrregularSinks(void) const
Returns the irregular sink array for this wire.
size_t readTileWireInfo(DigestStream &inStream)
Read the family wire info.
ostream & mErr(void)
Returns the database console error stream.
const Array< const WireInfo > & getWireInfo(TileTypeIndex inTileTypeIndex) const
Returns the WireInfo array for the specified tile type.
const WireArray & getSources(void) const
Returns the source array for this wire.
size_t readTileTypes(DigestStream &inStream)
Read the family tile types.
void expandSegmentSinks(const Tilewire &inTilewire, ArcVector &outSinks, EExpandDirection inExpandDirection=eExpandDirectionNone, bool inUseTied=true, bool inUseRegular=true, bool inUseIrregular=true, bool inUseRoutethrough=true)
Expands all sink arcs for the given tilewire's segment.
size_t readIrregularArcs(DigestStream &inStream)
Read the irregular arcs for the device.
Encapsulation of an irregular arc.
Encapsulation of a wire index in an unsigned 16-bit integer.
std::vector< Arc > ArcVector
Vector of Arc objects.
Encapsulation of a tile offset in an unsigned 32-bit integer.
const WireArray & getRoutethroughSources(void) const
Returns the routethrough source array for this wire.
void expandTilewireSinks(const Tilewire &inTilewire, TilewireVector &outSinks, bool inUseTied=true, bool inUseRegular=true, bool inUseIrregular=true, bool inUseRoutethrough=true)
Expands the given tilewire's arc sinks.
const WireArray & getTiedSources(void) const
Returns the tied source array for this wire.
Header for torc::physical output stream helpers.
const WireArray & getIrregularSources(void) const
Returns the irregular source array for this wire.
size_t readFamilyName(class DigestStream &inStream)
Reads the family name from a device DigestStream.
TileIndex getAnchorTileIndex(void) const
string mFamilyName
The name of the family.
Encapsulation of a device tile and wire pair.
size_t readPrimitivePinMaps(DigestStream &inStream)
Read the site pin mappings for the family.
Array2D< CompactSegmentTilewire > mCompactSegments
The compact segments in the device.
const WireArray & getSinks(void) const
Returns the sink array for this wire.
void expandTilewireSources(const Tilewire &inTilewire, TilewireVector &outSources, bool inUseTied=true, bool inUseRegular=true, bool inUseIrregular=true, bool inUseRoutethrough=true)
Expands the given tilewire's arc sources.
void expandSegmentSources(const Tilewire &inTilewire, ArcVector &outSources, EExpandDirection inExpandDirection=eExpandDirectionNone, bool inUseTied=true, bool inUseRegular=true, bool inUseIrregular=true, bool inUseRoutethrough=true)
Expands all source arcs for the given tilewire's segment.
Encapsulation of a tile within a device tile map.
const TileTypeIndex & getTypeIndex(void) const
Returns the tile type index for this tile.
ArcUsage mArcUsage
The design arc usage.
const WireArray & getRoutethroughSinks(void) const
Returns the routethrough sink array for this wire.
void readSectionHeader(string &outHeader)
Read and return a section header.
ostream & mOut(void)
Returns the database console output stream.
ostream & mLog(void)
Returns the database console log stream.
Encapsulation of dotted decimal DottedVersion numbers.
bool isDefined(void) const
const Segments::IrregularArc * getIrregularArc(TileIndex inTileIndex, WireIndex inSourceWireIndex, WireIndex inSinkWireIndex)
Return a pointer to the requested IrregularArc, or 0 if the arc does not exist.
boost::filesystem::path mFamilyPath
the family database path.
Encapsulation of compact segment index and an anchoring tile index.
Segments mSegments
The device segment data.
Header for the DigestStream class.
const Segments::SegmentReference & getTilewireSegment(const Tilewire &inTilewire) const
Return the segment reference for the given tile and wire index.
T * begin(void)
Returns the non-constant begin iterator.
const WireArray & getTiedSinks(void) const
Returns the tied sink array for this wire.
Header for the DDB class.
size_t readPackages(DigestStream &inStream)
Read the packages for the device.
const TileIndex & getTileIndex(void) const
Returns the tile index.
void setSize(uint32_t inSize)
Discards all contents and resizes the array.
StringVector mSpeedGrades
The supported speed grades.
Encapsulation of a wire within a tile type.
Sites mSites
The family and device site data.
void initialize(const string &inDeviceName, const string &inPackageName)
Initializes the database.
Encapsulation of a device or family digest stream.
size_t readTileMap(DigestStream &inStream)
Read the device tile map.
size_t readTilewireSegments(DigestStream &inStream)
Read the segment entries for every tile.
size_t getBytesRead(void) const
Returns the number of bytes read.
size_t readPrimitiveTypes(DigestStream &inStream)
Read the primitive types for the family.
WireUsage mWireUsage
The design wire usage.
bool isTrivial(void) const
void autosize(void)
Size the wire usage according to the number of device tiles.
size_t readSpeedGrades(class DigestStream &inStream)
Reads the supported speed grades from a device DigestStream.
size_t readSegments(DigestStream &inStream, bool inExtendedAnchorTileCount)
Read the compact segments for the device.
Versions mFamilyVersion
The family database version.
Encapsulation of a static array.
void expandSegment(const Tilewire &inTilewire, TilewireVector &outTilewires, EExpandDirection inExpandDirection=eExpandDirectionNone)
Expands the given tilewire's segment.
const DottedVersion & getFormat(void) const
Returns the database format version.
size_t readSites(DigestStream &inStream)
Read the sites for the device.
Versions mDeviceVersion
The device database version.