torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::architecture::Tiles Class Reference

Tile map, tile type, and wire information for the family and device. More...

#include <Tiles.hpp>

+ Inheritance diagram for torc::architecture::Tiles:
+ Collaboration diagram for torc::architecture::Tiles:

Data Structures

class  CharStringWrapper
 Wrapper around char* for use with the Array template. More...
 

Public Member Functions

 ~Tiles (void)
 Non-virtual destructor. More...
 
const TileInfogetTileInfo (TileIndex inTileIndex) const
 Returns the TileInfo object for the specified tile. More...
 
const Array< const WireInfo > & getWireInfo (TileTypeIndex inTileTypeIndex) const
 Returns the WireInfo array for the specified tile type. More...
 
const WireInfogetWireInfo (TileTypeIndex inTileTypeIndex, WireIndex inWireIndex) const
 Returns the WireInfo object for the specified tile type and wire index. More...
 
const WireInfogetWireInfo (TileIndex inTileIndex, WireIndex inWireIndex) const
 Returns the WireInfo object for the specified tile index and wire index. More...
 
TileCount getTileCount (void) const
 Returns the tile count for this device. More...
 
TileTypeCount getTileTypeCount (void) const
 Returns the tile type count for this device. More...
 
TileRow getRowCount (void) const
 Returns the row count for this device. More...
 
TileCol getColCount (void) const
 Returns the column count for this device. More...
 
WireCount getWireCount (TileTypeIndex inTileTypeIndex) const
 Returns the wire count for the specified tile type. More...
 
TileIndex getTileIndex (TileRow inRow, TileCol inCol) const
 Returns the tile index for the given [row,column] pair. More...
 
const char * getTileTypeName (TileTypeIndex inTileTypeIndex) const
 Returns the tile type name for the given tile type index. More...
 
TileIndex findTileIndex (const string &inName) const
 Returns the tile index for the given tile name. More...
 
WireIndex findWireIndex (TileTypeIndex inTileTypeIndex, const string &inName) const
 Returns the wire index for the given wire name in the given tile type. More...
 

Protected Types

typedef std::string string
 Imported type name. More...
 
typedef boost::uint16_t uint16_t
 Imported type name. More...
 
typedef boost::uint32_t uint32_t
 Imported type name. More...
 
typedef xilinx::TileRow TileRow
 Imported type name. More...
 
typedef xilinx::TileCol TileCol
 Imported type name. More...
 
typedef xilinx::TileCount TileCount
 Imported type name. More...
 
typedef xilinx::TileIndex TileIndex
 Imported type name. More...
 
typedef xilinx::TileTypeCount TileTypeCount
 Imported type name. More...
 
typedef xilinx::TileTypeIndex TileTypeIndex
 Imported type name. More...
 
typedef xilinx::WireCount WireCount
 Imported type name. More...
 
typedef xilinx::WireIndex WireIndex
 Imported type name. More...
 
typedef std::pair< std::string,
xilinx::TileIndex
TileNameIndexPair
 Wrapper for a tile name with corresponding tile index. More...
 
typedef std::pair< std::string,
xilinx::WireIndex
WireNameIndexPair
 Wrapper for a wire name with corresponding wire index. More...
 

Protected Member Functions

size_t readTileTypes (DigestStream &inStream)
 Read the family tile types. More...
 
size_t readTileWireInfo (DigestStream &inStream)
 Read the family wire info. More...
 
size_t readTileMap (DigestStream &inStream)
 Read the device tile map. More...
 
 Tiles (void)
 Protected constructor. More...
 

Static Protected Member Functions

static bool CompareTilePairByName (const TileNameIndexPair &inA, const TileNameIndexPair &inB)
 Compare tile pairs by name, for ordering purposes. More...
 
static bool CompareWirePairByName (const WireNameIndexPair &inA, const WireNameIndexPair &inB)
 Compare wire pairs by name, for ordering purposes. More...
 

Protected Attributes

TileCount mTileCount
 The tile count for this device. More...
 
TileRow mRowCount
 The tile row count for this device. More...
 
TileCol mColCount
 The tile column count for this device. More...
 
TileIndex ** mTileMap
 The two-dimensional tile map for this device. More...
 
Array< const TileInfomTiles
 The tile information for this device. More...
 
Array< const TileNameIndexPairmOrderedTileNames
 The tile name to tile index mapping for this device. More...
 
TileTypeCount mTileTypeCount
 The number of tile types for this family. More...
 
Array< const CharStringWrappermTileTypeNames
 The tile type names for this family. More...
 
Array2D< const WireInfomWires
 The wire information for this family. More...
 
Array2D< const WireNameIndexPairmOrderedWireNames
 The wire name to wire index mapping for each tile type for this family. More...
 

Private Types

typedef std::basic_istream< char > istream
 Internal typedef of istream;. More...
 
typedef std::basic_ostream< char > ostream
 Internal typedef of ostream;. More...
 

Private Member Functions

istreammIn (void)
 Returns the database console input stream. More...
 
ostreammOut (void)
 Returns the database console output stream. More...
 
ostreammErr (void)
 Returns the database console error stream. More...
 
ostreammLog (void)
 Returns the database console log stream. More...
 
istreamgetConsoleIn (void)
 Returns the database console input stream. More...
 
ostreamgetConsoleOut (void)
 Returns the database console output stream. More...
 
ostreamgetConsoleErr (void)
 Returns the database console error stream. More...
 
ostreamgetConsoleLog (void)
 Returns the database console log stream. More...
 
void setConsoleIn (istream &inStream)
 Sets the database console input stream. More...
 
void setConsoleOut (ostream &inStream)
 Sets the database console output stream. More...
 
void setConsoleErr (ostream &inStream)
 Sets the database console error stream. More...
 
void setConsoleLog (ostream &inStream)
 Sets the database console log stream. More...
 
virtual void setConsoleStreams (istream &inIn, ostream &inOut, ostream &inErr, ostream &inLog)
 Sets all of the database console streams. More...
 

Private Attributes

istreammInPtr
 Pointer to the database console input stream. More...
 
ostreammOutPtr
 
ostreammErrPtr
 
ostreammLogPtr
 

Static Private Attributes

static DDBConsoleStreams sDefaultConsoleStreams
 
static DDBConsoleStreams sNullConsoleStreams
 

Friends

class DDB
 The database has access to our protected functions. More...
 

Detailed Description

Tile map, tile type, and wire information for the family and device.

The tile map defines the tile layout for the current device. Every tile is associated with a tile type that has been defined for the family. The wire type information is likewise device independent, and is therefore included in this class.

Definition at line 36 of file Tiles.hpp.

Member Typedef Documentation

Internal typedef of istream;.

Definition at line 41 of file DDBConsoleStreams.hpp.

Internal typedef of ostream;.

Definition at line 43 of file DDBConsoleStreams.hpp.

typedef std::string torc::architecture::Tiles::string
protected

Imported type name.

Definition at line 42 of file Tiles.hpp.

Imported type name.

Definition at line 46 of file Tiles.hpp.

Imported type name.

Definition at line 47 of file Tiles.hpp.

Imported type name.

Definition at line 48 of file Tiles.hpp.

typedef std::pair<std::string, xilinx::TileIndex> torc::architecture::Tiles::TileNameIndexPair
protected

Wrapper for a tile name with corresponding tile index.

Definition at line 54 of file Tiles.hpp.

Imported type name.

Definition at line 45 of file Tiles.hpp.

Imported type name.

Definition at line 49 of file Tiles.hpp.

Imported type name.

Definition at line 50 of file Tiles.hpp.

typedef boost::uint16_t torc::architecture::Tiles::uint16_t
protected

Imported type name.

Definition at line 43 of file Tiles.hpp.

typedef boost::uint32_t torc::architecture::Tiles::uint32_t
protected

Imported type name.

Definition at line 44 of file Tiles.hpp.

Imported type name.

Definition at line 51 of file Tiles.hpp.

Imported type name.

Definition at line 52 of file Tiles.hpp.

typedef std::pair<std::string, xilinx::WireIndex> torc::architecture::Tiles::WireNameIndexPair
protected

Wrapper for a wire name with corresponding wire index.

Definition at line 56 of file Tiles.hpp.

Constructor & Destructor Documentation

torc::architecture::Tiles::Tiles ( void  )
inlineprotected

Protected constructor.

Definition at line 123 of file Tiles.hpp.

123  : mTileCount(), mRowCount(), mColCount(), mTileMap(0), mTiles(),
TileRow mRowCount
The tile row count for this device.
Definition: Tiles.hpp:86
Array< const CharStringWrapper > mTileTypeNames
The tile type names for this family.
Definition: Tiles.hpp:98
TileCol mColCount
The tile column count for this device.
Definition: Tiles.hpp:88
TileTypeCount mTileTypeCount
The number of tile types for this family.
Definition: Tiles.hpp:96
Array< const TileInfo > mTiles
The tile information for this device.
Definition: Tiles.hpp:92
TileCount mTileCount
The tile count for this device.
Definition: Tiles.hpp:84
TileIndex ** mTileMap
The two-dimensional tile map for this device.
Definition: Tiles.hpp:90
Array2D< const WireInfo > mWires
The wire information for this family.
Definition: Tiles.hpp:100
torc::architecture::Tiles::~Tiles ( void  )
inline

Non-virtual destructor.

Definition at line 128 of file Tiles.hpp.

128  {
129  // release the tile map memory; the other objects will go away by themselves
130  if(mTileMap != 0) {
131  if(mTileMap[0] != 0) { delete[] mTileMap[0]; mTileMap[0] = 0; }
132  delete[] mTileMap; mTileMap = 0;
133  }
134  }
TileIndex ** mTileMap
The two-dimensional tile map for this device.
Definition: Tiles.hpp:90

Member Function Documentation

static bool torc::architecture::Tiles::CompareTilePairByName ( const TileNameIndexPair inA,
const TileNameIndexPair inB 
)
inlinestaticprotected

Compare tile pairs by name, for ordering purposes.

Definition at line 112 of file Tiles.hpp.

113  {
114  return inA.first < inB.first;
115  }

+ Here is the caller graph for this function:

static bool torc::architecture::Tiles::CompareWirePairByName ( const WireNameIndexPair inA,
const WireNameIndexPair inB 
)
inlinestaticprotected

