torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WireXdlGenerator.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2012-2013 University of Southern California. All Rights Reserved.
2 /// \file
3 /// \brief Open a device, go over all the pips of some tile types
4 // and create an XDL file for each pip
5 
6 #include <iostream>
7 #include <fstream>
8 #include <sstream>
9 #include "torc/Architecture.hpp"
10 #include "torc/Physical.hpp"
11 #include "torc/Common.hpp"
12 #include "SharedFunctions.hpp"
13 
14 using namespace torc::common;
15 using namespace torc::architecture;
16 using namespace torc::architecture::xilinx;
17 using namespace torc::physical;
18 
19 const std::string dummyInstName = "dummyInst";
20 const std::string dummyInstSiteType = "SLICEL";
21 const std::string dummyInstSiteLcoation = "SLICE_X1Y1";
22 
24 
25 static const std::string kSupportedTiles[] = { "INT",
26  "CLBLM",
27  "CFG_HCLK_INTERFACE",
28  "CLKV",
29  "CLKV_MC",
30  "CLK_BUFGMUX",
31  "CLK_CMT_BOT",
32  "CLK_CMT_BOT_MGT",
33  "CLK_CMT_TOP",
34  "CLK_CMT_TOP_MGT",
35  "CLK_HROW",
36  "CLK_HROW_MGT",
37  "CLK_IOB_B",
38  "CLK_IOB_T",
39  "CLK_MGT_BOT",
40  "CLK_MGT_BOT_MGT",
41  "CLK_MGT_TOP",
42  "CLK_MGT_TOP_MGT",
43  "CLK_TERM_BOT",
44  "CLK_TERM_TOP",
45  "HCLK",
46  "HCLK_BRAM",
47  "HCLK_BRAM_MGT",
48  "HCLK_BRAM_MGT_LEFT",
49  "HCLK_CLB",
50  "HCLK_CMT_CMT",
51  "HCLK_CMT_CMT_MGT",
52  "HCLK_CMT_IOI",
53  "HCLK_DSP",
54  "HCLK_GT3",
55  "HCLK_GTX",
56  "HCLK_GTX_LEFT",
57  "HCLK_IOB",
58  "HCLK_IOB_CMT_BOT",
59  "HCLK_IOB_CMT_BOT_MGT",
60  "HCLK_IOB_CMT_MID",
61  "HCLK_IOB_CMT_MID_MGT",
62  "HCLK_IOB_CMT_TOP",
63  "HCLK_IOB_CMT_TOP_MGT",
64  "HCLK_IOI",
65  "HCLK_IOI_BOTCEN",
66  "HCLK_IOI_BOTCEN_MGT",
67  "HCLK_IOI_CENTER",
68  "HCLK_IOI_CMT",
69  "HCLK_IOI_CMT_MGT",
70  "HCLK_IOI_TOPCEN",
71  "HCLK_IOI_TOPCEN_MGT",
72  "HCLK_LIOB",
73  "HCLK_PCIE_BRAM",
74  "HCLK_PPC",
75  "HCLK_PPC_TERM",
76  "HCLK_TERM_L",
77  "HCLK_TERM_R",
78  "HCLK_VBRK",
79  "INT_HCLK_BUFS",
80  "LAST_TILE"
81  };
82 
83 /// \brief Export a single pip.
84 void exportSink(DDB& inDDB, Tilewire& inSource, Tilewire& inSink) {
85 
86  ExtendedWireInfo source(inDDB, inSource);
87  ExtendedWireInfo sink(inDDB, inSink);
88 
89  std::stringstream ss;
90  ss << kFamily << kNameSeparator << source.mTileTypeName << kNameSeparator << source.mWireName << kNameSeparator << sink.mWireName;
91  std::string designName(ss.str());
92 
94  "xc5vfx130t", "ff1738", "-2", "v3.2");
95 
98 
99  designPtr->addInstance(instancePtr);
100 
101  NetSharedPtr net = Factory::newNetPtr(dummyInstName);
102  Pip pip = Factory::newPip(source.mTileName, source.mWireName, sink.mWireName,
104  net->addPip(pip);
105 
106  torc::physical::InstancePinSharedPtr sourcePin = Factory::newInstancePinPtr(instancePtr,
107  "BQ");
108  torc::physical::InstancePinSharedPtr sinkPin = Factory::newInstancePinPtr(instancePtr,
109  "B4");
110  net->addSource(sourcePin);
111  net->addSink(sinkPin);
112 
113  designPtr->addNet(net);
114 
115  // export the created design
116  boost::filesystem::path xdlFilePath = gXDLGenerationFolder / designName.append(".xdl");
117  std::fstream xdlExport(xdlFilePath.string().c_str(), std::ios_base::out);
118  torc::physical::XdlExporter fileExporter(xdlExport);
119  fileExporter(designPtr);
120 }
121 
122 /// \brief Export all pips within the specified tile
123 void exportTileSinks(DDB& inDDB, TileIndex inTileIndex) {
124  const Tiles& tiles = inDDB.getTiles();
125  const TileInfo& tileInfo = tiles.getTileInfo(inTileIndex);
126 
127  TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
128 
129  std::cout << "Tile name: " << tileInfo.getName() << ", Tile type name: "
130  << tiles.getTileTypeName(tileTypeIndex) << std::endl;
131 
132  WireCount wireCount = tiles.getWireCount(tileTypeIndex);
133 
134  // iterate through all the wires in the tile
135  for(WireIndex wireIndex /* implicitly initialized to 0 */; wireIndex < wireCount; wireIndex++) {
136  // join the tile index and the wire index into a "tilewire"
137  Tilewire source(inTileIndex, wireIndex);
138  // expand all of the sinks of interest in this tile
139  TilewireVector sinks;
140  inDDB.expandTilewireSinks(source, sinks, false, true, true, true);
141  if(sinks.empty())
142  continue;
143  // iterate over all of the pips that we have found
144  TilewireVector::iterator p = sinks.begin();
145  TilewireVector::iterator e = sinks.end();
146  while(p < e) {
147  // look up the sink tilewire
148  Tilewire sink = *p++;
149  exportSink(inDDB, source, sink);
150  }
151  }
152 }
153 
154 /// \brief Export pips from arbitrary tiles for the given device.
155 int main(int argc, char* argv[]) {
156 
157  if(argc != 2) {
158  std::cerr << "Invalid arguments. Usage: " << argv[0] <<
159  " <xdl_generation_folder>" << std::endl;
160  exit (-1);
161  }
162 
163  // Create the xdl generation folder if it doesn't exits
164  gXDLGenerationFolder = argv[1];
165  if(!boost::filesystem::exists(gXDLGenerationFolder))
166  boost::filesystem::create_directory(gXDLGenerationFolder);
167 
168  // construct and initialize the device database
169  DirectoryTree directoryTree(argv[0]);
170 
171 
172  DeviceDesignator designator("xc5vfx130tff1738-2");
173  DDB ddb(designator);
174  std::cout << ddb; // this allows the database to annotate stream output
175 
176  // look up all tile types
177  const Tiles& tiles = ddb.getTiles();
178  tiles.getTileTypeCount();
179  TileCount tileCount = tiles.getTileCount();
180 
181  // Go over the supported tile types, find the first tile of the type in "all types" list
182  uint32_t supportedTileIndex = 0;
183  while(kSupportedTiles[supportedTileIndex].compare("LAST_TILE") != 0) {
184 
185  for(TileIndex i; i < tileCount; i++) {
186  const TileInfo& tileInfo = tiles.getTileInfo(i);
187  TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
188  std::string tileTypeName = tiles.getTileTypeName(tileTypeIndex);
189  if(tileTypeName.compare(kSupportedTiles[supportedTileIndex]) == 0) {
190  exportTileSinks(ddb, i);
191  break;
192  }
193  }
194  supportedTileIndex++;
195  }
196 
197 
198  return 0;
199 }
const char * mTileTypeName
The tile type name.
Encapsulation of a tile index in an unsigned 32-bit integer.
const std::string dummyInstName
void exportTileSinks(DDB &inDDB, TileIndex inTileIndex)
Export all pips within the specified tile.
std::vector< Tilewire > TilewireVector
Vector of Tilewire objects.
Definition: Tilewire.hpp:101
Main torc::architecture namespace header.
Encapsulation of a device designator and its constituent elements.
const std::string dummyInstSiteLcoation
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
TileTypeCount getTileTypeCount(void) const
Returns the tile type count for this device.
Definition: Tiles.hpp:151
const Tiles & getTiles(void) const
Returns a constant reference to the family and device tile data.
Definition: DDB.hpp:146
const char * mWireName
The wire name.
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
const std::string dummyInstSiteType
Encapsulation of a wire index in an unsigned 16-bit integer.
boost::shared_ptr< class InstancePin > InstancePinSharedPtr
Shared pointer encapsulation of an InstancePin.
TileCount getTileCount(void) const
Returns the tile count for this device.
Definition: Tiles.hpp:149
std::string string
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.
Definition: DDB.cpp:214
static boost::filesystem::path gXDLGenerationFolder
const char * mTileName
The tile name.
Main torc::physical namespace header.
Encapsulation of a device tile and wire pair.
Definition: Tilewire.hpp:39
int main(int argc, char *argv[])
Export pips from arbitrary tiles for the given device.
Tile map, tile type, and wire information for the family and device.
Definition: Tiles.hpp:36
Encapsulation of filesystem paths that are used by the library.
Encapsulation of a wire count in an unsigned 16-bit integer.
Encapsulation of a tile count in an unsigned 32-bit integer.
Encapsulation of a tile within a device tile map.
Definition: TileInfo.hpp:33
boost::shared_ptr< Net > NetSharedPtr
Shared pointer encapsulation of a Net.
const char * getTileTypeName(TileTypeIndex inTileTypeIndex) const
Returns the tile type name for the given tile type index.
Definition: Tiles.hpp:164
Verbose encapsulation of a wire's information.
static InstanceSharedPtr newInstancePtr(const string &inName, const string &inType, const string &inTile, const string &inSite, EInstanceBonding inBonding=eInstanceBondingUnknown, InstanceReferenceSharedPtr inInstanceReferencePtr=InstanceReferenceSharedPtr())
Construct and return a new Instance shared pointer.
boost::filesystem::path path
const TileTypeIndex & getTypeIndex(void) const
Returns the tile type index for this tile.
Definition: TileInfo.hpp:92
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
const std::string kNameSeparator
Physical design programmable interconnect point.
Definition: Pip.hpp:34
const std::string kFamily
Encapsulation of a tile type index in an unsigned 16-bit integer.
const char * getName(void) const
Returns the name for this tile.
Definition: TileInfo.hpp:98
static DesignSharedPtr newDesignPtr(const string &inName, const string &inDevice, const string &inPackage, const string &inSpeedGrade, const string &inXdlVersion)
Create and return a new Design shared pointer.
Main torc::common namespace header.
WireCount getWireCount(TileTypeIndex inTileTypeIndex) const
Returns the wire count for the specified tile type.
Definition: Tiles.hpp:157
Physical design exporter for XDL.
Definition: XdlExporter.hpp:31
void exportSink(DDB &inDDB, Tilewire &inSource, Tilewire &inSink)
Export a single pip.
static const std::string kSupportedTiles[]