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

Encapsulation the design arc usage. More...

#include <ArcUsage.hpp>

+ Collaboration diagram for torc::architecture::ArcUsage:

Public Member Functions

 ArcUsage (const Tiles &inTiles)
 Public constructor. More...
 
 ~ArcUsage (void)
 Non-virtual destructor. More...
 
void autosize (void)
 Size the wire usage according to the number of device tiles. More...
 
void use (const Arc &inArc)
 Marks the specified arc as being used. More...
 
void use (const Tilewire &inTilewire1, const Tilewire &inTilewire2)
 Marks the specified arc as being used. More...
 
void release (const Arc &inArc)
 Marks the specified arc as being unused. More...
 
void release (const Tilewire &inTilewire1, const Tilewire &inTilewire2)
 Marks the specified arc as being unused. More...
 
void clear (void)
 Marks all arcs as being unused, without releasing the bitset objects. More...
 
bool isUsed (const Arc &inArc)
 Determines whether the specified arc is in use. More...
 
bool isUsed (const Tilewire &inTilewire1, const Tilewire &inTilewire2) const
 Determines whether the specified arc is in use. More...
 
uint32_t getArcUsageCount (void) const
 Returns the number of arcs in use. More...
 
TileCount getTileUsageCount (void) const
 Returns the number of tiles that have been touched. More...
 
uint32_t getBitCount (void) const
 Returns the number of bits allocated. More...
 

Protected Types

typedef boost::dynamic_bitset dynamic_bitset
 Imported type name. More...
 
typedef xilinx::TileIndex TileIndex
 Imported type name. More...
 
typedef xilinx::TileCount TileCount
 Imported type name. More...
 
typedef xilinx::TileTypeIndex TileTypeIndex
 Imported type name. More...
 
typedef xilinx::WireIndex WireIndex
 Imported type name. More...
 

Protected Member Functions

uint32_t getArcOffset (const Tilewire &inTilewire1, const Tilewire &inTilewire2) const
 Returns the offset into the bitset for the specified arc. More...
 

Protected Attributes

const TilesmTiles
 Reference to the database Tiles object. More...
 
TileCount mTileUsageCount
 The number of tiles for which bitsets are allocated. More...
 
Array< dynamic_bitset * > mBitsets
 The wire usage bitset array. More...
 
uint32_t mBitCount
 The number of bits allocated by the usage bitsets. More...
 
dynamic_bitset mTileDirty
 The mask of tile bitsets that contain changes. More...
 

Friends

class torc::architecture::architecture::ArcUsageUnitTest
 Our unit test class has access to our internals. More...
 

Detailed Description

Encapsulation the design arc usage.

This class uses a compact bitset representation to very efficiently track the arc usage of a design in an entire device. Internal bitset objects are maintained on a per-tile basis, and are not allocated until at least one arc in the tile has been marked used.

Definition at line 38 of file ArcUsage.hpp.

Member Typedef Documentation

typedef boost::dynamic_bitset torc::architecture::ArcUsage::dynamic_bitset
protected

Imported type name.

Definition at line 43 of file ArcUsage.hpp.

Imported type name.

Definition at line 45 of file ArcUsage.hpp.

Imported type name.

Definition at line 44 of file ArcUsage.hpp.

Imported type name.

Definition at line 46 of file ArcUsage.hpp.

Imported type name.

Definition at line 47 of file ArcUsage.hpp.

Constructor & Destructor Documentation

torc::architecture::ArcUsage::ArcUsage ( const Tiles inTiles)
inline

Public constructor.

Definition at line 109 of file ArcUsage.hpp.

109  : mTiles(inTiles), mTileUsageCount(), mBitsets(0),
110  mBitCount(0), mTileDirty(0) {}
const Tiles & mTiles
Reference to the database Tiles object.
Definition: ArcUsage.hpp:50
Array< dynamic_bitset * > mBitsets
The wire usage bitset array.
Definition: ArcUsage.hpp:54
uint32_t mBitCount
The number of bits allocated by the usage bitsets.
Definition: ArcUsage.hpp:56
dynamic_bitset mTileDirty
The mask of tile bitsets that contain changes.
Definition: ArcUsage.hpp:58
TileCount mTileUsageCount
The number of tiles for which bitsets are allocated.
Definition: ArcUsage.hpp:52
torc::architecture::ArcUsage::~ArcUsage ( void  )
inline

Non-virtual destructor.

Definition at line 112 of file ArcUsage.hpp.

112  {
113  size_t tileCount = mBitsets.getSize();
114  for(TileIndex i; i < tileCount; i++) {
115  if(mBitsets[i] != 0) { delete mBitsets[i]; mBitsets[i] = 0; }
116  }
117  }
xilinx::TileIndex TileIndex
Imported type name.
Definition: ArcUsage.hpp:44
Array< dynamic_bitset * > mBitsets
The wire usage bitset array.
Definition: ArcUsage.hpp:54
uint32_t getSize(void) const
Returns the array size.
Definition: Array.hpp:104

+ Here is the call graph for this function:

Member Function Documentation

void torc::architecture::ArcUsage::autosize ( void  )
inline

Size the wire usage according to the number of device tiles.

Definition at line 120 of file ArcUsage.hpp.

120  {
121  // release any existing bitsets
122  for(TileCount i; i < mBitsets.getSize(); i++) {
123  if(mBitsets[i] != 0) { delete mBitsets[i]; mBitsets[i] = 0; }
124  mTileDirty.reset(i);
125  }
126  // resize for the new dimensions
127  TileCount tileCount = mTiles.getTileCount();
128  mBitsets.setSize(tileCount);
129  for(TileCount i; i < tileCount; i++) mBitsets[i] = 0;
130  mTileDirty.resize(tileCount);
131  }
const Tiles & mTiles
Reference to the database Tiles object.
Definition: ArcUsage.hpp:50
Array< dynamic_bitset * > mBitsets
The wire usage bitset array.
Definition: ArcUsage.hpp:54
TileCount getTileCount(void) const
Returns the tile count for this device.
Definition: Tiles.hpp:149
xilinx::TileCount TileCount
Imported type name.
Definition: ArcUsage.hpp:45
dynamic_bitset mTileDirty
The mask of tile bitsets that contain changes.
Definition: ArcUsage.hpp:58
void setSize(uint32_t inSize)
Discards all contents and resizes the array.
Definition: Array.hpp:107
uint32_t getSize(void) const
Returns the array size.
Definition: Array.hpp:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::architecture::ArcUsage::clear ( void  )
inline

Marks all arcs as being unused, without releasing the bitset objects.

This capability allows the tracer to track the wires that it has visited while processing a particular net, and then to start again from scratch without incurring allocation and construction overheads.

Definition at line 192 of file ArcUsage.hpp.

192  {
193  // iterate over all of the tiles
194  size_t tileCount = mBitsets.getSize();
195  for(TileIndex i; i < tileCount; i++) {
196  // skip this tile if it isn't dirty
197  if(!mTileDirty[i]) continue;
198  // mark the tile clean
199  mTileDirty.reset(i);
200  // look up the bitset for this tile
201  dynamic_bitset* bitset = mBitsets[i];
202  // skip tiles without an associated bitset (should never happen for dirty tiles)
203  if(bitset == 0) continue;
204  // clear the entire bitset
205  bitset->reset();
206  }
207  }
xilinx::TileIndex TileIndex
Imported type name.
Definition: ArcUsage.hpp:44
Array< dynamic_bitset * > mBitsets
The wire usage bitset array.
Definition: ArcUsage.hpp:54
dynamic_bitset mTileDirty
The mask of tile bitsets that contain changes.
Definition: ArcUsage.hpp:58
boost::dynamic_bitset dynamic_bitset
Imported type name.
Definition: ArcUsage.hpp:43
uint32_t getSize(void) const
Returns the array size.
Definition: Array.hpp:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32_t torc::architecture::ArcUsage::getArcOffset ( const Tilewire inTilewire1,
const Tilewire inTilewire2 
) const
inlineprotected

Returns the offset into the bitset for the specified arc.

Note
The ordering of regular, irregular, routethrough, and tied sinks does not matter as long as it is consistent. The only impact comes from the likelihood of access for the different types, where more common ones ought to be visited first.
Todo:
Throw a meaningful exception.

Definition at line 64 of file ArcUsage.hpp.

64  {
65  // first make sure the arc is defined
66  if(inTilewire1.isUndefined() || inTilewire2.isUndefined())
67  throw InvalidArcException(Arc(inTilewire1, inTilewire2));
68  // look up the relevant tile and wire indexes
69  TileIndex tile1 = inTilewire1.getTileIndex();
70  WireIndex wire1 = inTilewire1.getWireIndex();
71  WireIndex wire2 = inTilewire2.getWireIndex();
72  // determine the tile type
73  const TileInfo& tileInfo = mTiles.getTileInfo(tile1);
74  TileTypeIndex type = tileInfo.getTypeIndex();
75  // next get the wire's base arc offset
76  const WireInfo& wireInfo = mTiles.getWireInfo(type, wire1);
77  uint32_t offset = wireInfo.getArcOffset();
78  // look for a regular sink
79  const WireArray& sinks = wireInfo.getSinks();
80  for(WireIndex i; i < sinks.getSize(); i++) {
81  if(sinks[i] == wire2) return offset;
82  offset++;
83  }
84  // look for an irregular sink
85  const WireArray& irregularSinks = wireInfo.getIrregularSinks();
86  for(WireIndex i; i < irregularSinks.getSize(); i++) {
87  if(irregularSinks[i] == wire2) return offset;
88  offset++;
89  }
90  // look for a routethrough sink
91  const WireArray& routethroughSinks = wireInfo.getRoutethroughSinks();
92  for(WireIndex i; i < routethroughSinks.getSize(); i++) {
93  if(routethroughSinks[i] == wire2) return offset;
94  offset++;
95  }
96  // look for a tied sink
97  const WireArray& tiedSinks = wireInfo.getTiedSinks();
98  for(WireIndex i; i < tiedSinks.getSize(); i++) {
99  if(tiedSinks[i] == wire2) return offset;
100  offset++;
101  }
102  // if we didn't find the sink in the regular or irregular arcs, the call failed
103  /// \todo Throw a meaningful exception.
104  throw InvalidArcException(Arc(inTilewire1, inTilewire2));
105  }
xilinx::TileIndex TileIndex
Imported type name.
Definition: ArcUsage.hpp:44
const Tiles & mTiles
Reference to the database Tiles object.
Definition: ArcUsage.hpp:50
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
const Array< const WireInfo > & getWireInfo(TileTypeIndex inTileTypeIndex) const
Returns the WireInfo array for the specified tile type.
Definition: Tiles.hpp:140
xilinx::WireIndex WireIndex
Imported type name.
Definition: ArcUsage.hpp:47
xilinx::TileTypeIndex TileTypeIndex
Imported type name.
Definition: ArcUsage.hpp:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32_t torc::architecture::ArcUsage::getArcUsageCount ( void  ) const
inline

Returns the number of arcs in use.

Todo:
Question: can we get away with only checking dirty bitsets? / skip this tile if it isn't dirty

Definition at line 228 of file ArcUsage.hpp.

228  {
229  uint32_t usageCount = 0;
230  size_t tileCount = mBitsets.getSize();
231  for(TileIndex i; i < tileCount; i++) {
232  /// \todo Question: can we get away with only checking dirty bitsets?
233  //// skip this tile if it isn't dirty
234  //if(!mTileDirty[i]) continue;
235  // look up the bitset for this tile
236  dynamic_bitset* bitset = mBitsets[i];
237  // skip tiles without an associated bitset
238  if(bitset == 0) continue;
239  // clear the entire bitset
240  usageCount += bitset->count();
241  }
242  return usageCount;
243  }
xilinx::TileIndex TileIndex
Imported type name.
Definition: ArcUsage.hpp:44
Array< dynamic_bitset * > mBitsets
The wire usage bitset array.
Definition: ArcUsage.hpp:54
boost::dynamic_bitset dynamic_bitset
Imported type name.
Definition: ArcUsage.hpp:43
uint32_t getSize(void) const
Returns the array size.
Definition: Array.hpp:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32_t torc::architecture::ArcUsage::getBitCount ( void  ) const
inline

Returns the number of bits allocated.

Definition at line 248 of file ArcUsage.hpp.

248 { return mBitCount; }
uint32_t mBitCount
The number of bits allocated by the usage bitsets.
Definition: ArcUsage.hpp:56

+ Here is the caller graph for this function:

TileCount torc::architecture::ArcUsage::getTileUsageCount ( void  ) const
inline

Returns the number of tiles that have been touched.

Definition at line 246 of file ArcUsage.hpp.

246 { return mTileUsageCount; }
TileCount mTileUsageCount
The number of tiles for which bitsets are allocated.
Definition: ArcUsage.hpp:52

+ Here is the caller graph for this function:

bool torc::architecture::ArcUsage::isUsed ( const Arc inArc)
inline

Determines whether the specified arc is in use.

Definition at line 209 of file ArcUsage.hpp.

210  { return isUsed(inArc.getSourceTilewire(), inArc.getSinkTilewire()); }
bool isUsed(const Arc &inArc)
Determines whether the specified arc is in use.
Definition: ArcUsage.hpp:209

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool torc::architecture::ArcUsage::isUsed ( const Tilewire inTilewire1,
const Tilewire inTilewire2 
) const
inline

Determines whether the specified arc is in use.

Todo:
Throw a meaningful exception.

Definition at line 212 of file ArcUsage.hpp.

212  {
213  // extract the tile indexes
214  TileIndex tileIndex1 = inTilewire1.getTileIndex();
215  TileIndex tileIndex2 = inTilewire2.getTileIndex();
216  // ensure that these tilewires belong to the same tile
217  /// \todo Throw a meaningful exception.
218  if(tileIndex1 != tileIndex2) throw -1;
219 
220  // if there is no entry for the tile, the tilewire is already implicitly unused.
221  dynamic_bitset* bitset = mBitsets[tileIndex1];
222  if(bitset == 0) return false;
223 
224  // otherwise, interrogate the bit
225  return bitset->test(getArcOffset(inTilewire1, inTilewire2));
226  }
xilinx::TileIndex TileIndex
Imported type name.
Definition: ArcUsage.hpp:44
Array< dynamic_bitset * > mBitsets
The wire usage bitset array.
Definition: ArcUsage.hpp:54
uint32_t getArcOffset(const Tilewire &inTilewire1, const Tilewire &inTilewire2) const
Returns the offset into the bitset for the specified arc.
Definition: ArcUsage.hpp:64
boost::dynamic_bitset dynamic_bitset
Imported type name.
Definition: ArcUsage.hpp:43

+ Here is the call graph for this function:

void torc::architecture::ArcUsage::release ( const Arc inArc)
inline

Marks the specified arc as being unused.

Definition at line 169 of file ArcUsage.hpp.

170  { release(inArc.getSourceTilewire(), inArc.getSinkTilewire()); }
void release(const Arc &inArc)
Marks the specified arc as being unused.
Definition: ArcUsage.hpp:169

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::architecture::ArcUsage::release ( const Tilewire inTilewire1,
const Tilewire inTilewire2 
)
inline

Marks the specified arc as being unused.

Todo:
Throw a meaningful exception.

Definition at line 172 of file ArcUsage.hpp.

172  {
173  // extract the tile indexes
174  TileIndex tileIndex1 = inTilewire1.getTileIndex();
175  TileIndex tileIndex2 = inTilewire2.getTileIndex();
176  // ensure that these tilewires belong to the same tile
177  /// \todo Throw a meaningful exception.
178  if(tileIndex1 != tileIndex2) throw -1;
179 
180  // if there is no entry for the tile, the arc is already implicitly unused.
181  dynamic_bitset* bitset = mBitsets[tileIndex1];
182  if(bitset == 0) return;
183 
184  // otherwise clear the bit and mark the tile dirty
185  bitset->set(getArcOffset(inTilewire1, inTilewire2), false);
186  mTileDirty.set(tileIndex1, true);
187  }
xilinx::TileIndex TileIndex
Imported type name.
Definition: ArcUsage.hpp:44
Array< dynamic_bitset * > mBitsets
The wire usage bitset array.
Definition: ArcUsage.hpp:54
uint32_t getArcOffset(const Tilewire &inTilewire1, const Tilewire &inTilewire2) const
Returns the offset into the bitset for the specified arc.
Definition: ArcUsage.hpp:64
dynamic_bitset mTileDirty
The mask of tile bitsets that contain changes.
Definition: ArcUsage.hpp:58
boost::dynamic_bitset dynamic_bitset
Imported type name.
Definition: ArcUsage.hpp:43

+ Here is the call graph for this function:

void torc::architecture::ArcUsage::use ( const Arc inArc)
inline

Marks the specified arc as being used.

Definition at line 133 of file ArcUsage.hpp.

134  { use(inArc.getSourceTilewire(), inArc.getSinkTilewire()); }
void use(const Arc &inArc)
Marks the specified arc as being used.
Definition: ArcUsage.hpp:133

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::architecture::ArcUsage::use ( const Tilewire inTilewire1,
const Tilewire inTilewire2 
)
inline

Marks the specified arc as being used.

Todo:
Throw a meaningful exception.

Definition at line 136 of file ArcUsage.hpp.

136  {
137  // extract the tile indexes
138  TileIndex tileIndex1 = inTilewire1.getTileIndex();
139  TileIndex tileIndex2 = inTilewire2.getTileIndex();
140  // ensure that these tilewires belong to the same tile
141  /// \todo Throw a meaningful exception.
142  if(tileIndex1 != tileIndex2) throw InvalidArcException(Arc(inTilewire1, inTilewire2));
143 
144  // make sure we have a bitset for this tile
145  dynamic_bitset* bitset = mBitsets[tileIndex1];
146  if(bitset == 0) {
147  // determine how many arcs are in this tile
148  const TileInfo& tileInfo = mTiles.getTileInfo(tileIndex1);
149  TileTypeIndex type = tileInfo.getTypeIndex();
150  const Array<const WireInfo>& wires = mTiles.getWireInfo(type);
151  if(wires.getSize() == 0) return;
152  const WireInfo& wireInfo = mTiles.getWireInfo(type, WireIndex(wires.getSize() - 1));
153  // caution: we have to add the regular and irregular sink count from the last wire
154  size_t size = wireInfo.getArcOffset() + wireInfo.getSinks().getSize()
155  + wireInfo.getIrregularSinks().getSize()
156  + wireInfo.getRoutethroughSinks().getSize()
157  + wireInfo.getTiedSinks().getSize();
158  bitset = mBitsets[tileIndex1] = new dynamic_bitset(size);
159  // track the statistics
160  mTileUsageCount++;
161  mBitCount += size;
162  }
163 
164  // set the bit and mark the tile dirty
165  bitset->set(getArcOffset(inTilewire1, inTilewire2));
166  mTileDirty.set(tileIndex1, true);
167  }
xilinx::TileIndex TileIndex
Imported type name.
Definition: ArcUsage.hpp:44
const Tiles & mTiles
Reference to the database Tiles object.
Definition: ArcUsage.hpp:50
Array< dynamic_bitset * > mBitsets
The wire usage bitset array.
Definition: ArcUsage.hpp:54
uint32_t mBitCount
The number of bits allocated by the usage bitsets.
Definition: ArcUsage.hpp:56
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
uint32_t getArcOffset(const Tilewire &inTilewire1, const Tilewire &inTilewire2) const
Returns the offset into the bitset for the specified arc.
Definition: ArcUsage.hpp:64
const Array< const WireInfo > & getWireInfo(TileTypeIndex inTileTypeIndex) const
Returns the WireInfo array for the specified tile type.
Definition: Tiles.hpp:140
xilinx::WireIndex WireIndex
Imported type name.
Definition: ArcUsage.hpp:47
dynamic_bitset mTileDirty
The mask of tile bitsets that contain changes.
Definition: ArcUsage.hpp:58
xilinx::TileTypeIndex TileTypeIndex
Imported type name.
Definition: ArcUsage.hpp:46
boost::dynamic_bitset dynamic_bitset
Imported type name.
Definition: ArcUsage.hpp:43
TileCount mTileUsageCount
The number of tiles for which bitsets are allocated.
Definition: ArcUsage.hpp:52

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend class torc::architecture::architecture::ArcUsageUnitTest
friend

Our unit test class has access to our internals.

Definition at line 40 of file ArcUsage.hpp.

Field Documentation

uint32_t torc::architecture::ArcUsage::mBitCount
protected

The number of bits allocated by the usage bitsets.

Definition at line 56 of file ArcUsage.hpp.

Array<dynamic_bitset*> torc::architecture::ArcUsage::mBitsets
protected

The wire usage bitset array.

Definition at line 54 of file ArcUsage.hpp.

dynamic_bitset torc::architecture::ArcUsage::mTileDirty
protected

The mask of tile bitsets that contain changes.

Definition at line 58 of file ArcUsage.hpp.

const Tiles& torc::architecture::ArcUsage::mTiles
protected

Reference to the database Tiles object.

Definition at line 50 of file ArcUsage.hpp.

TileCount torc::architecture::ArcUsage::mTileUsageCount
protected

The number of tiles for which bitsets are allocated.

Definition at line 52 of file ArcUsage.hpp.


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