19 #ifndef TORC_UTILS_ARCHITECTUREBROWSER_HPP
20 #define TORC_UTILS_ARCHITECTUREBROWSER_HPP
29 #include <boost/regex.hpp>
30 #include <boost/lexical_cast.hpp>
31 #include <boost/algorithm/string/case_conv.hpp>
141 cout <<
"Bye!" << endl << endl;
145 cout <<
"Device Summary." << endl;
150 functionPrompt(
"Enter regexp filter (\".*\" to match all tiles), q to quit",
151 getFilteredTileListRef);
154 functionPrompt(
"Enter tile type index, tile type name or tile name, q to quit",
155 getWireListForTileTypeRef);
158 functionPrompt(
"Enter wire@tile, q to quit", getTilewireDetailRef);
161 functionPrompt(
"Enter wire@tile, q to quit", displayFullSegmentRef);
164 functionPrompt(
"Enter wire@tile, q to quit", displaySegmentSourcesRef);
167 functionPrompt(
"Enter wire@tile, q to quit", displaySegmentSinksRef);
171 functionPrompt(
"Enter regexp filter (\".*\" to match all sites), q to quit",
172 getFilteredSiteListRef);
175 functionPrompt(
"Enter site name or index, q to quit", getSiteDetailRef);
178 cout <<
"List site types: " << endl;
182 functionPrompt(
"Enter site type name, q to quit", displaySitesOfTypeRef);
188 cout <<
"Bit - Nothing here yet." << endl;
191 cout <<
"Clear - Nothing here yet." << endl;
194 cout <<
"Enter tile index: ";
199 cout <<
"Enter wire@tile: " << endl;
204 cout <<
"Enter tile type: ";
209 cout <<
"Route - Not yet supported" << endl;
214 cout <<
"Available tile types:" << endl;
218 cout <<
"Equations - Nothing here yet." << endl;
221 cout <<
"Enter wire@tile: ";
226 cout <<
"Displaying tilemap:" << endl;
230 cout <<
"Enter site: ";
235 cout <<
"Invalid Function: " <<
function << endl;
246 cout << endl << inPrompt <<
"> ";
252 (this->*f)(userinput);
263 cout <<
"Speed grades:";
280 std::ios_base::fmtflags saveflags = cout.flags();
284 cout << std::setw(6) << i <<
" type " << std::setw(3) << ti.
getTypeIndex() <<
" "
285 <<
"(" << std::setw(3) << ti.
getRow() <<
"," << std::setw(3) << ti.
getCol()
286 <<
") " << ti.
getName() << endl;
288 cout.flags(saveflags);
294 std::ios_base::fmtflags saveflags = cout.flags();
297 std::string userPattern = regex_replace(inString, boost::regex(
"(?<!\\.)\\*"),
".*");
300 boost::regex sTileNameRegEx(userPattern, boost::regex::perl | boost::regex::icase
301 | boost::regex::no_except);
303 if (sTileNameRegEx.empty()) {
304 cout <<
"Bad regular expression. Try again." << endl;
309 boost::smatch smatches;
315 cout << std::setw(6) << i <<
" type " << std::setw(3) << ti.
getTypeIndex() <<
" "
316 <<
"(" << std::setw(3) << ti.
getRow() <<
"," << std::setw(3) << ti.
getCol()
317 <<
") " << ti.
getName() << endl;
322 cout << endl << matchCount <<
" match" << (matchCount == 1 ?
"." :
"es.") << endl;
324 cout.flags(saveflags);
330 std::ios_base::fmtflags saveflags = cout.flags();
334 cout << std::setw(7) << i <<
" " << site.
getName() << endl;
336 cout.flags(saveflags);
342 std::ios_base::fmtflags saveflags = cout.flags();
345 std::string userPattern = regex_replace(inString, boost::regex(
"(?<!\\.)\\*"),
".*");
348 boost::regex sSiteNameRegEx(userPattern, boost::regex::perl | boost::regex::icase
349 | boost::regex::no_except);
351 if (sSiteNameRegEx.empty()) {
352 cout <<
"Bad regular expression. Try again." << endl;
357 boost::smatch smatches;
361 if (regex_match(site.
getName(), smatches, sSiteNameRegEx)) {
363 cout << std::setw(7) << i <<
" " << site.
getName() << endl;
368 cout << endl << matchCount <<
" match" << (matchCount == 1 ?
"." :
"es.") << endl;
370 cout.flags(saveflags);
376 std::ios_base::fmtflags saveflags = cout.flags();
379 boost::smatch smatches;
381 siteIndex = boost::lexical_cast<
SiteIndex>(smatches[1]);
383 cout <<
"Site index " << siteIndex <<
" out of range! "
390 cout <<
"Site not found: " << inString << endl;
394 cout <<
"Input invalid: " << inString << endl;
398 cout <<
"Site: " << site.
getName() << endl;
401 cout <<
"\tFlags: " << std::hex << site.
getFlags() << endl;
402 cout << std::dec <<
"\tPinMapPtr" << endl <<
"\t\t";
403 for (
unsigned int i = 0; i < (site.
getPinMapPtr())->getSize(); i++) {
408 cout <<
"\tPrimitive Definition: " << primDef.
getName() << endl;
409 cout.flags(saveflags);
416 std::ios_base::fmtflags saveflags = cout.flags();
421 if (siteTypePtr->
getName() == inString)
422 cout << std::setw(7) << i <<
" " << site.
getName() << endl;
425 cout.flags(saveflags);
433 cout <<
"Specified tilewire not found: " << inString << endl;
440 cout <<
"\toffset: " << wireinfo.
getArcOffset() << endl;
441 cout <<
"\tattributes: ";
442 cout << (wireinfo.
isHidden() ?
"HIDDEN " :
"");
443 cout << (wireinfo.
isInput() ?
"INPUT " :
"");
444 cout << (wireinfo.
isOutput() ?
"OUTPUT " :
"");
445 cout << (wireinfo.
isRemote() ?
"REMOTE " :
"");
446 cout << (wireinfo.
isGlobal() ?
"GLOBAL " :
"");
451 for (uint32_t i = 0; i < sinks.getSize(); i++) cout << sinks[i] <<
" "; cout << endl;
454 cout <<
"\tsources: ";
455 for (uint32_t i = 0; i < sources.
getSize(); i++) cout << sources[i] <<
" "; cout << endl;
458 cout <<
"\tirregular sinks: ";
459 for (uint32_t i = 0; i < isinks.
getSize(); i++) cout << isinks[i] <<
" "; cout << endl;
462 cout <<
"\tirregular sources: ";
463 for (uint32_t i = 0; i < isources.
getSize(); i++) cout << isources[i] <<
" "; cout << endl;
466 cout <<
"\ttied sinks: ";
467 for (uint32_t i = 0; i < tsinks.
getSize(); i++) cout << tsinks[i] <<
" "; cout << endl;
470 cout <<
"\ttied sources: ";
471 for (uint32_t i = 0; i < tsources.
getSize(); i++) cout << tsources[i] <<
" "; cout << endl;
478 for (uint32_t i = 0; i < segmentwires.size(); i++) cout << segmentwires[i] <<
" ";
488 cout << inString <<
" is not a valid Tilewire" << endl;
493 cout <<
"Sources for segment containing: " << inString << endl;
495 for (uint32_t i = 0; i < segmentWires.size(); i++) {
497 cout <<
"|\t" << ewi << endl;
500 for (uint32_t j = 0; j < sourceWires.size(); j++) {
502 cout <<
"|<--\t\t" << ewi2 << endl;
506 for (uint32_t j = 0; j < sourceWires.size(); j++) {
508 cout <<
"|<--\t\t" << ewi2 <<
" - IRREGULAR" << endl;
512 for (uint32_t j = 0; j < sourceWires.size(); j++) {
514 cout <<
"|<--\t\t" << ewi2 <<
" - ROUTETHROUGH" << endl;
525 cout << inString <<
" is not a valid Tilewire" << endl;
530 cout <<
"Sinks for segment containing: " << inString << endl;
532 for (uint32_t i = 0; i < segmentWires.size(); i++) {
534 cout <<
"|\t" << ewi << endl;
537 for (uint32_t j = 0; j < sinkWires.size(); j++) {
539 cout <<
"|-->\t\t" << ewi2 << endl;
543 for (uint32_t j = 0; j < sinkWires.size(); j++) {
545 cout <<
"|-->\t\t" << ewi2 <<
" - IRREGULAR" << endl;
549 for (uint32_t j = 0; j < sinkWires.size(); j++) {
551 cout <<
"|-->\t\t" << ewi2 <<
" - ROUTETHROUGH" << endl;
560 std::map<string, std::vector<string> > sourcemap;
561 std::map<string, std::vector<string> > sinkmap;
562 std::vector<string> segmentstrings;
566 cout << inString <<
" is not a valid Tilewire" << std::endl;
572 for (uint32_t i = 0; i < segmentwires.size(); i++) {
574 std::stringstream segwire;
576 string segwirestring = segwire.str();
577 segmentstrings.push_back(segwirestring);
579 sinkmap[segwirestring] = std::vector<string>();
580 sourcemap[segwirestring] = std::vector<string>();
584 for (uint32_t j = 0; j < arcwires.size(); j++) {
586 std::stringstream arcwire;
589 sinkmap[segwirestring].push_back(arcwire.str());
593 for (uint32_t j = 0; j < arcwires.size(); j++) {
595 std::stringstream arcwire;
598 sourcemap[segwirestring].push_back(arcwire.str());
601 cout <<
"Displaying segment containing: " << inString << endl;
612 for (uint32_t i = 0; i < segmentstrings.size(); i++) {
613 cout <<
"|" << endl <<
"| " << segmentstrings[i] << endl;
615 for (uint32_t j = 0; j < sourcemap[segmentstrings[i]].size(); j++) {
616 cout <<
"| <--- " << sourcemap[segmentstrings[i]][j] << endl;
618 for (uint32_t j = 0; j < sinkmap[segmentstrings[i]].size(); j++) {
619 cout <<
"| ---> " << sinkmap[segmentstrings[i]][j] << endl;
629 std::map<string, std::vector<string> > sourcemap;
630 std::map<string, std::vector<string> > sinkmap;
631 std::vector<string> segmentstrings;
637 for (uint32_t i = 0; i < segmentwires.size(); i++) {
639 std::stringstream segwire;
642 string segwirestring = segwire.str();
643 segmentstrings.push_back(segwirestring);
645 sinkmap[segwirestring] = std::vector<string>();
646 sourcemap[segwirestring] = std::vector<string>();
650 for (uint32_t j = 0; j < arcwires.size(); j++) {
652 std::stringstream arcwire;
656 sinkmap[segwirestring].push_back(arcwire.str());
660 for (uint32_t j = 0; j < arcwires.size(); j++) {
662 std::stringstream arcwire;
666 sourcemap[segwirestring].push_back(arcwire.str());
670 uint32_t sourcewidth = 0;
671 uint32_t segwidth = 0;
672 uint32_t sinkwidth = 0;
674 std::map<string, std::vector<string> >::iterator e;
675 std::map<string, std::vector<string> >::iterator p;
678 for (p = sourcemap.begin(); p != e; p++) {
680 for (uint32_t j = 0; j < p->second.size(); j++) {
681 if (p->second[j].size() > sourcewidth) sourcewidth = p->second[j].size();
685 for (p = sinkmap.begin(); p != e; p++) {
687 for (uint32_t j = 0; j < p->second.size(); j++) {
688 if (p->second[j].size() > sinkwidth) sinkwidth = p->second[j].size();
691 for (uint32_t i = 0; i < segmentstrings.size(); i++) {
692 if (segmentstrings[i].size() > segwidth) segwidth = segmentstrings[i].size();
698 for (uint32_t i = 0; i < segmentstrings.size(); i++) {
699 std::map<string, std::vector<string> >::iterator p;
700 p = sourcemap.find(segmentstrings[i]);
701 if (p != sourcemap.end() && p->second.size() > 0) {
702 for (uint32_t j = 0; j < p->second.size() - 1; j++) {
703 cout <<
" " << p->second[j];
704 for (uint32_t k = p->second[j].size(); k < sourcewidth; k++) cout <<
" ";
707 cout <<
" " << p->second[p->second.size() - 1];
708 for (uint32_t k = p->second[p->second.size() - 1].size();
709 k < sourcewidth; k++) cout <<
" ";
712 for (uint32_t k = 0; k < sourcewidth + 3; k++) cout <<
" ";
715 cout << segmentstrings[i];
716 for (uint32_t k = segmentstrings[i].size(); k < segwidth; k++) cout <<
" ";
717 p = sinkmap.find(segmentstrings[i]);
718 if (p != sinkmap.end()) {
719 if (p->second.size() > 0) cout <<
" + " << p->second[0] << endl;
721 for (uint32_t j = 1; j < p->second.size(); j++) {
722 for (uint32_t k = 0; k < sourcewidth + segwidth + 4; k++) cout <<
" ";
723 cout <<
"| " << p->second[j] << endl;
739 boost::smatch smatches;
743 cout <<
"Type index " << tileType <<
" out of range! "
750 tileTypeName = smatches[1];
757 tileName = tileTypeName;
760 if (tileTypeName == tileInfo.
getName()) {
768 cout << inString <<
" not found." << endl;
772 cout <<
"Input invalid: " << inString << endl;
779 cout <<
"Wires for tile type: " << tileTypeName <<
" (" << tileType <<
")" << endl;
780 for (uint32_t i = 0; i < wireInfoArray.
getSize(); i++) {
781 const WireInfo& wireInfo = wireInfoArray[i];
782 cout <<
"\t" << i <<
": " << wireInfo.
getName();
783 cout << (wireInfo.
isHidden() ?
" (HIDDEN) " :
"");
784 cout << (wireInfo.
isInput() ?
" (INPUT) " :
"");
785 cout << (wireInfo.
isOutput() ?
" (OUTPUT) " :
"");
786 cout << (wireInfo.
isRemote() ?
" (REMOTE) " :
"");
787 cout << (wireInfo.
isGlobal() ?
" (GLOBAL) " :
"");
796 cout <<
"Device Site Types:" << endl;
799 for (uint32_t i = 0; i < siteTypes.
getSize(); i++) {
800 cout << siteTypes[i].getName() << endl;
809 boost::smatch smatches;
810 boost::smatch smatches2;
813 string tilePart = smatches[2];
814 boost::to_upper(tilePart);
816 tile = boost::lexical_cast<
TileIndex>(smatches2[1]);
824 string wirePart = smatches[1];
825 boost::to_upper(wirePart);
827 wire = boost::lexical_cast<
WireIndex>(smatches2[1]);
849 #endif // TORC_UTILS_ARCHITECTUREBROWSER_HPP
const Sites & mSites
Site data reference from the database.
const WireIndex & getWireIndex(void) const
Returns the wire index.
architecture::xilinx::TileCount TileCount
Imported type name.
SiteCount getSiteCount(void) const
Returns the site count for this device.
Encapsulation of a tile index in an unsigned 32-bit integer.
const TileCol & getCol(void) const
Returns the column for this tile.
void displayFullSegmentFANCY(const string &inString)
Display segment connectivity.
bool isOutput(void) const
Returns true if the wire is a logic output.
architecture::xilinx::SiteIndex SiteIndex
Imported type name.
std::vector< Tilewire > TilewireVector
Vector of Tilewire objects.
const TileRow & getRow(void) const
Returns the row for this tile.
Utility class for exploring database contents.
architecture::xilinx::TileIndex TileIndex
Imported type name.
const string & getDeviceName(void) const
Returns the device name.
architecture::Tilewire Tilewire
Imported type name.
const PrimitiveDef * getPrimitiveDefPtr(void) const
Returns a pointer to the associated primitive definition.
Device database, including complete wiring and logic support.
TileTypeCount getTileTypeCount(void) const
Returns the tile type count for this device.
TileRow getRowCount(void) const
Returns the row count for this device.
bool isGlobal(void) const
Returns true if the wire is a global wire (a what!?).
const string & getFamilyName(void) const
Returns the family name.
void getFilteredSiteList(const string &inString)
Filtered list of all sites.
void getFilteredTileList(const string &inString)
Filtered list of all tiles.
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Encapsulation the design wire usage.
Encapsulation of primitive site definition, with associated connections, elements, and pins.
const uint16_t getArcOffset(void) const
Returns this wire's offset into the arc usage bitset.
bool isInput(void) const
Returns true if the wire is a logic input.
void getWireListForTileType(const string &inString)
List all wires for a given tile type.
static boost::regex sTilewireRegEx
Regular expression for Tilewire form.
const WireArray & getIrregularSinks(void) const
Returns the irregular sink array for this wire.
uint32_t getArcUsageCount(void) const
Returns the number of arcs in use.
Header for the DDBStreamHelper class.
ArchitectureBrowser(DDB &inDB)
Constructor.
architecture::Sites Sites
Imported type name.
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.
architecture::DDB DDB
Imported type name.
bool isHidden(void) const
Returns true if the wire is hidden in traces.
Encapsulation of a wire index in an unsigned 16-bit integer.
void displaySitesOfType(const string &inString)
brief Sites of a particular type function.
TileCount getTileCount(void) const
Returns the tile count for this device.
ArcUsage & mArcUsage
Pip usage information from the database.
void enumerateSiteTypes()
const StringVector & getSpeedGrades(void) const
Returns a constant reference to a vector of speed grades.
uint32_t getWireUsageCount(void) const
Returns the number of wires in use.
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.
architecture::WireInfo WireInfo
Imported type name.
void getTileList()
List all tiles.
architecture::PrimitiveDef PrimitiveDef
Imported type name.
const Array< const PrimitiveDef > & getSiteTypes(void) const
Returns the site types for this family.
const WireArray & getTiedSources(void) const
Returns the tied source array for this wire.
SiteFlags getFlags(void) const
Returns the flags associated with this site.
DDB & mDB
Database Reference.
Header for torc::physical output stream helpers.
Encapsulation of a device logic site.
const WireArray & getIrregularSources(void) const
Returns the irregular source array for this wire.
bool isRemoteArcCapable(void) const
Returns true if the wire may be referenced by a remote arc.
Site type and population data for the family and the device.
void browse()
Function to begin an interactive browsing session.
Encapsulation of a device tile and wire pair.
const string & getName(void) const
Returns the site name.
void displaySegmentSources(const string &inString)
Display source Tilewires of a segment.
architecture::Segments Segments
Imported type name.
Encapsulation the design arc usage.
Tile map, tile type, and wire information for the family and device.
~ArchitectureBrowser()
Destructor.
Encapsulation of a tile count in an unsigned 32-bit integer.
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.
Encapsulation of a tile within a device tile map.
const char * getTileTypeName(TileTypeIndex inTileTypeIndex) const
Returns the tile type name for the given tile type index.
Verbose encapsulation of a wire's information.
SiteIndex findSiteIndex(const string &inName) const
Returns the site index for the given site name.
architecture::ArcUsage ArcUsage
Imported type name.
TileIndex getTileIndex(void) const
Returns the index of the containing tile.
const TileTypeIndex & getTypeIndex(void) const
Returns the tile type index for this tile.
void displaySegmentSinks(const string &inString)
Display sink Tilewires of a segment.
void getSiteDetail(const string &inString)
brief Site detail function.
architecture::xilinx::TileTypeIndex TileTypeIndex
Imported type name.
const Site & getSite(SiteIndex inSiteIndex) const
Returns the site for the specified index.
EFunctionMap
Enumeration of menu selection options.
TileIndex findTileIndex(const string &inName) const
Returns the tile index for the given tile name.
void setupFunctionMap()
Prepare function map to lookup what the user asks for.
void getSiteList()
List of all sites.
void(ArchitectureBrowser::* BrowserFunction)(const std::string &x)
Type for member function pointers.
TileCol getColCount(void) const
Returns the column count for this device.
Encapsulation of a site index in an unsigned 32-bit integer.
architecture::WireUsage WireUsage
Imported type name.
WireIndex findWireIndex(TileTypeIndex inTileTypeIndex, const string &inName) const
Returns the wire index for the given wire name in the given tile type.
Tilewire stringToTilewire(const string &inString)
Convert user input to a Tilewire.
Encapsulation of a tile type index in an unsigned 16-bit integer.
void functionPrompt(const char *inPrompt, BrowserFunction f)
Secondary menu loop to remain in a particular function.
const char * getName(void) const
Returns the name for this tile.
const WireArray & getTiedSinks(void) const
Returns the tied sink array for this wire.
Header for the DDB class.
static boost::regex sNameRegEx
Regular expression for a name.
const TileIndex & getTileIndex(void) const
Returns the tile index.
Encapsulation of a wire within a tile type.
static const Tilewire sInvalid
static boost::regex sIndexRegEx
Regular expression for nonnegative integers.
std::string string
Imported type name.
void displayFullSegment(const string &inString)
Display segment connectivity.
Segment and irregular arc data for the device.
const Segments & mSegments
Segments reference from the database.
void printFullMenu()
Print the full menu of browser functions.
const char * getName(void) const
Returns the name for this wire.
architecture::TilewireVector TilewireVector
Imported type name.
WireUsage & mWireUsage
Wire usage information from the database.
std::map< string, EFunctionMap > mFunctionMap
Mapping from function to index.
const WireIndexArray * getPinMapPtr(void) const
Returns the pin to wire map for this site.
void deviceSummary()
A brief summary of device information.
bool isRemote(void) const
Returns true if the wire is a remote wire.
architecture::Tiles Tiles
Imported type name.
architecture::xilinx::WireIndex WireIndex
Imported type name.
bool isRemoteNodeCapable(void) const
Returns true if the wire may be referenced by a remote wire.
Encapsulation of a static array.
void expandSegment(const Tilewire &inTilewire, TilewireVector &outTilewires, EExpandDirection inExpandDirection=eExpandDirectionNone)
Expands the given tilewire's segment.
uint32_t getSize(void) const
Returns the array size.
void getTilewireDetail(const string &inString)
Tilewire detail function.
const Tiles & mTiles
Tile data reference from the database.
const string & getName(void) const
Returns the name of the primitive.