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

Spartan-class bitstream. More...

#include <Spartan6Bitstream.hpp>

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

Data Structures

struct  CRC
 CRC class for the Spartan6 architecture. More...
 

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 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 = 0xe000, ePacketShiftType = 13, ePacketMaskOpcode = 0x1800, ePacketShiftOpcode = 11,
  ePacketMaskTypeAddress = 0x07e0, ePacketShiftTypeAddress = 5, ePacketMaskType1Count = 0x001f, ePacketShiftType1Count = 0,
  ePacketMaskType2Count0 = 0xffff, ePacketShiftType2Count0 = 0, ePacketMaskType2Count1 = 0xffff, ePacketShiftType2Count1 = 0
}
 Packet subfields. More...
 
enum  ESynchronization {
  eSynchronizationDummy = 0xffff, eSynchronizationSync0 = 0xaa99, eSynchronizationSync1 = 0x5566, eSynchronizationBusWidthSync0 = 0x0000,
  eSynchronizationBusWidthSync1 = 0x00bb, eSynchronizationBusWidthDetect0 = 0x1122, eSynchronizationBusWidthDetect1 = 0x0044
}
 Synchronization words. More...
 

Public Member Functions

 Spartan6Bitstream (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::uint16_t uint16_t
 Imported type name. More...
 
typedef boost::uint32_t uint32_t
 

Friends

class torc::bitstream::bitstream::Spartan6BitstreamUnitTest
 

Detailed Description

Spartan-class bitstream.

Definition at line 32 of file Spartan6Bitstream.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::Spartan6Bitstream::uint16_t
protected

Imported type name.

Definition at line 38 of file Spartan6Bitstream.hpp.

typedef boost::uint32_t torc::bitstream::Spartan6Bitstream::uint32_t
protected

Definition at line 39 of file Spartan6Bitstream.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: UG380, v2.2, July 30, 2010, Table 5-24
type 2 packet format: UG380, v2.2, July 30, 2010, Table 5-26
type 2 packet format: UG380, v2.2, July 30, 2010, Table 5-27
Enumerator
ePacketMaskType 
ePacketShiftType 
ePacketMaskOpcode 
ePacketShiftOpcode 
ePacketMaskTypeAddress 
ePacketShiftTypeAddress 
ePacketMaskType1Count 
ePacketShiftType1Count 
ePacketMaskType2Count0 
ePacketShiftType2Count0 
ePacketMaskType2Count1 
ePacketShiftType2Count1 

Definition at line 49 of file Spartan6Packet.hpp.

49  {
50  // generic packet subfields
51  ePacketMaskType = 0xe000, ePacketShiftType = 13,
54  // type 1 packet subfields
56  // type 2 packet subfields
59  };

Packet type enumeration.

See Also
packet type: UG380, v2.2, July 30, 2010, Table 5-24, 5-26
Enumerator
ePacketType1 
ePacketType2 
ePacketTypeCount 

Definition at line 40 of file Spartan6Packet.hpp.

Constructor & Destructor Documentation

torc::bitstream::Spartan6Bitstream::Spartan6Bitstream ( void  )
inline

Basic constructor.

Definition at line 87 of file Spartan6Bitstream.hpp.

87 : Bitstream(), Spartan6PacketVector(), Spartan6PacketConstants() {}
std::vector< Spartan6Packet > Spartan6PacketVector
Vector of Spartan 16 bit 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::Spartan6Bitstream::preflightPackets ( void  )
virtual

Preflight the packets.

Reimplemented from torc::bitstream::Bitstream.

Definition at line 53 of file Spartan6Bitstream.cpp.

53  {
54  // determine which architecture this is
55  DeviceDesignator deviceDesignator(getDeviceName());
56  DeviceDesignator::EFamily family = deviceDesignator.getFamily();
57  // set up family-specific variables
58  uint32_t crcRegister = 0;
59  uint32_t cmdRegister = 0;
60  uint32_t fdriRegister = 0;
61  uint32_t rcrcCommand = 0;
62  uint32_t addressLength = 0;
63  bool autoCrc = false;
64  switch(family) {
66  cmdRegister = Spartan6::eRegisterCMD; rcrcCommand = Spartan6::eCommandRCRC;
67  fdriRegister = Spartan6::eRegisterFDRI; crcRegister = Spartan6::eRegisterCRC;
68  /*addressLength = 6*/ (void) addressLength; autoCrc = true;
69  break;
70  default:
71  std::cerr << "Unsupported architecture in Spartan6Bitstream::preflightPackets()."
72  << std::endl;
73  break;
74  }
75  // begin CRC calculation: calculation is derived from one of the following simulation files:
76  // ISE/verilog/src/unisims/SIM_CONFIG_S6.v
77  // ISE/vhdl/src/unisims/primitive/SIM_CONFIG_S6.vhd
78  CRC crc;
79  iterator p = begin();
80  iterator e = end();
81  while(p < e) {
82  // look up the current packet
83  const Spartan6Packet& packet = *p++;
84  // only process write packets with non-zero payload length
85  if(!packet.isWrite()) continue;
86  uint32_t address = packet.getAddress();
87  uint32_t wordCount = packet.getWordCount();
88  if(wordCount == 0) continue;
89  // CRC register write (this is what compares the expected and supplied CRC values)
90  if(address == crcRegister) {
91  //printf("Expected CRC16: %8.8x\n", uint32_t(packet[1]) << 16 | packet[2]);
92  //printf("Calculated CRC16: %8.8x\n", uint32_t(crc));
93  *(p-1) = Spartan6Packet::makeType1Write32(crcRegister, crc);
94  crc.reset();
95  // reset CRC command
96  } else if(address == cmdRegister && wordCount >= 1 && packet[1] == rcrcCommand) {
97  crc.reset();
98  // registers that are omitted from CRC calculation
99  } else if(address == Spartan6::eRegisterBOOSTS || address == Spartan6::eRegisterSTAT
100  || address == Spartan6::eRegisterLOUT || address == Spartan6::eRegisterCSBO
101  || address == Spartan6::eRegisterRDBK_SIGN || address == Spartan6::eRegisterFDRO) {
102  // process packet contents
103  } else {
104  for(uint32_t i = 1; i <= wordCount; i++) {
105  uint32_t word = packet[i];
106  //printf("Address: %4.4x\n", address);
107  //printf("Word: %8.8x\n", word);
108  crc.update(address, word);
109  // debugging output
110  //for(int32_t c = sizeof(crc_curr) - 1; c >= 0; c--) printf("%d", crc_curr[c]);
111  //printf("\n");
112  }
113  // process the Auto CRC
114  if(autoCrc && address == fdriRegister) {
115  //printf("Expected Auto CRC16: %8.8x\n", (uint32_t((*p)[0]) << 16) | (*p)[1]);
116  //printf("Calculated Auto CRC16: %8.8x\n", uint32_t(crc));
117  // current packet is FDRI, next is Auto CRC
118  *p = Spartan6Packet(crc >> 16, crc & 0xffff);
119  // unlike the Spartan3E, the CRC is not reset after an Auto CRC
120  //crc.reset();
121  }
122  }
123  }
124  }
Encapsulation of a device designator and its constituent elements.
const string & getDeviceName(void) const
Return the device name.
static Spartan6Packet makeType1Write32(uint16_t inAddress, uint32_t inWord)
Construct a type 1 write packet for two words.

+ 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::Spartan6Bitstream::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 Spartan6Bitstream.cpp.

27  {
28  uint16_t bitstreamWordLength = mBitstreamByteLength >> 1;
29  uint16_t cumulativeWordLength = 0;
30  while(cumulativeWordLength < bitstreamWordLength) {
31  push_back(Spartan6Packet::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  uint16_t autoCrcHi = 0;
37  uint16_t autoCrcLo = 0;
38  inStream.read((char*) &autoCrcHi, sizeof(autoCrcHi));
39  inStream.read((char*) &autoCrcLo, sizeof(autoCrcLo));
40  autoCrcHi = ntohs(autoCrcHi);
41  autoCrcLo = ntohs(autoCrcLo);
42  push_back(Spartan6Packet(autoCrcHi, autoCrcLo));
43  cumulativeWordLength += 2;
44  }
45  }
boost::uint16_t uint16_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 Spartan6Packet 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::Spartan6Bitstream::updatePacketLength ( void  )
virtual

Update the header packet length.

Reimplemented from torc::bitstream::Bitstream.

Definition at line 126 of file Spartan6Bitstream.cpp.

126  {
127  uint32_t totalWordCount = 0;
128  iterator p = begin();
129  iterator e = end();
130  while(p < e) totalWordCount += (p++)->getWordSize();
131  mBitstreamByteLength = totalWordCount << 1;
132  }
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::Spartan6Bitstream::writePackets ( std::ostream &  inStream)
virtual

Write bitstream packets to a stream.

Reimplemented from torc::bitstream::Bitstream.

Definition at line 47 of file Spartan6Bitstream.cpp.

47  {
48  const_iterator p = begin();
49  const_iterator e = end();
50  while(p < e) p++->write(inStream);
51  }
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::Spartan6BitstreamUnitTest
friend

Definition at line 34 of file Spartan6Bitstream.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: