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

Spartan-class bitstream. More...

#include <SpartanBitstream.hpp>

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

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 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...
 
enum  EPacketType { ePacketType1 = 1, ePacketType2, ePacketTypeCount = 8 }
 Packet type enumeration. More...
 
enum  EOpcode {
  eOpcodeNOP = 0, eOpcodeRead, eOpcodeWrite, eOpcodeReserved,
  eOpcodeCount
}
 Packet opcode enumeration. More...
 
enum  EPacket {
  ePacketMaskType = 0xe0000000, ePacketShiftType = 29, ePacketMaskOpcode = 0x18000000, ePacketShiftOpcode = 27,
  ePacketMaskType1Address = 0x07ffe000, ePacketShiftType1Address = 13, ePacketMaskType1Reserved = 0x00001800, ePacketShiftType1Reserved = 11,
  ePacketMaskType1Count = 0x000007ff, ePacketShiftType1Count = 0, ePacketMaskType2Count = 0x07ffffff, ePacketShiftType2Count = 0
}
 Packet subfields. More...
 
enum  ESynchronization { eSynchronizationDummy = 0xffffffff, eSynchronizationSync = 0xaa995566, eSynchronizationBusWidthSync = 0x000000bb, eSynchronizationBusWidthDetect = 0x11220044 }
 Synchronization words. More...
 

Public Member Functions

 SpartanBitstream (void)
 Basic constructor. More...
 
virtual void readPackets (std::istream &inStream)
 Read bitstream packets from a stream. More...
 
virtual void writePackets (std::ostream &inStream)
 Write bitstream packets to a stream. More...
 
virtual void preflightPackets (void)
 Preflight the packets. More...
 
virtual void updatePacketLength (void)
 Update the header packet length. More...
 
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...
 
virtual void write (std::ostream &inStream)
 Write the bitstream header and packets to a stream. More...
 
void writeHeaderString (std::ostream &inStream, const string &inString)
 Write a Xilinx-style header string to the stream. More...
 
virtual void readHeader (std::istream &inStream)
 Read the bitstream header. 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...
 
virtual void read (std::istream &inStream, bool inCleanDateAndTime=true)
 Read the bitstream header and packets from a stream. 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...
 

Protected Types

typedef boost::uint32_t uint32_t
 Imported type name. More...
 

Friends

class torc::bitstream::bitstream::SpartanBitstreamUnitTest
 

Detailed Description

Spartan-class bitstream.

Definition at line 32 of file SpartanBitstream.hpp.

Member Typedef Documentation

Imported type name.

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

typedef std::string torc::bitstream::Bitstream::string
inherited

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.

typedef std::map<std::string, uint32_t> torc::bitstream::Bitstream::TileTypeNameToColumnType
inherited

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
inherited

Imported type name.

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

typedef boost::uint32_t torc::bitstream::SpartanBitstream::uint32_t
protected

Imported type name.

Definition at line 38 of file SpartanBitstream.hpp.

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

Imported type name.

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

Member Enumeration Documentation

anonymous enum
inherited

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.

Packet subfields.

See Also
type 1 packet format: XAPP452, v1.1, June 25, 2008, Figure 6.
type 2 packet format: XAPP452, v1.1, June 25, 2008, Figure 7.
Enumerator
ePacketMaskType 
ePacketShiftType 
ePacketMaskOpcode 
ePacketShiftOpcode 
ePacketMaskType1Address 
ePacketShiftType1Address 
ePacketMaskType1Reserved 
ePacketShiftType1Reserved 
ePacketMaskType1Count 
ePacketShiftType1Count 
ePacketMaskType2Count 
ePacketShiftType2Count 

Definition at line 46 of file SpartanPacket.hpp.

46  {
47  // generic packet subfields
48  ePacketMaskType = 0xe0000000, ePacketShiftType = 29,
49  ePacketMaskOpcode = 0x18000000, ePacketShiftOpcode = 27,
50  // type 1 packet subfields
54  // type 2 packet subfields
56  };

Packet type enumeration.

See Also
packet type: XAPP452, v1.1, June 25, 2008, Figure 6, 7.
Enumerator
ePacketType1 
ePacketType2 
ePacketTypeCount 

Definition at line 39 of file SpartanPacket.hpp.

Synchronization words.

See Also
Configuration Sequence: XAPP452, v1.1, June 25, 2008, Table 9.
Enumerator
eSynchronizationDummy 
eSynchronizationSync 
eSynchronizationBusWidthSync 
eSynchronizationBusWidthDetect 

Definition at line 60 of file SpartanPacket.hpp.

Constructor & Destructor Documentation

torc::bitstream::SpartanBitstream::SpartanBitstream ( void  )
inline

Basic constructor.

Definition at line 43 of file SpartanBitstream.hpp.

43 : Bitstream(), SpartanPacketVector(), SpartanPacketConstants() {}
std::vector< SpartanPacket > SpartanPacketVector
Vector of Spartan packets.
Bitstream(void)
Basic constructor.

Member Function Documentation

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

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 
)
inlinestaticinherited

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 
)
inlinestaticinherited

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 
)
inlinestaticinherited

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
inlineinherited

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
inlineinherited

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
inlineinherited

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
inlineinherited

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
inlineinherited

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
inlinevirtualinherited
uint32_t torc::bitstream::Bitstream::getHeaderByteLength ( void  ) const
inlineinherited

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)
inlinevirtualinherited

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  )
inlinevirtualinherited

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 {}
void torc::bitstream::SpartanBitstream::preflightPackets ( void  )
virtual

Preflight the packets.

Reimplemented from torc::bitstream::Bitstream.

Definition at line 50 of file SpartanBitstream.cpp.

50  {
51  // determine which architecture this is
52  DeviceDesignator deviceDesignator(getDeviceName());
53  DeviceDesignator::EFamily family = deviceDesignator.getFamily();
54  // set up family-specific variables
55  uint32_t crcRegister = 0;
56  uint32_t cmdRegister = 0;
57  uint32_t fdriRegister = 0;
58  uint32_t rcrcCommand = 0;
59  uint32_t addressLength = 0;
60  bool autoCrc = false;
61  switch(family) {
63  cmdRegister = Spartan3E::eRegisterCMD; rcrcCommand = Spartan3E::eCommandRCRC;
64  fdriRegister = Spartan3E::eRegisterFDRI; crcRegister = Spartan3E::eRegisterCRC;
65  addressLength = 5; autoCrc = true;
66  break;
67  default:
68  std::cerr << "Unsupported architecture in SpartanBitstream::preflightPackets()."
69  << std::endl;
70  break;
71  }
72  // begin CRC calculation
73  uint32_t address = 0;
74  iterator p = begin();
75  iterator e = end();
76  // CRC-16-IBM polynomial for Spartan3/6 and Virtex/E/2/2P families
77  boost::crc_basic<16> crc16(0x8005, 0, 0, false, true);
78  while(p < e) {
79  // look up the current packet
80  const SpartanPacket& packet = *p++;
81  // only process write packets with non-zero payload length
82  if(!packet.isWrite()) continue;
83  if(packet.isType1()) address = packet.getAddress();
84  uint32_t wordCount = packet.getWordCount();
85  if(wordCount == 0) continue;
86  // CRC register write (this is what compares the expected and supplied CRC values)
87  if(address == crcRegister) {
88  //printf("Expected CRC16: %4.4x\n", packet[1]);
89  //printf("Calculated CRC16: %4.4x\n", crc16.checksum());
90  *(p-1) = SpartanPacket::makeType1Write(crcRegister, crc16.checksum());
91  crc16.reset();
92  // reset CRC command
93  } else if(address == cmdRegister && wordCount >= 1 && packet[1] == rcrcCommand) {
94  crc16.reset();
95  // process packet contents
96  } else {
97  uint32_t j;
98  uint32_t mask;
99  for(uint32_t i = 1; i <= wordCount; i++) {
100  uint32_t word = packet[i];
101  //printf("Address: %4.4x\n", address);
102  //printf("Word: %8.8x\n", word);
103  for(j = 0, mask = 1; j < 32; j++, mask <<= 1) {
104  crc16.process_bit((word & mask) ? 1 : 0);
105  }
106  for(j = 0, mask = 1; j < addressLength; j++, mask <<= 1) {
107  crc16.process_bit((address & mask) ? 1 : 0);
108  }
109  }
110  // process the Auto CRC
111  if(autoCrc && address == fdriRegister) {
112  //printf("Expected Auto CRC16: %4.4x\n", (*p)[0]);
113  //printf("Calculated Auto CRC16: %4.4x\n", crc16.checksum());
114  *p = SpartanPacket(crc16.checksum()); // current word is FDRI, next is Auto CRC
115  crc16.reset();
116  }
117  }
118  }
119  }
Encapsulation of a device designator and its constituent elements.
const string & getDeviceName(void) const
Return the device name.
boost::uint32_t uint32_t
Imported type name.
static SpartanPacket makeType1Write(uint32_t inAddress, uint32_t inWord)
Construct a type 1 write packet.

+ Here is the call graph for this function:

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

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 
)
inlinestaticinherited

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)
inlinevirtualinherited

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 
)
inlinestaticinherited

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:

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

Read bitstream packets from a stream.

Note
This function should be called after the bitstream header has been read.

Reimplemented from torc::bitstream::Bitstream.

Definition at line 27 of file SpartanBitstream.cpp.

27  {
28  uint32_t bitstreamWordLength = mBitstreamByteLength >> 2;
29  uint32_t cumulativeWordLength = 0;
30  while(cumulativeWordLength < bitstreamWordLength) {
31  push_back(SpartanPacket::read(inStream));
32  uint32_t wordSize = back().getWordSize();
33  cumulativeWordLength += wordSize;
34  // infer Auto CRCs for writes equal to or longer than one frame (not rigorously correct)
35  if(wordSize <= getFrameLength()) continue;
36  uint32_t autoCrc = 0;
37  inStream.read((char*) &autoCrc, sizeof(autoCrc));
38  autoCrc = ntohl(autoCrc);
39  push_back(SpartanPacket(autoCrc));
40  cumulativeWordLength++;
41  }
42  }
boost::uint32_t uint32_t
Imported type name.
uint32_t mBitstreamByteLength
Bitstream packet length in bytes.
virtual uint32_t getFrameLength(void) const
Return the frame length for the current device.
static SpartanPacket read(std::istream &inStream)
Read a packet.
void torc::bitstream::Bitstream::setDesignDate ( const string inDesignDate)
inlineinherited

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)
inlineinherited

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)
inlineinherited

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)
inlineinherited

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)
inlineinherited

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)
inlineinherited

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:

void torc::bitstream::SpartanBitstream::updatePacketLength ( void  )
virtual

Update the header packet length.

Reimplemented from torc::bitstream::Bitstream.

Definition at line 121 of file SpartanBitstream.cpp.

121  {
122  uint32_t totalWordCount = 0;
123  iterator p = begin();
124  iterator e = end();
125  while(p < e) totalWordCount += (p++)->getWordSize();
126  mBitstreamByteLength = totalWordCount << 2;
127  }
boost::uint32_t uint32_t
Imported type name.
uint32_t mBitstreamByteLength
Bitstream packet length in bytes.
void torc::bitstream::Bitstream::write ( std::ostream &  inStream,
uint8_t  inVal 
)
inlineinherited

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 
)
inlineinherited

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 
)
inlineinherited

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)
inlinevirtualinherited

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 
)
virtualinherited

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)
inlinevirtualinherited

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 
)
inlineinherited

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:

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

Write bitstream packets to a stream.

Reimplemented from torc::bitstream::Bitstream.

Definition at line 44 of file SpartanBitstream.cpp.

44  {
45  const_iterator p = begin();
46  const_iterator e = end();
47  while(p < e) p++->write(inStream);
48  }
void torc::bitstream::Bitstream::writeSubfieldSettings ( std::ostream &  inStream,
uint32_t  inWord,
const Subfield inSubfields 
)
staticinherited

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 
)
staticinherited

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

friend class torc::bitstream::bitstream::SpartanBitstreamUnitTest
friend

Definition at line 34 of file SpartanBitstream.hpp.

Field Documentation

uint32_t torc::bitstream::Bitstream::mBitstreamByteLength
inherited

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
inherited

Column type widths.

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

string torc::bitstream::Bitstream::mDesignDate
inherited

Header design date.

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

string torc::bitstream::Bitstream::mDesignName
inherited

Header design name.

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

string torc::bitstream::Bitstream::mDesignTime
inherited

Header design time.

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

EDevice torc::bitstream::Bitstream::mDevice
inherited

Bitstream device enumeration.

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

DeviceInfo torc::bitstream::Bitstream::mDeviceInfo
inherited

Device information.

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

string torc::bitstream::Bitstream::mDeviceName
inherited

Header device name.

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

uint32_t torc::bitstream::Bitstream::mHeaderByteLength
inherited

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
inherited

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

TileTypeNameToColumnType torc::bitstream::Bitstream::mTileTypeNameToColumnType
inherited

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


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