torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Sites.hpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Header for the Sites class.
18 
19 #ifndef TORC_ARCHITECTURE_SITES_HPP
20 #define TORC_ARCHITECTURE_SITES_HPP
21 
34 #include <boost/cstdint.hpp>
35 #include <map>
36 #include <set>
37 
38 namespace torc {
39 namespace architecture {
40 
41  /// \brief Site type and population data for the family and the device.
42  /// \details Each device has a collection of logic sites. Those sites are instantiations of
43  /// family defined site types, with each instance also including a mapping from site pin
44  /// to Tilewire.
46  // friends
47  /// \brief The database has access to our protected functions.
48  friend class DDB;
49  protected:
50  // types
51  typedef std::string string; ///< \brief Imported type name.
52  typedef xilinx::TileIndex TileIndex; ///< \brief Imported type name.
53  typedef xilinx::WireIndex WireIndex; ///< \brief Imported type name.
54  typedef xilinx::PinFlags PinFlags; ///< \brief Imported type name.
55  typedef xilinx::PinCount PinCount; ///< \brief Imported type name.
56  typedef xilinx::SiteCount SiteCount; ///< \brief Imported type name.
57  typedef xilinx::SiteIndex SiteIndex; ///< \brief Imported type name.
58  typedef xilinx::SiteFlags SiteFlags; ///< \brief Imported type name.
59  typedef xilinx::SiteTypeCount SiteTypeCount; ///< \brief Imported type name.
60  typedef xilinx::SiteTypeIndex SiteTypeIndex; ///< \brief Imported type name.
61  typedef xilinx::PackageCount PackageCount; ///< \brief Imported type name.
62  typedef xilinx::PackageIndex PackageIndex; ///< \brief Imported type name.
63  typedef xilinx::PadCount PadCount; ///< \brief Imported type name.
64  typedef xilinx::PadIndex PadIndex; ///< \brief Imported type name.
65  /// \brief Map from site name to site index.
66  typedef std::map<string, SiteIndex> SiteNameToSiteIndexMap;
67  /// \brief Map from package name to package index.
68  typedef std::map<string, PackageIndex> PackageNameToPackageIndexMap;
69  // members
70  /// \brief The site types for this family.
72  /// \brief The site pin maps for this family.
74  /// \brief The logic sites for this device.
76  /// \brief The mapping from site name to site index for this device.
78  /// \brief The packages for this device
80  /// \brief The mapping from package name to package index for this device.
82  // functions
83  /// \brief Read the primitive types for the family.
84  size_t readPrimitiveTypes(DigestStream& inStream);
85  /// \brief Read the site pin mappings for the family.
86  size_t readPrimitivePinMaps(DigestStream& inStream);
87  /// \brief Read the sites for the device.
88  size_t readSites(DigestStream& inStream);
89  /// \brief Read the packages for the device.
90  size_t readPackages(DigestStream& inStream);
91  /// \brief Activate the specified device package.
92  void activatePackage(const string& inName) {
94  }
95  /// \brief Activate the specified device package.
96  void activatePackage(PackageIndex inPackageIndex) {
97  // look up the package
98  if(inPackageIndex >= mPackages.getSize()) return;
99  const Package& package = mPackages[inPackageIndex];
100  // iterate through the pads
101  const Array<const Pad>& pads = package.getPads();
104  while(p < e) {
105  // update the site name and flags
106  Site& site = const_cast<Site&>(mSites[p->mSiteIndex]);
107  site.mName = p->mName;
108  site.mFlags = p->mFlags;
109  p++;
110  }
111  // update the name to index map
112  mSiteNameToSiteIndex.clear();
113  for(SiteIndex i; i < getSiteCount(); i++) {
114  Site& site = const_cast<Site&>(mSites[i]);
115  mSiteNameToSiteIndex[site.mName] = i;
116  }
117  }
118  public:
119  // accessors
120  /// \brief Returns the site count for this device.
121  SiteCount getSiteCount(void) const { return SiteCount(mSites.getSize()); }
122  /// \brief Returns the site type count for this family.
123  SiteTypeCount getSiteTypeCount(void) const { return SiteTypeCount(mSiteTypes.getSize()); }
124  /// \brief Returns the site types for this family.
125  const Array<const PrimitiveDef>& getSiteTypes(void) const { return mSiteTypes; }
126  /// \brief Returns the sites for this family.
127  const Array<const Site>& getSites(void) const { return mSites; }
128  /// \brief Returns the site for the specified index.
129  const Site& getSite(SiteIndex inSiteIndex) const { return mSites[inSiteIndex]; }
130  /// \brief Returns the packages for this family.
131  const Array<const Package>& getPackages(void) const { return mPackages; }
132  // functions
133  /// \brief Returns the site index for the given site name.
134  SiteIndex findSiteIndex(const string& inName) const {
135  SiteNameToSiteIndexMap::const_iterator p = mSiteNameToSiteIndex.find(inName);
136  return (p == mSiteNameToSiteIndex.end())
137  ? SiteIndex(SiteIndex::undefined()) : p->second;
138  }
139  /// \brief Returns the package index for the given package name.
140  PackageIndex findPackageIndex(const string& inName) const {
141  PackageNameToPackageIndexMap::const_iterator p
142  = mPackageNameToPackageIndex.find(inName);
143  return (p == mPackageNameToPackageIndex.end())
144  ? PackageIndex(PackageIndex::undefined()) : p->second;
145  }
146  };
147 
148 } // namespace architecture
149 } // namespace torc
150 
151 #endif // TORC_ARCHITECTURE_SITES_HPP
std::map< string, SiteIndex > SiteNameToSiteIndexMap
Map from site name to site index.
Definition: Sites.hpp:66
xilinx::SiteTypeCount SiteTypeCount
Imported type name.
Definition: Sites.hpp:59
Encapsulation of a physical device package and its pins.
Definition: Package.hpp:33
SiteCount getSiteCount(void) const
Returns the site count for this device.
Definition: Sites.hpp:121
Encapsulation of a tile index in an unsigned 32-bit integer.
xilinx::PackageCount PackageCount
Imported type name.
Definition: Sites.hpp:61
SiteNameToSiteIndexMap mSiteNameToSiteIndex
The mapping from site name to site index for this device.
Definition: Sites.hpp:77
Encapsulation of a pad count in an unsigned 32-bit integer.
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
SiteFlags mFlags
The flags associated with this site.
Definition: Site.hpp:54
Encapsulation of a pin count in an unsigned 32-bit integer.
void activatePackage(const string &inName)
Activate the specified device package.
Definition: Sites.hpp:92
std::map< string, PackageIndex > PackageNameToPackageIndexMap
Map from package name to package index.
Definition: Sites.hpp:68
Header for the PrimitiveElement class.
T * end(void)
Returns the non-constant end iterator.
Definition: Array.hpp:97
std::string string
Imported type name.
Definition: Sites.hpp:51
Encapsulation of a site count in an unsigned 32-bit integer.
xilinx::PackageIndex PackageIndex
Imported type name.
Definition: Sites.hpp:62
Array< const PrimitiveDef > mSiteTypes
The site types for this family.
Definition: Sites.hpp:71
Device database console streams class.
xilinx::TileIndex TileIndex
Imported type name.
Definition: Sites.hpp:52
xilinx::SiteCount SiteCount
Imported type name.
Definition: Sites.hpp:56
Encapsulation of a wire index in an unsigned 16-bit integer.
Array< const Package > mPackages
The packages for this device.
Definition: Sites.hpp:79
xilinx::PadIndex PadIndex
Imported type name.
Definition: Sites.hpp:64
void activatePackage(PackageIndex inPackageIndex)
Activate the specified device package.
Definition: Sites.hpp:96
std::string string
Encapsulation of a package count in an unsigned 16-bit integer.
Encapsulation of a site type index in an unsigned 16-bit integer.
xilinx::SiteTypeIndex SiteTypeIndex
Imported type name.
Definition: Sites.hpp:60
const Array< const PrimitiveDef > & getSiteTypes(void) const
Returns the site types for this family.
Definition: Sites.hpp:125
Header for the Site class.
Array< const Site > mSites
The logic sites for this device.
Definition: Sites.hpp:75
Encapsulation of a device logic site.
Definition: Site.hpp:30
Header for the DDBConsoleStreams class.
Site type and population data for the family and the device.
Definition: Sites.hpp:45
xilinx::SiteFlags SiteFlags
Imported type name.
Definition: Sites.hpp:58
Header for the PrimitiveConn class.
const Array< const Site > & getSites(void) const
Returns the sites for this family.
Definition: Sites.hpp:127
size_t readPrimitivePinMaps(DigestStream &inStream)
Read the site pin mappings for the family.
Definition: Sites.cpp:267
xilinx::PadCount PadCount
Imported type name.
Definition: Sites.hpp:63
PackageNameToPackageIndexMap mPackageNameToPackageIndex
The mapping from package name to package index for this device.
Definition: Sites.hpp:81
Header for the PrimitivePin class.
Encapsulation of a 2D static array.
Definition: Array.hpp:125
Header for the PrimitiveDef class.
SiteIndex findSiteIndex(const string &inName) const
Returns the site index for the given site name.
Definition: Sites.hpp:134
Encapsulation of a package index in an unsigned 16-bit integer.
Encapsulation of pin attribute flags in an unsigned 16-bit integer.
SiteTypeCount getSiteTypeCount(void) const
Returns the site type count for this family.
Definition: Sites.hpp:123
Encapsulation of a site type count in an unsigned 16-bit integer.
xilinx::PinCount PinCount
Imported type name.
Definition: Sites.hpp:55
const Site & getSite(SiteIndex inSiteIndex) const
Returns the site for the specified index.
Definition: Sites.hpp:129
xilinx::SiteIndex SiteIndex
Imported type name.
Definition: Sites.hpp:57
Header for the Tilewire class.
Encapsulation of site attribute flags in an unsigned 16-bit integer.
PackageIndex findPackageIndex(const string &inName) const
Returns the package index for the given package name.
Definition: Sites.hpp:140
Header for the Array class.
Header for the DigestStream class.
Encapsulation of a site index in an unsigned 32-bit integer.
Array2D< const WireIndex > mPrimitivePinMaps
The site pin maps for this family.
Definition: Sites.hpp:73
T * begin(void)
Returns the non-constant begin iterator.
Definition: Array.hpp:95
size_t readPackages(DigestStream &inStream)
Read the packages for the device.
Definition: Sites.cpp:25
const Array< const Package > & getPackages(void) const
Returns the packages for this family.
Definition: Sites.hpp:131
xilinx::WireIndex WireIndex
Imported type name.
Definition: Sites.hpp:53
Header for the Package class.
Encapsulation of a device or family digest stream.
size_t readPrimitiveTypes(DigestStream &inStream)
Read the primitive types for the family.
Definition: Sites.cpp:90
Encapsulation of a pad index in an unsigned 32-bit integer.
Header for the PrimitiveElementPin class.
string mName
The logic site name.
Definition: Site.hpp:48
Encapsulation of a static array.
Definition: Array.hpp:39
size_t readSites(DigestStream &inStream)
Read the sites for the device.
Definition: Sites.cpp:305
xilinx::PinFlags PinFlags
Imported type name.
Definition: Sites.hpp:54
Device database types for Xilinx architectures.