Compare wire pairs by name, for ordering purposes.

Definition at line 117 of file Tiles.hpp.

118  {
119  return inA.first < inB.first;
120  }

+ Here is the caller graph for this function:

TileIndex torc::architecture::Tiles::findTileIndex ( const string inName) const
inline

Returns the tile index for the given tile name.

The search has logarithmic complexity.

Returns
TileIndex(-1) if the name does not exist, or the corresponding tile index otherwise.

Definition at line 170 of file Tiles.hpp.

170  {
174  Array<const TileNameIndexPair>::const_iterator p = lower_bound(b, e, value,
176  return TileIndex((p == e || p->first != inName) ? -1 : p->second);
177  }
xilinx::TileIndex TileIndex
Imported type name.
Definition: Tiles.hpp:48
const const TileNameIndexPair * const_iterator
Constant T iterator type.
Definition: Array.hpp:83
T * end(void)
Returns the non-constant end iterator.
Definition: Array.hpp:97
static bool CompareTilePairByName(const TileNameIndexPair &inA, const TileNameIndexPair &inB)
Compare tile pairs by name, for ordering purposes.
Definition: Tiles.hpp:112
T * begin(void)
Returns the non-constant begin iterator.
Definition: Array.hpp:95
std::pair< std::string, xilinx::TileIndex > TileNameIndexPair
Wrapper for a tile name with corresponding tile index.
Definition: Tiles.hpp:54
Array< const TileNameIndexPair > mOrderedTileNames
The tile name to tile index mapping for this device.
Definition: Tiles.hpp:94

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

WireIndex torc::architecture::Tiles::findWireIndex ( TileTypeIndex  inTileTypeIndex,
const string inName 
) const
inline

Returns the wire index for the given wire name in the given tile type.

The search has logarithmic complexity.

Returns
WireIndex(-1) if the name does not exist, or the corresponding wire index otherwise.

Definition at line 182 of file Tiles.hpp.

182  {
183  const Array<const WireNameIndexPair>& wireNameIndexPairArray
184  = mOrderedWireNames[inTileTypeIndex];
185  Array<const WireNameIndexPair>::const_iterator b = wireNameIndexPairArray.begin();
186  Array<const WireNameIndexPair>::const_iterator e = wireNameIndexPairArray.end();
188  Array<const WireNameIndexPair>::const_iterator p = lower_bound(b, e, value,
190  return WireIndex((p == e || p->first != inName) ? -1 : p->second);
191  }
std::pair< std::string, xilinx::WireIndex > WireNameIndexPair
Wrapper for a wire name with corresponding wire index.
Definition: Tiles.hpp:56
static bool CompareWirePairByName(const WireNameIndexPair &inA, const WireNameIndexPair &inB)
Compare wire pairs by name, for ordering purposes.
Definition: Tiles.hpp:117
Array2D< const WireNameIndexPair > mOrderedWireNames
The wire name to wire index mapping for each tile type for this family.
Definition: Tiles.hpp:102
T * begin(void)
Returns the non-constant begin iterator.
Definition: Array.hpp:95
xilinx::WireIndex WireIndex
Imported type name.
Definition: Tiles.hpp:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TileCol torc::architecture::Tiles::getColCount ( void  ) const
inline

Returns the column count for this device.

Definition at line 155 of file Tiles.hpp.

155 { return mColCount; }
TileCol mColCount
The tile column count for this device.
Definition: Tiles.hpp:88

+ Here is the caller graph for this function:

ostream& torc::architecture::DDBConsoleStreams::getConsoleErr ( void  )
inlineinherited

Returns the database console error stream.

Definition at line 69 of file DDBConsoleStreams.hpp.

69 { return mErr(); }
ostream & mErr(void)
Returns the database console error stream.

+ Here is the call graph for this function:

istream& torc::architecture::DDBConsoleStreams::getConsoleIn ( void  )
inlineinherited

Returns the database console input stream.

Definition at line 65 of file DDBConsoleStreams.hpp.

65 { return mIn(); }
istream & mIn(void)
Returns the database console input stream.

+ Here is the call graph for this function:

ostream& torc::architecture::DDBConsoleStreams::getConsoleLog ( void  )
inlineinherited

Returns the database console log stream.

Definition at line 71 of file DDBConsoleStreams.hpp.

71 { return mLog(); }
ostream & mLog(void)
Returns the database console log stream.

+ Here is the call graph for this function:

ostream& torc::architecture::DDBConsoleStreams::getConsoleOut ( void  )
inlineinherited

Returns the database console output stream.

Definition at line 67 of file DDBConsoleStreams.hpp.

67 { return mOut(); }
ostream & mOut(void)
Returns the database console output stream.

+ Here is the call graph for this function:

TileRow torc::architecture::Tiles::getRowCount ( void  ) const
inline

Returns the row count for this device.

Definition at line 153 of file Tiles.hpp.

153 { return mRowCount; }
TileRow mRowCount
The tile row count for this device.
Definition: Tiles.hpp:86

+ Here is the caller graph for this function:

TileCount torc::architecture::Tiles::getTileCount ( void  ) const
inline

Returns the tile count for this device.

Definition at line 149 of file Tiles.hpp.

149 { return mTileCount; }
TileCount mTileCount
The tile count for this device.
Definition: Tiles.hpp:84

+ Here is the caller graph for this function:

TileIndex torc::architecture::Tiles::getTileIndex ( TileRow  inRow,
TileCol  inCol 
) const
inline

Returns the tile index for the given [row,column] pair.

Definition at line 161 of file Tiles.hpp.

162  { return mTileMap[inRow][inCol]; }
TileIndex ** mTileMap
The two-dimensional tile map for this device.
Definition: Tiles.hpp:90

+ Here is the caller graph for this function:

const TileInfo& torc::architecture::Tiles::getTileInfo ( TileIndex  inTileIndex) const
inline

Returns the TileInfo object for the specified tile.

Definition at line 137 of file Tiles.hpp.

137  {
138  return mTiles[inTileIndex]; }
Array< const TileInfo > mTiles
The tile information for this device.
Definition: Tiles.hpp:92

+ Here is the caller graph for this function:

TileTypeCount torc::architecture::Tiles::getTileTypeCount ( void  ) const
inline

Returns the tile type count for this device.

Definition at line 151 of file Tiles.hpp.

151 { return mTileTypeCount; }
TileTypeCount mTileTypeCount
The number of tile types for this family.
Definition: Tiles.hpp:96

+ Here is the caller graph for this function:

const char* torc::architecture::Tiles::getTileTypeName ( TileTypeIndex  inTileTypeIndex) const
inline

Returns the tile type name for the given tile type index.

Definition at line 164 of file Tiles.hpp.

165  { return mTileTypeNames[inTileTypeIndex]; }
Array< const CharStringWrapper > mTileTypeNames
The tile type names for this family.
Definition: Tiles.hpp:98

+ Here is the caller graph for this function:

WireCount torc::architecture::Tiles::getWireCount ( TileTypeIndex  inTileTypeIndex) const
inline

Returns the wire count for the specified tile type.

Definition at line 157 of file Tiles.hpp.

158  { return WireCount(mWires[inTileTypeIndex].getSize()); }
xilinx::WireCount WireCount
Imported type name.
Definition: Tiles.hpp:51
Array2D< const WireInfo > mWires
The wire information for this family.
Definition: Tiles.hpp:100

+ Here is the caller graph for this function:

const Array<const WireInfo>& torc::architecture::Tiles::getWireInfo ( TileTypeIndex  inTileTypeIndex) const
inline

Returns the WireInfo array for the specified tile type.

Definition at line 140 of file Tiles.hpp.

141  { return mWires[inTileTypeIndex]; }
Array2D< const WireInfo > mWires
The wire information for this family.
Definition: Tiles.hpp:100

+ Here is the caller graph for this function:

const WireInfo& torc::architecture::Tiles::getWireInfo ( TileTypeIndex  inTileTypeIndex,
WireIndex  inWireIndex 
) const
inline

Returns the WireInfo object for the specified tile type and wire index.

Definition at line 143 of file Tiles.hpp.

144  { return mWires[inTileTypeIndex][inWireIndex]; }
Array2D< const WireInfo > mWires
The wire information for this family.
Definition: Tiles.hpp:100
const WireInfo& torc::architecture::Tiles::getWireInfo ( TileIndex  inTileIndex,
WireIndex  inWireIndex 
) const
inline

Returns the WireInfo object for the specified tile index and wire index.

Definition at line 146 of file Tiles.hpp.

147  { return mWires[mTiles[inTileIndex].mTypeIndex][inWireIndex]; }
Array< const TileInfo > mTiles
The tile information for this device.
Definition: Tiles.hpp:92
Array2D< const WireInfo > mWires
The wire information for this family.
Definition: Tiles.hpp:100
ostream& torc::architecture::DDBConsoleStreams::mErr ( void  )
inlineinherited

Returns the database console error stream.

Definition at line 61 of file DDBConsoleStreams.hpp.

+ Here is the caller graph for this function:

istream& torc::architecture::DDBConsoleStreams::mIn ( void  )
inlineinherited

Returns the database console input stream.

Definition at line 57 of file DDBConsoleStreams.hpp.

57 { return *mInPtr; }
istream * mInPtr
Pointer to the database console input stream.

+ Here is the caller graph for this function:

ostream& torc::architecture::DDBConsoleStreams::mLog ( void  )
inlineinherited

Returns the database console log stream.

Definition at line 63 of file DDBConsoleStreams.hpp.

+ Here is the caller graph for this function:

ostream& torc::architecture::DDBConsoleStreams::mOut ( void  )
inlineinherited

Returns the database console output stream.

Definition at line 59 of file DDBConsoleStreams.hpp.

+ Here is the caller graph for this function:

size_t torc::architecture::Tiles::readTileMap ( DigestStream inStream)
protected

Read the device tile map.

Todo:
Throw a proper exception.
Todo:
Throw a proper exception.

Definition at line 226 of file Tiles.cpp.

226  {
227  // prepare to read from the stream
228  size_t bytesReadOffset = inStream.getBytesRead();
229  char scratch[1 << 10]; // scratch read buffer
230  uint16_t nameLength = 0; // length of tile type name
231  TileTypeIndex type; // tile type
232  TileRow row; // tile row
233  TileCol col; // tile column
234 
235  // read the section header
236  string sectionName;
237  inStream.readSectionHeader(sectionName);
238  /// \todo Throw a proper exception.
239  if(sectionName != ">>>>TileMap >>>>") throw -1;
240 
241  // read the characteristic dimensions
242  inStream.read(mTileCount);
243  inStream.read(mRowCount);
244  inStream.read(mColCount);
245 
246  // initialize the tile map array
247  mTiles.setSize(mTileCount);
249  mTileMap = new TileIndex*[static_cast<TileRow::pod>(mRowCount)];
250  mTileMap[0] = new TileIndex[static_cast<TileCount::pod>(mTileCount)];
251  for(TileRow i(1); i < mRowCount; i++) mTileMap[i] = mTileMap[i-1] + mColCount;
252  mOut() << "\tReading tile map for " << mTileCount << " tiles (" << mRowCount
253  << " rows x " << mColCount << " columns)..." << std::endl;
254  // loop through each tile
255  for(TileIndex i; i < mTileCount; i++) {
256  // read the info for each tile
257  inStream.read(type);
258  inStream.read(row);
259  inStream.read(col);
260  inStream.read(nameLength);
261  /// \todo Throw a proper exception.
262  if(nameLength > sizeof(scratch)) throw -1;
263  inStream.read(scratch, nameLength);
264  scratch[nameLength] = 0;
265  // and store the info
266  const_cast<TileInfo&>(mTiles[i]).set(type, row, col, scratch);
267  mTileMap[row][col] = i; // point back to the tile index
268  //mErr() << "\t\t" << i << ": [" << row << "," << col << "]: \"" << scratch
269  // << "\" (" << mTileTypeNames[type] << ")" << std::endl;
270  // also add the entry to the ordered tile names array
271  const_cast<TileNameIndexPair&>(mOrderedTileNames[i])
272  = TileNameIndexPair(mTiles[i].getName(), i);
273  }
274 
275  // sort the ordered tile names
276  std::sort(const_cast<Array<TileNameIndexPair>::iterator>(mOrderedTileNames.begin()),
277  const_cast<Array<TileNameIndexPair>::iterator>(mOrderedTileNames.end()),
279  );
280 
281  // return the number of bytes read
282  return inStream.getBytesRead() - bytesReadOffset;
283  }
xilinx::TileIndex TileIndex
Imported type name.
Definition: Tiles.hpp:48
TileRow mRowCount
The tile row count for this device.
Definition: Tiles.hpp:86
T * end(void)
Returns the non-constant end iterator.
Definition: Array.hpp:97
TileCol mColCount
The tile column count for this device.
Definition: Tiles.hpp:88
xilinx::TileTypeIndex TileTypeIndex
Imported type name.
Definition: Tiles.hpp:50
Array< const TileInfo > mTiles
The tile information for this device.
Definition: Tiles.hpp:92
TileCount mTileCount
The tile count for this device.
Definition: Tiles.hpp:84
ostream & mOut(void)
Returns the database console output stream.
TileIndex ** mTileMap
The two-dimensional tile map for this device.
Definition: Tiles.hpp:90
static bool CompareTilePairByName(const TileNameIndexPair &inA, const TileNameIndexPair &inB)
Compare tile pairs by name, for ordering purposes.
Definition: Tiles.hpp:112
T * begin(void)
Returns the non-constant begin iterator.
Definition: Array.hpp:95
void setSize(uint32_t inSize)
Discards all contents and resizes the array.
Definition: Array.hpp:107
std::pair< std::string, xilinx::TileIndex > TileNameIndexPair
Wrapper for a tile name with corresponding tile index.
Definition: Tiles.hpp:54
boost::uint16_t uint16_t
Imported type name.
Definition: Tiles.hpp:43
Array< const TileNameIndexPair > mOrderedTileNames
The tile name to tile index mapping for this device.
Definition: Tiles.hpp:94
xilinx::TileRow TileRow
Imported type name.
Definition: Tiles.hpp:45
boost::uint16_t pod
Alias for the encapsulated Plain-Old-Data type.
xilinx::TileCol TileCol
Imported type name.
Definition: Tiles.hpp:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t torc::architecture::Tiles::readTileTypes ( DigestStream inStream)
protected

Read the family tile types.

Todo:
Throw a proper exception.
Todo:
Throw a proper exception.

Definition at line 25 of file Tiles.cpp.

25  {
26  // prepare to read from the stream
27  size_t bytesReadOffset = inStream.getBytesRead();
28  char scratch[1 << 10]; // scratch read buffer
29  uint16_t nameLength = 0; // length of tile type name
30 
31  // read the section header
32  string sectionName;
33  inStream.readSectionHeader(sectionName);
34  /// \todo Throw a proper exception.
35  if(sectionName != ">>>>TileType>>>>") throw -1;
36 
37  // initialize the tile type array
38  inStream.read(mTileTypeCount);
40  mOut() << "\tReading " << mTileTypeCount << " tile types..." << std::endl;
41  // loop through each tile type
42  for(TileTypeCount i; i < mTileTypeCount; i++) {
43  // read the tile type name
44  inStream.read(nameLength);
45  /// \todo Throw a proper exception.
46  if(nameLength > sizeof(scratch)) throw -1;
47  inStream.read(scratch, nameLength);
48  scratch[nameLength] = 0;
49  const_cast<CharStringWrapper&>(mTileTypeNames[i]) = scratch;
50  //mErr() << "\t\t" << mTileTypeNames[i] << ": "
51  // << (void*) (const char*) mTileTypeNames[i] << std::endl;
52  }
53 
54  // return the number of bytes read
55  return inStream.getBytesRead() - bytesReadOffset;
56  }
Array< const CharStringWrapper > mTileTypeNames
The tile type names for this family.
Definition: Tiles.hpp:98
TileTypeCount mTileTypeCount
The number of tile types for this family.
Definition: Tiles.hpp:96
xilinx::TileTypeCount TileTypeCount
Imported type name.
Definition: Tiles.hpp:49
ostream & mOut(void)
Returns the database console output stream.
boost::uint16_t uint16_t
Imported type name.
Definition: Tiles.hpp:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t torc::architecture::Tiles::readTileWireInfo ( DigestStream inStream)
protected

Read the family wire info.

Todo:
Throw a proper exception.
Todo:
Throw a proper exception.
Todo:
Throw a proper exception.

Definition at line 58 of file Tiles.cpp.

58  {
59  // prepare to read from the stream
60  size_t bytesReadOffset = inStream.getBytesRead();
61  char scratch[1 << 10]; // scratch read buffer
62  uint16_t nameLength = 0; // length of tile type name
63  TileTypeCount typeCount; // number of tile types
64  WireCount wireCount; // number of wires
65  WireCount sinkCount; // number of sinks or tied sinks
66  WireIndex sink; // wire index of sink or tied sink
67  uint16_t offset = 0; // offset into the arc usage bitmap
68 
69  // read the section header
70  string sectionName;
71  inStream.readSectionHeader(sectionName);
72  /// \todo Throw a proper exception.
73  if(sectionName != ">>>>TileNode>>>>") throw -1;
74 
75  // initialize the tile type array
76  inStream.read(typeCount);
77  /// \todo Throw a proper exception.
78  if(typeCount != mTileTypeCount) throw -1;
79  mWires.setSize(mTileTypeCount);
81  mOut() << "\tReading wire info for " << mTileTypeCount << " tile types..."
82  << std::endl;
83  // loop through each tile type
84  for(TileTypeCount i; i < mTileTypeCount; i++) {
85  //mErr() << "\t\t" << mTileTypeNames[i] << ":" << std::endl;
86  offset = 0;
87  // read the wire count
88  inStream.read(wireCount);
89  mWires[i].setSize(wireCount);
90  mOrderedWireNames[i].setSize(wireCount);
91  // get a reference to this tile type's wire info array
92  Array<const WireInfo>& wires = mWires[i];
93  // get a reference to this tile type's wire name array
94  Array<const WireNameIndexPair>& wireNameIndexPairs = mOrderedWireNames[i];
95  // prepare to track the source and tied source counts for each wire in the tile type
96  Array<uint16_t> sourceCounts(wireCount);
97  Array<uint16_t> tiedSourceCounts(wireCount);
98  Array<uint16_t> irregularSourceCounts(wireCount);
99  Array<uint16_t> routethroughSourceCounts(wireCount);
100  for(WireCount j; j < wireCount; j++) { sourceCounts[j] = tiedSourceCounts[j]
101  = irregularSourceCounts[j] = routethroughSourceCounts[j] = 0; }
102  // loop over all of the wires
103  for(WireIndex j; j < wireCount; j++) {
104  // look up a reference for the wire info, and discard the const trait
105  WireInfo& wireInfo = const_cast<WireInfo&>(wires[j]);
106  // store the cumulative arc offset for this tile type
107  wireInfo.mArcOffset = offset;
108  // read the flags
109  inStream.read(wireInfo.mFlags);
110  // read the wire name
111  inStream.read(nameLength);
112  /// \todo Throw a proper exception.
113  if(nameLength > sizeof(scratch)) throw -1;
114  inStream.read(scratch, nameLength);
115  scratch[nameLength] = 0;
116  wireInfo.mName = strdup(scratch);
117  // also add the entry to the ordered wire names array
118  const_cast<WireNameIndexPair&>(wireNameIndexPairs[j])
119  = WireNameIndexPair(wireInfo.mName, WireIndex(j));
120  // read the tied sinks, and update the tied source count for each one
121  inStream.read(sinkCount);
122  wireInfo.mTiedSinks.setSize(sinkCount);
123  for(WireIndex k; k < sinkCount; k++) {
124  inStream.read(sink);
125  const_cast<WireIndex&>(wireInfo.mTiedSinks[k]) = sink;
126  tiedSourceCounts[sink]++;
127  }
128  // read the regular sinks, and update the source count for each one
129  inStream.read(sinkCount);
130  wireInfo.mSinks.setSize(sinkCount);
131  for(WireIndex k; k < sinkCount; k++) {
132  offset++; // increment the arc count
133  inStream.read(sink);
134  const_cast<WireIndex&>(wireInfo.mSinks[k]) = sink;
135  sourceCounts[sink]++;
136  //// take care to allow for negative numbers in remote arcs
137  //sourceCounts[sink >= 0 ? sink : -1 - sink]++;
138  }
139  // read the irregular sinks, and update the irregular source count for each one
140  inStream.read(sinkCount);
141  wireInfo.mIrregularSinks.setSize(sinkCount);
142  for(WireIndex k; k < sinkCount; k++) {
143  offset++; // increment the arc count
144  inStream.read(sink);
145  const_cast<WireIndex&>(wireInfo.mIrregularSinks[k]) = sink;
146  irregularSourceCounts[sink]++;
147  }
148  // read the routethrough sinks, and update the routethrough source count for each
149  // one
150  inStream.read(sinkCount);
151  wireInfo.mRoutethroughSinks.setSize(sinkCount);
152  for(WireIndex k; k < sinkCount; k++) {
153  offset++; // increment the arc count
154  inStream.read(sink);
155  const_cast<WireIndex&>(wireInfo.mRoutethroughSinks[k]) = sink;
156  routethroughSourceCounts[sink]++;
157  }
158  }
159 
160  // initialize the source arrays
161  for(WireIndex j; j < wireCount; j++) {
162  // look up a reference for the wire info, and discard the const trait
163  WireInfo& wireInfo = const_cast<WireInfo&>(wires[j]);
164  wireInfo.mSources.setSize(sourceCounts[j]);
165  wireInfo.mTiedSources.setSize(tiedSourceCounts[j]);
166  wireInfo.mIrregularSources.setSize(irregularSourceCounts[j]);
167  wireInfo.mRoutethroughSources.setSize(routethroughSourceCounts[j]);
168  }
169 
170  // and infer the source information from the sinks
171  for(WireIndex j; j < wireCount; j++) {
172  // look up a reference for the wire info, and discard the const trait
173  WireInfo& wireInfo = const_cast<WireInfo&>(wires[j]);
174  // handle the tied sources
175  const WireArray& tiedSinks = wireInfo.getTiedSinks();
176  sinkCount = WireIndex(tiedSinks.getSize());
177  for(WireIndex k; k < sinkCount; k++) {
178  const WireIndex tiedSink = tiedSinks[k];
179  tiedSourceCounts[tiedSink]--;
180  const_cast<WireIndex&>(wires[tiedSink]
181  .mTiedSources[tiedSourceCounts[tiedSink]]) = WireIndex(j);
182  }
183  // handle the normal sources
184  const WireArray& sinks = wireInfo.getSinks();
185  sinkCount = WireIndex(sinks.getSize());
186  for(WireIndex k; k < sinkCount; k++) {
187  const WireIndex sink = sinks[k];
188  sourceCounts[sink]--;
189  const_cast<WireIndex&>(wires[sink]
190  .mSources[sourceCounts[sink]]) = WireIndex(j);
191  }
192  // handle the irregular sources
193  const WireArray& irregularSinks = wireInfo.getIrregularSinks();
194  sinkCount = WireIndex(irregularSinks.getSize());
195  for(WireIndex k; k < sinkCount; k++) {
196  const WireIndex irregularSink = irregularSinks[k];
197  irregularSourceCounts[irregularSink]--;
198  const_cast<WireIndex&>(wires[irregularSink]
199  .mIrregularSources[irregularSourceCounts[irregularSink]]) = WireIndex(j);
200  }
201  // handle the routethrough sources
202  const WireArray& routethroughSinks = wireInfo.getRoutethroughSinks();
203  sinkCount = WireIndex(routethroughSinks.getSize());
204  for(WireIndex k; k < sinkCount; k++) {
205  const WireIndex routethroughSink = routethroughSinks[k];
206  routethroughSourceCounts[routethroughSink]--;
207  const_cast<WireIndex&>(wires[routethroughSink]
208  .mRoutethroughSources[routethroughSourceCounts[routethroughSink]])
209  = WireIndex(j);
210  }
211  }
212 
213  // sort the ordered wire names
214  std::sort(
215  const_cast<Array<WireNameIndexPair>::iterator>(wireNameIndexPairs.begin()),
216  const_cast<Array<WireNameIndexPair>::iterator>(wireNameIndexPairs.end()),
218  );
219 
220  }
221 
222  // return the number of bytes read
223  return inStream.getBytesRead() - bytesReadOffset;
224  }
std::pair< std::string, xilinx::WireIndex > WireNameIndexPair
Wrapper for a wire name with corresponding wire index.
Definition: Tiles.hpp:56
static bool CompareWirePairByName(const WireNameIndexPair &inA, const WireNameIndexPair &inB)
Compare wire pairs by name, for ordering purposes.
Definition: Tiles.hpp:117
TileTypeCount mTileTypeCount
The number of tile types for this family.
Definition: Tiles.hpp:96
xilinx::TileTypeCount TileTypeCount
Imported type name.
Definition: Tiles.hpp:49
Array2D< const WireNameIndexPair > mOrderedWireNames
The wire name to wire index mapping for each tile type for this family.
Definition: Tiles.hpp:102
ostream & mOut(void)
Returns the database console output stream.
xilinx::WireCount WireCount
Imported type name.
Definition: Tiles.hpp:51
void setSize(uint32_t inSize)
Discards all contents and resizes the array.
Definition: Array.hpp:107
Array2D< const WireInfo > mWires
The wire information for this family.
Definition: Tiles.hpp:100
boost::uint16_t uint16_t
Imported type name.
Definition: Tiles.hpp:43
xilinx::WireIndex WireIndex
Imported type name.
Definition: Tiles.hpp:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::architecture::DDBConsoleStreams::setConsoleErr ( ostream inStream)
inlineinherited

Sets the database console error stream.

Definition at line 77 of file DDBConsoleStreams.hpp.

77 { mErrPtr = &inStream; }

+ Here is the caller graph for this function:

void torc::architecture::DDBConsoleStreams::setConsoleIn ( istream inStream)
inlineinherited

Sets the database console input stream.

Definition at line 73 of file DDBConsoleStreams.hpp.

73 { mInPtr = &inStream; }
istream * mInPtr
Pointer to the database console input stream.

+ Here is the caller graph for this function:

void torc::architecture::DDBConsoleStreams::setConsoleLog ( ostream inStream)
inlineinherited

Sets the database console log stream.

Definition at line 79 of file DDBConsoleStreams.hpp.

79 { mLogPtr = &inStream; }

+ Here is the caller graph for this function:

void torc::architecture::DDBConsoleStreams::setConsoleOut ( ostream inStream)
inlineinherited

Sets the database console output stream.

Definition at line 75 of file DDBConsoleStreams.hpp.

75 { mOutPtr = &inStream; }

+ Here is the caller graph for this function:

virtual void torc::architecture::DDBConsoleStreams::setConsoleStreams ( istream inIn,
ostream inOut,
ostream inErr,
ostream inLog 
)
inlinevirtualinherited

Sets all of the database console streams.

Parameters
inInThe console input stream.
inOutThe console output stream.
inErrThe console error stream.
inLogThe console log stream.

Reimplemented in torc::architecture::DDB.

Definition at line 85 of file DDBConsoleStreams.hpp.

86  {
87  setConsoleIn(inIn);
88  setConsoleOut(inOut);
89  setConsoleErr(inErr);
90  setConsoleLog(inLog);
91  }
void setConsoleOut(ostream &inStream)
Sets the database console output stream.
void setConsoleIn(istream &inStream)
Sets the database console input stream.
void setConsoleLog(ostream &inStream)
Sets the database console log stream.
void setConsoleErr(ostream &inStream)
Sets the database console error stream.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class DDB
friend

The database has access to our protected functions.

Definition at line 39 of file Tiles.hpp.

Field Documentation

TileCol torc::architecture::Tiles::mColCount
protected

The tile column count for this device.

Definition at line 88 of file Tiles.hpp.

ostream* torc::architecture::DDBConsoleStreams::mErrPtr
protectedinherited

Definition at line 96 of file DDBConsoleStreams.hpp.

istream* torc::architecture::DDBConsoleStreams::mInPtr
protectedinherited

Pointer to the database console input stream.

Definition at line 94 of file DDBConsoleStreams.hpp.

ostream* torc::architecture::DDBConsoleStreams::mLogPtr
protectedinherited

Definition at line 97 of file DDBConsoleStreams.hpp.

Array<const TileNameIndexPair> torc::architecture::Tiles::mOrderedTileNames
protected

The tile name to tile index mapping for this device.

Definition at line 94 of file Tiles.hpp.

Array2D<const WireNameIndexPair> torc::architecture::Tiles::mOrderedWireNames
protected

The wire name to wire index mapping for each tile type for this family.

Definition at line 102 of file Tiles.hpp.

ostream* torc::architecture::DDBConsoleStreams::mOutPtr
protectedinherited

Definition at line 95 of file DDBConsoleStreams.hpp.

TileRow torc::architecture::Tiles::mRowCount
protected

The tile row count for this device.

Definition at line 86 of file Tiles.hpp.

TileCount torc::architecture::Tiles::mTileCount
protected

The tile count for this device.

Definition at line 84 of file Tiles.hpp.

TileIndex** torc::architecture::Tiles::mTileMap
protected

The two-dimensional tile map for this device.

Definition at line 90 of file Tiles.hpp.

Array<const TileInfo> torc::architecture::Tiles::mTiles
protected

The tile information for this device.

Definition at line 92 of file Tiles.hpp.

TileTypeCount torc::architecture::Tiles::mTileTypeCount
protected

The number of tile types for this family.

Definition at line 96 of file Tiles.hpp.

Array<const CharStringWrapper> torc::architecture::Tiles::mTileTypeNames
protected

The tile type names for this family.

Definition at line 98 of file Tiles.hpp.

Array2D<const WireInfo> torc::architecture::Tiles::mWires
protected

The wire information for this family.

Definition at line 100 of file Tiles.hpp.

DDBConsoleStreams torc::architecture::DDBConsoleStreams::sDefaultConsoleStreams
staticinherited

Definition at line 45 of file DDBConsoleStreams.hpp.

DDBConsoleStreams torc::architecture::DDBConsoleStreams::sNullConsoleStreams
staticinherited

Definition at line 46 of file DDBConsoleStreams.hpp.


The documentation for this class was generated from the following files: