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

Xilinx bitstream base class. More...

#include <Bitstream.hpp>

+ Inheritance diagram for torc::bitstream::Bitstream:
+ Collaboration diagram for torc::bitstream::Bitstream:

Data Structures

struct  Subfield
 

Public Types

enum  { eBlockTypeCount = 8 }
 The block type count is fixed at eight across all Xilinx architectures. More...
 
enum  EBitstreamType { eBitstreamTypeFull, eBitstreamTypePartialActive, eBitstreamTypePartialShutdown }
 The bitstream type to generate. Use eBitstreamFull to fully reconfigure a device, eBitstreamTypePartialActive to partially reconfigure it while it continues to run, or eBitstreamTypePartialShutdown to partially recongifure it after shutting it down. More...
 
enum  EFrameInclude { eFrameIncludeOnlyDirtyFrames, eFrameIncludeAllUsedFrames }
 The frames to include in a partial bitstream. Use eFrameIncludeOnlyDirtyFrames to include only dirty frames, or eFrameStateAllUsedFrames to include all allocated frames, dirty or not. Note that if not all frames were allocated, eFrameStateAllUsedFrames is not the same as a full bitstream. More...
 
typedef std::string string
 Imported type name. More...
 
typedef boost::uint8_t uint8_t
 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 torc::common::EDevice EDevice
 Imported type name. More...
 
typedef std::map< std::string,
uint32_t
TileTypeNameToColumnType
 Mapping from tile type names to column types. More...
 
typedef std::map< uint16_t,
uint32_t
TileTypeIndexToColumnType
 Mapping from tile indexes to column types. More...
 

Public Member Functions

void write (std::ostream &inStream, uint8_t inVal)
 Write a uint8_t to the stream. More...
 
void write (std::ostream &inStream, uint16_t inVal)
 Write a uint16_t to the stream. More...
 
void write (std::ostream &inStream, uint32_t inVal)
 Write a uint32_t to the stream. More...
 
void writeHeaderString (std::ostream &inStream, const string &inString)
 Write a Xilinx-style header string to the stream. More...
 
void cleanDateAndTime (void)
 Clean up the header date and time by replacing embedded spaces with zeros. More...
 
virtual void initializeDeviceInfo (const std::string &inDeviceName)
 Initialize the maps between frame indexes and frame addresses. This is generally only useful for internal purposes. More...
 
virtual void initializeFrameMaps (void)
 Initialize the maps between frame indexes and frame addresses. This is generally only useful for internal purposes. More...
 
virtual void writeDeviceInfo (std::ostream &inStream, const std::string &inDeviceName)
 Output static device information to a stream. More...
 
void setDeviceInfo (const DeviceInfo &rhs)
 Assign static device information for the current bitstream. More...
 
void setDevice (const std::string &inDeviceName)
 Assign the device enumeration constant for the given device name. More...
 
 Bitstream (void)
 Basic constructor. More...
 
virtual ~Bitstream (void)
 Virtual destructor. More...
 
virtual void read (std::istream &inStream, bool inCleanDateAndTime=true)
 Read the bitstream header and packets from a stream. More...
 
virtual void readPackets (std::istream &inStream)
 Read the bitstream packets. More...
 
virtual void readHeader (std::istream &inStream)
 Read the bitstream header. More...
 
virtual void write (std::ostream &inStream)
 Write the bitstream header and packets to a stream. More...
 
virtual void preflightPackets (void)
 Preflight the packets. More...
 
virtual void updatePacketLength (void)
 Update the header packet length. More...
 
virtual void writePackets (std::ostream &inStream)
 Write the bitstream packets. More...
 
virtual void writeHeader (std::ostream &inStream)
 Write the bitstream header to the stream. More...
 
void setDesignName (const string &inDesignName)
 Set the design name. More...
 
void setDeviceName (const string &inDeviceName)
 Set the device name. More...
 
void setDesignDate (const string &inDesignDate)
 Set the design date. More...
 
void setDesignTime (const string &inDesignTime)
 Set the design time. More...
 
const stringgetDesignName (void) const
 Return the design name. More...
 
const stringgetDeviceName (void) const
 Return the device name. More...
 
const stringgetDesignDate (void) const
 Return the design date. More...
 
const stringgetDesignTime (void) const
 Return the design time. More...
 
uint32_t getBitstreamByteLength (void) const
 Return the bitstream packet length in bytes. More...
 
uint32_t getHeaderByteLength (void) const
 Return the bitstream header length in bytes. More...
 
virtual uint32_t getFrameLength (void) const
 Return the frame length for the current device. More...
 

Static Public Member Functions

static bool expect (std::istream &inStream, uint8_t inExpected)
 Look for the expected uint8_t in the stream and return true if it matches. More...
 
static bool expect (std::istream &inStream, uint16_t inExpected)
 Look for the expected uint16_t in the stream and return true if it matches. More...
 
static bool expect (std::istream &inStream, uint32_t inExpected)
 Look for the expected uint32_t in the stream and return true if it matches. More...
 
static void readHeaderString (std::istream &inStream, string &outString)
 Read and return a bitstream header string. More...
 
static bool readHeader (std::istream &inStream, string &outDesignName, string &outDeviceName, string &outDesignDate, string &outDesignTime, uint32_t &outBitstreamLength, uint32_t &outHeaderLength)
 Read a bitstream header, and return its fields. More...
 
static void writeSubfieldSettings (std::ostream &inStream, uint32_t inWord, const Subfield *inSubfields)
 Insert 32 bit subfield settings into an output stream. More...
 
static void writeSubfieldSettings (std::ostream &inStream, uint16_t inWord, const Subfield *inSubfields)
 Insert 16 bit subfield settings into an output stream. More...
 

Data Fields

EDevice mDevice
 Bitstream device enumeration. More...
 
string mDesignName
 Header design name. More...
 
string mDeviceName
 Header device name. More...
 
string mDesignDate
 Header design date. More...
 
string mDesignTime
 Header design time. More...
 
uint32_t mBitstreamByteLength
 Bitstream packet length in bytes. More...
 
uint32_t mHeaderByteLength
 Header length in bytes. More...
 
ColumnDefVector mColumnDefs
 Column type widths. More...
 
TileTypeNameToColumnType mTileTypeNameToColumnType
 
TileTypeIndexToColumnType mTileTypeIndexToColumnType
 
DeviceInfo mDeviceInfo
 Device information. More...
 

Friends

class torc::bitstream::bitstream::BitstreamUnitTest
 
std::ostream & operator<< (std::ostream &os, const Bitstream &rhs)
 Insert the bitstream header into an output stream. More...
 

Detailed Description

Xilinx bitstream base class.

Definition at line 40 of file bitstream/Bitstream.hpp.

Member Typedef Documentation

Imported type name.

Definition at line 64 of file bitstream/Bitstream.hpp.

Imported type name.

Todo:
Bitstream access needs to be changed from public back to protected.

Definition at line 60 of file bitstream/Bitstream.hpp.

Mapping from tile indexes to column types.

Definition at line 254 of file bitstream/Bitstream.hpp.

Mapping from tile type names to column types.

Definition at line 251 of file bitstream/Bitstream.hpp.

typedef boost::uint16_t torc::bitstream::Bitstream::uint16_t

Imported type name.

Definition at line 62 of file bitstream/Bitstream.hpp.

typedef boost::uint32_t torc::bitstream::Bitstream::uint32_t

Imported type name.

Definition at line 63 of file bitstream/Bitstream.hpp.

typedef boost::uint8_t torc::bitstream::Bitstream::uint8_t

Imported type name.

Definition at line 61 of file bitstream/Bitstream.hpp.

Member Enumeration Documentation

anonymous enum

The block type count is fixed at eight across all Xilinx architectures.

Enumerator
eBlockTypeCount 

Definition at line 44 of file bitstream/Bitstream.hpp.

The bitstream type to generate. Use eBitstreamFull to fully reconfigure a device, eBitstreamTypePartialActive to partially reconfigure it while it continues to run, or eBitstreamTypePartialShutdown to partially recongifure it after shutting it down.

Enumerator
eBitstreamTypeFull 
eBitstreamTypePartialActive 
eBitstreamTypePartialShutdown 

Definition at line 49 of file bitstream/Bitstream.hpp.

The frames to include in a partial bitstream. Use eFrameIncludeOnlyDirtyFrames to include only dirty frames, or eFrameStateAllUsedFrames to include all allocated frames, dirty or not. Note that if not all frames were allocated, eFrameStateAllUsedFrames is not the same as a full bitstream.

Enumerator
eFrameIncludeOnlyDirtyFrames 
eFrameIncludeAllUsedFrames 

Definition at line 56 of file bitstream/Bitstream.hpp.

Constructor & Destructor Documentation

torc::bitstream::Bitstream::Bitstream ( void  )
inline

Basic constructor.

Definition at line 261 of file bitstream/Bitstream.hpp.

EDevice mDevice
Bitstream device enumeration.
uint32_t mBitstreamByteLength
Bitstream packet length in bytes.
virtual torc::bitstream::Bitstream::~Bitstream ( void  )
inlinevirtual

Virtual destructor.

Definition at line 263 of file bitstream/Bitstream.hpp.

263 {}

Member Function Documentation

void torc::bitstream::Bitstream::cleanDateAndTime ( void  )
inline

Clean up the header date and time by replacing embedded spaces with zeros.

Definition at line 183 of file bitstream/Bitstream.hpp.

183  {
184  // some versions of the tools leave spaces inside the date and time fields
185  size_t pos = 0;
186  while((pos = mDesignDate.find(' ', pos)) != string::npos) mDesignDate[pos] = '0';
187  pos = 0;
188  while((pos = mDesignTime.find(' ', pos)) != string::npos) mDesignTime[pos] = '0';
189  }
string mDesignDate
Header design date.
string mDesignTime
Header design time.

+ Here is the caller graph for this function:

static bool torc::bitstream::Bitstream::expect ( std::istream &  inStream,
uint8_t  inExpected 
)
inlinestatic

Look for the expected uint8_t in the stream and return true if it matches.

Definition at line 89 of file bitstream/Bitstream.hpp.

89  {
90  // read the actual data from the stream
91  uint8_t actual = 0;
92  inStream.read((char*) &actual, sizeof(actual));
93  // return equality
94  return inExpected == actual;
95  }
boost::uint8_t uint8_t
Imported type name.

+ Here is the caller graph for this function:

static bool torc::bitstream::Bitstream::expect ( std::istream &  inStream,
uint16_t  inExpected 
)
inlinestatic

Look for the expected uint16_t in the stream and return true if it matches.

Definition at line 97 of file bitstream/Bitstream.hpp.

97  {
98  // read the actual data from the stream
99  uint16_t actual = 0;
100  inStream.read((char*) &actual, sizeof(actual));
101  // return equality
102  return inExpected == ntohs(actual);
103  }
boost::uint16_t uint16_t
Imported type name.
static bool torc::bitstream::Bitstream::expect ( std::istream &  inStream,
uint32_t  inExpected 
)
inlinestatic

Look for the expected uint32_t in the stream and return true if it matches.

Definition at line 105 of file bitstream/Bitstream.hpp.

105  {
106  // read the actual data from the stream
107  uint32_t actual = 0;
108  inStream.read((char*) &actual, sizeof(actual));
109  // return equality
110  return inExpected == ntohl(actual);
111  }
boost::uint32_t uint32_t
Imported type name.
uint32_t torc::bitstream::Bitstream::getBitstreamByteLength ( void  ) const
inline

Return the bitstream packet length in bytes.

The length includes all packet data, but does not include the bitstream header.

Definition at line 340 of file bitstream/Bitstream.hpp.

340 { return mBitstreamByteLength; }
uint32_t mBitstreamByteLength
Bitstream packet length in bytes.
const string& torc::bitstream::Bitstream::getDesignDate ( void  ) const
inline

Return the design date.

Definition at line 335 of file bitstream/Bitstream.hpp.

335 { return mDesignDate; }
string mDesignDate
Header design date.
const string& torc::bitstream::Bitstream::getDesignName ( void  ) const
inline

Return the design name.

Definition at line 331 of file bitstream/Bitstream.hpp.

331 { return mDesignName; }
string mDesignName
Header design name.
const string& torc::bitstream::Bitstream::getDesignTime ( void  ) const
inline

Return the design time.

Definition at line 337 of file bitstream/Bitstream.hpp.

337 { return mDesignTime; }
string mDesignTime
Header design time.
const string& torc::bitstream::Bitstream::getDeviceName ( void  ) const
inline

Return the device name.

Definition at line 333 of file bitstream/Bitstream.hpp.

333 { return mDeviceName; }
string mDeviceName
Header device name.

+ Here is the caller graph for this function:

virtual uint32_t torc::bitstream::Bitstream::getFrameLength ( void  ) const
inlinevirtual
uint32_t torc::bitstream::Bitstream::getHeaderByteLength ( void  ) const
inline

Return the bitstream header length in bytes.

Definition at line 342 of file bitstream/Bitstream.hpp.

342 { return mHeaderByteLength; }
uint32_t mHeaderByteLength
Header length in bytes.

+ Here is the caller graph for this function:

virtual void torc::bitstream::Bitstream::initializeDeviceInfo ( const std::string &  inDeviceName)
inlinevirtual

Initialize the maps between frame indexes and frame addresses. This is generally only useful for internal purposes.

Todo:
This function should be made pure virtual.

Reimplemented in torc::bitstream::Virtex7, torc::bitstream::Virtex6, torc::bitstream::Virtex5, torc::bitstream::Virtex4, torc::bitstream::Spartan3E, torc::bitstream::Virtex2, torc::bitstream::Virtex, torc::bitstream::Virtex2P, and torc::bitstream::VirtexE.

Definition at line 214 of file bitstream/Bitstream.hpp.

214 {}

+ Here is the caller graph for this function:

virtual void torc::bitstream::Bitstream::initializeFrameMaps ( void  )
inlinevirtual

Initialize the maps between frame indexes and frame addresses. This is generally only useful for internal purposes.

Reimplemented in torc::bitstream::Virtex7, torc::bitstream::Virtex6, torc::bitstream::Virtex5, torc::bitstream::Virtex4, torc::bitstream::Spartan3E, torc::bitstream::Virtex2, torc::bitstream::Virtex, and torc::bitstream::VirtexE.

Definition at line 217 of file bitstream/Bitstream.hpp.

217 {}
virtual void torc::bitstream::Bitstream::preflightPackets ( void  )
inlinevirtual

Preflight the packets.

Reimplemented in torc::bitstream::VirtexBitstream, torc::bitstream::Spartan6Bitstream, and torc::bitstream::SpartanBitstream.

Definition at line 287 of file bitstream/Bitstream.hpp.

287 {}

+ Here is the caller graph for this function:

virtual void torc::bitstream::Bitstream::read ( std::istream &  inStream,
bool  inCleanDateAndTime = true 
)
inlinevirtual

Read the bitstream header and packets from a stream.

Definition at line 266 of file bitstream/Bitstream.hpp.

266  {
267  readHeader(inStream);
268  readPackets(inStream);
269  if(inCleanDateAndTime) cleanDateAndTime();
270  }
static bool readHeader(std::istream &inStream, string &outDesignName, string &outDeviceName, string &outDesignDate, string &outDesignTime, uint32_t &outBitstreamLength, uint32_t &outHeaderLength)
Read a bitstream header, and return its fields.
void cleanDateAndTime(void)
Clean up the header date and time by replacing embedded spaces with zeros.
virtual void readPackets(std::istream &inStream)
Read the bitstream packets.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool torc::bitstream::Bitstream::readHeader ( std::istream &  inStream,
string outDesignName,
string outDeviceName,
string outDesignDate,
string outDesignTime,
uint32_t outBitstreamLength,
uint32_t outHeaderLength 
)
inlinestatic

Read a bitstream header, and return its fields.

Definition at line 142 of file bitstream/Bitstream.hpp.

144  {
145  // assume success unless we find otherwise
146  bool success = true;
147  // read the magic length
148  success &= expect(inStream, uint16_t(0x0009));
149  // read the magic bytes
150  success &= expect(inStream, uint32_t(0x0ff00ff0));
151  success &= expect(inStream, uint32_t(0x0ff00ff0));
152  success &= expect(inStream, uint8_t(0x00));
153  // read the mysterious 0x0001
154  success &= expect(inStream, uint16_t(0x0001));
155  // read the 'a' byte
156  success &= expect(inStream, uint8_t('a'));
157  // read the design name length
158  readHeaderString(inStream, outDesignName);
159  // read the 'b' byte
160  success &= expect(inStream, uint8_t('b'));
161  // read the device name length
162  readHeaderString(inStream, outDeviceName);
163  // read the 'c' byte
164  success &= expect(inStream, uint8_t('c'));
165  // read the design date length
166  readHeaderString(inStream, outDesignDate);
167  // read the 'd' byte
168  success &= expect(inStream, uint8_t('d'));
169  // read the design time length
170  readHeaderString(inStream, outDesignTime);
171  // read the 'e' byte
172  success &= expect(inStream, uint8_t('e'));
173  // read the inStream length
174  inStream.read((char*) &outBitstreamLength, sizeof(outBitstreamLength));
175  outBitstreamLength = ntohl(outBitstreamLength);
176  // determine the header length
177  outHeaderLength = 34 + outDesignName.length() + outDeviceName.length()
178  + outDesignDate.length() + outDesignTime.length();
179  // return the result
180  return success;
181  }
boost::uint8_t uint8_t
Imported type name.
static bool expect(std::istream &inStream, uint8_t inExpected)
Look for the expected uint8_t in the stream and return true if it matches.
boost::uint32_t uint32_t
Imported type name.
static void readHeaderString(std::istream &inStream, string &outString)
Read and return a bitstream header string.
boost::uint16_t uint16_t
Imported type name.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void torc::bitstream::Bitstream::readHeader ( std::istream &  inStream)
inlinevirtual

Read the bitstream header.

Definition at line 274 of file bitstream/Bitstream.hpp.

274  {
278  }
static bool readHeader(std::istream &inStream, string &outDesignName, string &outDeviceName, string &outDesignDate, string &outDesignTime, uint32_t &outBitstreamLength, uint32_t &outHeaderLength)
Read a bitstream header, and return its fields.
string mDesignDate
Header design date.
string mDesignTime
Header design time.
string mDesignName
Header design name.
string mDeviceName
Header device name.
uint32_t mBitstreamByteLength
Bitstream packet length in bytes.
void setDevice(const std::string &inDeviceName)
Assign the device enumeration constant for the given device name.
uint32_t mHeaderByteLength
Header length in bytes.

+ Here is the call graph for this function:

static void torc::bitstream::Bitstream::readHeaderString ( std::istream &  inStream,
string outString 
)
inlinestatic

Read and return a bitstream header string.

Definition at line 124 of file bitstream/Bitstream.hpp.

124  {
125  // read the string length
126  uint16_t length = 0;
127  inStream.read((char*) &length, sizeof(length));
128  length = ntohs(length);
129  if(length > 0) {
130  // create a buffer
131  char* buffer = new char[length];
132  // read the null-terminated string
133  inStream.read(buffer, length);
134  // copy the data into the string
135  outString.assign(buffer, length - 1);
136  delete[] buffer;
137  } else {
138  outString.clear();
139  }
140  }
boost::uint16_t uint16_t
Imported type name.

+ Here is the caller graph for this function:

virtual void torc::bitstream::Bitstream::readPackets ( std::istream &  inStream)
inlinevirtual

Read the bitstream packets.

Reimplemented in torc::bitstream::Virtex2, torc::bitstream::Spartan6Bitstream, torc::bitstream::VirtexBitstream, and torc::bitstream::SpartanBitstream.

Definition at line 272 of file bitstream/Bitstream.hpp.

272 {}

+ Here is the caller graph for this function:

void torc::bitstream::Bitstream::setDesignDate ( const string inDesignDate)
inline

Set the design date.

Definition at line 327 of file bitstream/Bitstream.hpp.

327 { mDesignDate = inDesignDate; }
string mDesignDate
Header design date.

+ Here is the caller graph for this function:

void torc::bitstream::Bitstream::setDesignName ( const string inDesignName)
inline

Set the design name.

Definition at line 323 of file bitstream/Bitstream.hpp.

323 { mDesignName = inDesignName; }
string mDesignName
Header design name.

+ Here is the caller graph for this function:

void torc::bitstream::Bitstream::setDesignTime ( const string inDesignTime)
inline

Set the design time.

Definition at line 329 of file bitstream/Bitstream.hpp.

329 { mDesignTime = inDesignTime; }
string mDesignTime
Header design time.

+ Here is the caller graph for this function:

void torc::bitstream::Bitstream::setDevice ( const std::string &  inDeviceName)
inline

Assign the device enumeration constant for the given device name.

Definition at line 225 of file bitstream/Bitstream.hpp.

225  {
227  }
static EDevice getDeviceEnum(const string &inName)
Returns the device enumeration corresponding to the given device name.
Definition: Devices.hpp:216
EDevice mDevice
Bitstream device enumeration.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::Bitstream::setDeviceInfo ( const DeviceInfo rhs)
inline

Assign static device information for the current bitstream.

Definition at line 223 of file bitstream/Bitstream.hpp.

223 { mDeviceInfo = rhs; }
DeviceInfo mDeviceInfo
Device information.

+ Here is the caller graph for this function:

void torc::bitstream::Bitstream::setDeviceName ( const string inDeviceName)
inline

Set the device name.

Definition at line 325 of file bitstream/Bitstream.hpp.

325 { mDeviceName = inDeviceName; }
string mDeviceName
Header device name.

+ Here is the caller graph for this function:

virtual void torc::bitstream::Bitstream::updatePacketLength ( void  )
inlinevirtual

Update the header packet length.

Reimplemented in torc::bitstream::VirtexBitstream, torc::bitstream::Spartan6Bitstream, and torc::bitstream::SpartanBitstream.

Definition at line 289 of file bitstream/Bitstream.hpp.

289 {}

+ Here is the caller graph for this function:

void torc::bitstream::Bitstream::write ( std::ostream &  inStream,
uint8_t  inVal 
)
inline

Write a uint8_t to the stream.

Definition at line 67 of file bitstream/Bitstream.hpp.

67  {
68  uint8_t actual = inVal;
69  inStream.write((char*) &actual, sizeof(actual));
70  }
boost::uint8_t uint8_t
Imported type name.

+ Here is the caller graph for this function:

void torc::bitstream::Bitstream::write ( std::ostream &  inStream,
uint16_t  inVal 
)
inline

Write a uint16_t to the stream.

Definition at line 72 of file bitstream/Bitstream.hpp.

72  {
73  uint16_t actual = htons(inVal);
74  inStream.write((char*) &actual, sizeof(actual));
75  }
boost::uint16_t uint16_t
Imported type name.
void torc::bitstream::Bitstream::write ( std::ostream &  inStream,
uint32_t  inVal 
)
inline

Write a uint32_t to the stream.

Definition at line 77 of file bitstream/Bitstream.hpp.

77  {
78  uint32_t actual = htonl(inVal);
79  inStream.write((char*) &actual, sizeof(actual));
80  }
boost::uint32_t uint32_t
Imported type name.
virtual void torc::bitstream::Bitstream::write ( std::ostream &  inStream)
inlinevirtual

Write the bitstream header and packets to a stream.

Definition at line 280 of file bitstream/Bitstream.hpp.

280  {
283  writeHeader(inStream);
284  writePackets(inStream);
285  }
virtual void updatePacketLength(void)
Update the header packet length.
virtual void preflightPackets(void)
Preflight the packets.
virtual void writeHeader(std::ostream &inStream)
Write the bitstream header to the stream.
virtual void writePackets(std::ostream &inStream)
Write the bitstream packets.

+ Here is the call graph for this function:

void torc::bitstream::Bitstream::writeDeviceInfo ( std::ostream &  inStream,
const std::string &  inDeviceName 
)
virtual

Output static device information to a stream.

This is used to generate the static column maps for bitstream frame mapping.

Definition at line 74 of file Bitstream.cpp.

75  {
76  // write the device column composition
77  inStream << "\t// " << inDeviceName << " static device information." << std::endl;
78  inStream << "\tboost::uint32_t " << inDeviceName << "Columns[] = { ";
79  ColumnTypeVector::const_iterator p = mDeviceInfo.getColumnTypes().begin();
80  ColumnTypeVector::const_iterator e = mDeviceInfo.getColumnTypes().end();
81  while(p < e) inStream << mColumnDefs[*p++].getName() << ", ";
82  inStream << "END };" << std::endl;
83  // instantiate the device information
84  inStream << "\tDeviceInfo " << inDeviceName << "(" << mDeviceInfo.getTileCount() << ", "
85  << mDeviceInfo.getRowCount() << ", " << mDeviceInfo.getColCount() << ", "
86  << inDeviceName << "Columns);" << std::endl;
87  }
ColumnDefVector mColumnDefs
Column type widths.
uint16_t getRowCount(void) const
Returns the row count.
Definition: DeviceInfo.hpp:112
uint16_t getColCount(void) const
Returns the column count.
Definition: DeviceInfo.hpp:114
DeviceInfo mDeviceInfo
Device information.
const ColumnTypeVector & getColumnTypes(void) const
Returns the column type vector.
Definition: DeviceInfo.hpp:116
uint32_t getTileCount(void) const
Returns the tile count.
Definition: DeviceInfo.hpp:110

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void torc::bitstream::Bitstream::writeHeader ( std::ostream &  inStream)
inlinevirtual

Write the bitstream header to the stream.

Definition at line 293 of file bitstream/Bitstream.hpp.

293  {
294  // write the magic length
295  write(inStream, uint16_t(0x0009));
296  // write the magic bytes with null termination
297  write(inStream, uint32_t(0x0ff00ff0));
298  write(inStream, uint32_t(0x0ff00ff0));
299  write(inStream, uint8_t(0x00));
300  // write the mysterious 0x0001
301  write(inStream, uint16_t(0x0001));
302  // write the 'a' byte and the design name
303  write(inStream, uint8_t('a'));
304  writeHeaderString(inStream, mDesignName);
305  // write the 'b' byte and the device name
306  write(inStream, uint8_t('b'));
307  writeHeaderString(inStream, mDeviceName);
308  // write the 'c' byte and the design date
309  write(inStream, uint8_t('c'));
310  writeHeaderString(inStream, mDesignDate);
311  // write the 'd' byte and the design time
312  write(inStream, uint8_t('d'));
313  writeHeaderString(inStream, mDesignTime);
314  // write the 'e' byte and the design name
315  write(inStream, uint8_t('e'));
316  write(inStream, uint32_t(mBitstreamByteLength));
317  }
void writeHeaderString(std::ostream &inStream, const string &inString)
Write a Xilinx-style header string to the stream.
string mDesignDate
Header design date.
string mDesignTime
Header design time.
string mDesignName
Header design name.
boost::uint8_t uint8_t
Imported type name.
boost::uint32_t uint32_t
Imported type name.
string mDeviceName
Header device name.
uint32_t mBitstreamByteLength
Bitstream packet length in bytes.
void write(std::ostream &inStream, uint8_t inVal)
Write a uint8_t to the stream.
boost::uint16_t uint16_t
Imported type name.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::Bitstream::writeHeaderString ( std::ostream &  inStream,
const string inString 
)
inline

Write a Xilinx-style header string to the stream.

Definition at line 82 of file bitstream/Bitstream.hpp.

82  {
83  // write the string length
84  uint16_t length = inString.length() + 1;
85  write(inStream, uint16_t(length));
86  inStream.write(inString.c_str(), length);
87  }
void write(std::ostream &inStream, uint8_t inVal)
Write a uint8_t to the stream.
boost::uint16_t uint16_t
Imported type name.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void torc::bitstream::Bitstream::writePackets ( std::ostream &  inStream)
inlinevirtual

Write the bitstream packets.

Reimplemented in torc::bitstream::Spartan6Bitstream, torc::bitstream::VirtexBitstream, and torc::bitstream::SpartanBitstream.

Definition at line 291 of file bitstream/Bitstream.hpp.

291 {}

+ Here is the caller graph for this function:

void torc::bitstream::Bitstream::writeSubfieldSettings ( std::ostream &  inStream,
uint32_t  inWord,
const Subfield inSubfields 
)
static

Insert 32 bit subfield settings into an output stream.

Definition at line 26 of file Bitstream.cpp.

27  {
28  // count the subfields
29  int subfieldCount = 0;
30  while(inSubfields[subfieldCount].mMask) subfieldCount++;
31  // generate the output
32  inStream << " (";
33  for(int index = subfieldCount; index > 0; index--) {
34  uint32_t field = index - 1;
35  const Subfield& subfield = inSubfields[field];
36  uint32_t value = (inWord & subfield.mMask) >> subfield.mShift;
37  inStream << (*subfield.mBitgenName == 0 ? subfield.mConfigGuideName
38  : subfield.mBitgenName) << ":";
39  const char** ptr = subfield.mValues;
40  for(uint32_t i = 0; ; i++) {
41  if(*ptr == 0) { inStream << "[UNKNOWN " << i << "]"; break; }
42  if(value == i) { inStream << *ptr; break; }
43  ptr++;
44  }
45  if(index > 1) inStream << ", ";
46  }
47  inStream << ")";
48  }
boost::uint32_t uint32_t
Imported type name.

+ Here is the caller graph for this function:

void torc::bitstream::Bitstream::writeSubfieldSettings ( std::ostream &  inStream,
uint16_t  inWord,
const Subfield inSubfields 
)
static

Insert 16 bit subfield settings into an output stream.

Definition at line 50 of file Bitstream.cpp.

51  {
52  // count the subfields
53  int subfieldCount = 0;
54  while(inSubfields[subfieldCount].mMask) subfieldCount++;
55  // generate the output
56  inStream << " (";
57  for(int index = subfieldCount; index > 0; index--) {
58  uint16_t field = index - 1;
59  const Subfield& subfield = inSubfields[field];
60  uint16_t value = (inWord & subfield.mMask) >> subfield.mShift;
61  inStream << (*subfield.mBitgenName == 0 ? subfield.mConfigGuideName
62  : subfield.mBitgenName) << ":";
63  const char** ptr = subfield.mValues;
64  for(uint16_t i = 0; ; i++) {
65  if(*ptr == 0) { inStream << "[UNKNOWN " << i << "]"; break; }
66  if(value == i) { inStream << *ptr; break; }
67  ptr++;
68  }
69  if(index > 1) inStream << ", ";
70  }
71  inStream << ")";
72  }
boost::uint16_t uint16_t
Imported type name.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Bitstream rhs 
)
friend

Insert the bitstream header into an output stream.

Definition at line 49 of file bitstream/OutputStreamHelpers.cpp.

49  {
50  // dispatch the various architectures
51  if(typeid(rhs) == typeid(Virtex)) {
52  os << dynamic_cast<const Virtex&>(rhs);
53  } else if(typeid(rhs) == typeid(VirtexE)) {
54  os << dynamic_cast<const VirtexE&>(rhs);
55  } else if(typeid(rhs) == typeid(Virtex2)) {
56  os << dynamic_cast<const Virtex2&>(rhs);
57  } else if(typeid(rhs) == typeid(Virtex2P)) {
58  os << dynamic_cast<const Virtex2P&>(rhs);
59  } else if(typeid(rhs) == typeid(Virtex4)) {
60  os << dynamic_cast<const Virtex4&>(rhs);
61  } else if(typeid(rhs) == typeid(Virtex5)) {
62  os << dynamic_cast<const Virtex5&>(rhs);
63  } else if(typeid(rhs) == typeid(Virtex6)) {
64  os << dynamic_cast<const Virtex6&>(rhs);
65  } else if(typeid(rhs) == typeid(Virtex7)) {
66  os << dynamic_cast<const Virtex7&>(rhs);
67  } else if(typeid(rhs) == typeid(Spartan3E)) {
68  os << dynamic_cast<const Spartan3E&>(rhs);
69  } else if(typeid(rhs) == typeid(Spartan6)) {
70  os << dynamic_cast<const Spartan6&>(rhs);
71 
72  // handle the generic bitstream header
73  } else {
74  os << "Design " << rhs.mDesignName << " (" << rhs.mDeviceName << ") @ "
75  << rhs.mDesignDate << " " << rhs.mDesignTime << ": " << rhs.mBitstreamByteLength
76  << " bytes (" << (rhs.mBitstreamByteLength >> 2) << " words)";
77  }
78  return os;
79  }
friend class torc::bitstream::bitstream::BitstreamUnitTest
friend

Definition at line 41 of file bitstream/Bitstream.hpp.

Field Documentation

uint32_t torc::bitstream::Bitstream::mBitstreamByteLength

Bitstream packet length in bytes.

This is the length in bytes of all the bitstream packets, without the bitstream header.

Definition at line 242 of file bitstream/Bitstream.hpp.

ColumnDefVector torc::bitstream::Bitstream::mColumnDefs

Column type widths.

Definition at line 249 of file bitstream/Bitstream.hpp.

string torc::bitstream::Bitstream::mDesignDate

Header design date.

Definition at line 236 of file bitstream/Bitstream.hpp.

string torc::bitstream::Bitstream::mDesignName

Header design name.

Definition at line 232 of file bitstream/Bitstream.hpp.

string torc::bitstream::Bitstream::mDesignTime

Header design time.

Definition at line 238 of file bitstream/Bitstream.hpp.

EDevice torc::bitstream::Bitstream::mDevice

Bitstream device enumeration.

Definition at line 230 of file bitstream/Bitstream.hpp.

DeviceInfo torc::bitstream::Bitstream::mDeviceInfo

Device information.

Definition at line 257 of file bitstream/Bitstream.hpp.

string torc::bitstream::Bitstream::mDeviceName

Header device name.

Definition at line 234 of file bitstream/Bitstream.hpp.

uint32_t torc::bitstream::Bitstream::mHeaderByteLength

Header length in bytes.

This is the length of the header itself, as opposed to mBitstreamByteLength, which is the length of bitstream reported by the header.

Definition at line 246 of file bitstream/Bitstream.hpp.

TileTypeIndexToColumnType torc::bitstream::Bitstream::mTileTypeIndexToColumnType

Definition at line 255 of file bitstream/Bitstream.hpp.

TileTypeNameToColumnType torc::bitstream::Bitstream::mTileTypeNameToColumnType

Definition at line 252 of file bitstream/Bitstream.hpp.


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