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

Spartan3E bitstream. More...

#include <Spartan3E.hpp>

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

Data Structures

class  FrameAddress
 

Public Types

enum  ERegister {
  eRegisterCRC = 0, eRegisterFAR, eRegisterFDRI, eRegisterFDRO,
  eRegisterCMD, eRegisterCTL, eRegisterMASK, eRegisterSTAT,
  eRegisterLOUT, eRegisterCOR, eRegisterMFWR, eRegisterFLR,
  eRegisterIDCODE = 14, eRegisterCount
}
 Configuration register enumeration. More...
 
enum  ECommand {
  eCommandNULL = 0, eCommandWCFG, eCommandMFWR, eCommandLFRM,
  eCommandRCFG, eCommandSTART, eCommandRCAP, eCommandRCRC,
  eCommandAGHIGH, eCommandSWITCH, eCommandGRESTORE, eCommandSHUTDOWN,
  eCommandGCAPTURE, eCommandDESYNCH, eCommandCount
}
 Configuration command enumeration for eRegisterCMD. More...
 
enum  EFar {
  eFarMaskColumn = 0x06000000, eFarShiftColumn = 25, eFarMaskMajor = 0x01fe0000, eFarShiftMajor = 17,
  eFarMaskMinor = 0x0001fe00, eFarShiftMinor = 9
}
 Frame Address Register subfields. More...
 
enum  EFarTopBottom { eFarTop = 0, eFarBottom = 1 }
 Frame Address Register top and bottom constants. More...
 
enum  EFarBlockType {
  eFarBlockType0 = 0, eFarBlockType1, eFarBlockType2, eFarBlockType3,
  eFarBlockType4, eFarBlockType5, eFarBlockType6, eFarBlockType7,
  eFarBlockTypeCount
}
 Frame Address Register block type constants. More...
 
enum  EColumnType {
  eColumnTypeEmpty = 0, eColumnTypeBram, eColumnTypeBramInt, eColumnTypeClb,
  eColumnTypeClock, eColumnTypeClockLL, eColumnTypeTerm, eColumnTypeIob,
  eColumnTypeCount
}
 Major column types. More...
 
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

 Spartan3E (void)
 Basic constructor. More...
 
virtual void initializeDeviceInfo (const std::string &inDeviceName)
 Initialize the device information. More...
 
virtual void initializeFrameMaps (void)
 Initialize the maps between frame indexes and frame addresses. This is generally only useful for internal purposes. More...
 
virtual uint32_t getFrameLength (void) const
 
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 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...
 

Static Public Member Functions

static uint32_t makeSubfield (ERegister inRegister, const std::string &inSubfield, const std::string &inSetting)
 Return the masked value for a subfield of the specified register. More...
 
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...
 
typedef std::map< uint32_t,
Spartan3E::FrameAddress
FrameIndexToAddress
 Map from frame index to frame address. More...
 
typedef std::map
< Spartan3E::FrameAddress,
uint32_t
FrameAddressToIndex
 Map from frame address to frame index. More...
 
typedef std::vector< uint32_tColumnIndexVector
 Array of vectors to store frame indexes of each block type. More...
 

Protected Attributes

FrameIndexToAddress mFrameIndexToAddress
 Map of frame indexes to frame addresses. More...
 
FrameAddressToIndex mFrameAddressToIndex
 Map of frame addressee to frame indexes. More...
 
ColumnIndexVector mBitColumnIndexes [Spartan3E::eFarBlockTypeCount]
 Vector to store frame indexes of XDL columns. More...
 
ColumnIndexVector mXdlColumnIndexes [Spartan3E::eFarBlockTypeCount]
 Vector to store frame indexes of Bitstream columns. More...
 

Static Protected Attributes

static const char * sPacketTypeName [ePacketTypeCount]
 Packet type names. More...
 
static const char * sOpcodeName [eOpcodeCount]
 Packet opcode names. More...
 
static const char * sRegisterName [eRegisterCount]
 Configuration register names. More...
 
static const char * sCommandName [eCommandCount]
 Configuration command names. More...
 
static const Subfield sCOR []
 Configuration Options Register (COR) subfields. More...
 
static const Subfield sSTAT []
 Status Register (STAT) subfields. More...
 
static const Subfield sCTL []
 Control Register (CTL) subfields. More...
 
static const Subfield sMASK []
 Control Mask Register (MASK) subfields. More...
 

Friends

class torc::bitstream::bitstream::Spartan3EUnitTest
 
class torc::bitstream::bitstream::Spartan3EFarUnitTest
 
void torc::bitstream::bitstream::testSpartan3EDevice (const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
 
std::ostream & operator<< (std::ostream &os, const Spartan3E &rhs)
 Insert the bitstream header into an output stream. More...
 

Detailed Description

Spartan3E bitstream.

Definition at line 38 of file Spartan3E.hpp.

Member Typedef Documentation

Array of vectors to store frame indexes of each block type.

Definition at line 189 of file Spartan3E.hpp.

Imported type name.

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

Map from frame address to frame index.

Definition at line 187 of file Spartan3E.hpp.

Map from frame index to frame address.

Definition at line 185 of file Spartan3E.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::Spartan3E::uint32_t
protected

Imported type name.

Definition at line 46 of file Spartan3E.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.

Major column types.

These are defined and used for internal purposes only, and are not derived from any Xilinx documentation.

Enumerator
eColumnTypeEmpty 
eColumnTypeBram 
eColumnTypeBramInt 
eColumnTypeClb 
eColumnTypeClock 
eColumnTypeClockLL 
eColumnTypeTerm 
eColumnTypeIob 
eColumnTypeCount 

Definition at line 78 of file Spartan3E.hpp.

Configuration command enumeration for eRegisterCMD.

See Also
CMD register commands: XAPP452, v1.1, June 25, 2008, Table 2.
Enumerator
eCommandNULL 
eCommandWCFG 
eCommandMFWR 
eCommandLFRM 
eCommandRCFG 
eCommandSTART 
eCommandRCAP 
eCommandRCRC 
eCommandAGHIGH 
eCommandSWITCH 
eCommandGRESTORE 
eCommandSHUTDOWN 
eCommandGCAPTURE 
eCommandDESYNCH 
eCommandCount 

Definition at line 58 of file Spartan3E.hpp.

Frame Address Register subfields.

See Also
Frame Address Register Description: XAPP452, v1.1, June 25, 2008, Figure 2.
Enumerator
eFarMaskColumn 
eFarShiftColumn 
eFarMaskMajor 
eFarShiftMajor 
eFarMaskMinor 
eFarShiftMinor 

Definition at line 64 of file Spartan3E.hpp.

Frame Address Register top and bottom constants.

Enumerator
eFarTop 
eFarBottom 

Definition at line 71 of file Spartan3E.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.

Configuration register enumeration.

See Also
configuration registers: XAPP452, v1.1, June 25, 2008, Table 1.
Enumerator
eRegisterCRC 
eRegisterFAR 
eRegisterFDRI 
eRegisterFDRO 
eRegisterCMD 
eRegisterCTL 
eRegisterMASK 
eRegisterSTAT 
eRegisterLOUT 
eRegisterCOR 
eRegisterMFWR 
eRegisterFLR 
eRegisterIDCODE 
eRegisterCount 

Definition at line 52 of file Spartan3E.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::Spartan3E::Spartan3E ( void  )
inline

Basic constructor.

Definition at line 103 of file Spartan3E.hpp.

103  : SpartanBitstream() {
104 // for(int i = 0; i < eRegisterCount; i++) mRegister[i] = 0;
105  // initialize the column type widths for this family
107  mColumnDefs[eColumnTypeEmpty] = ColumnDef("Empty", 0, 0, 0, 0, 0, 0, 0, 0);
108  mColumnDefs[eColumnTypeBram] = ColumnDef("Bram", 0, 76, 0, 0, 0, 0, 0, 0);
109  mColumnDefs[eColumnTypeBramInt] = ColumnDef("BramInt", 0, 0, 19, 0, 0, 0, 0, 0);
110  mColumnDefs[eColumnTypeClb] = ColumnDef("Clb", 19, 0, 0, 0, 0, 0, 0, 0);
111  mColumnDefs[eColumnTypeClock] = ColumnDef("Clock", 3, 0, 0, 0, 0, 0, 0, 0);
112  mColumnDefs[eColumnTypeClockLL] = ColumnDef("ClockLL", 4, 0, 0, 0, 0, 0, 0, 0);
113  mColumnDefs[eColumnTypeIob] = ColumnDef("Iob", 19, 0, 0, 0, 0, 0, 0, 0);
114  mColumnDefs[eColumnTypeTerm] = ColumnDef("Term", 2, 0, 0, 0, 0, 0, 0, 0);
115  // map type type names to column types
118  mTileTypeNameToColumnType["CENTER_SMALL"] = eColumnTypeClb;
125  }
ColumnDefVector mColumnDefs
Column type widths.
TileTypeNameToColumnType mTileTypeNameToColumnType
SpartanBitstream(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::Spartan3E::getFrameLength ( void  ) const
inlinevirtual

Reimplemented from torc::bitstream::Bitstream.

Definition at line 170 of file Spartan3E.hpp.

170  {
171  using namespace torc::common;
172  // lengths obtained directly from bitstream Frame Length Register
173  switch(mDevice) {
174  case eXC3S100E: return 49;
175  case eXC3S250E: return 73;
176  case eXC3S500E: return 97;
177  case eXC3S1200E: return 125;
178  case eXC3S1600E: return 157;
179  default: return 0;
180  }
181  }
EDevice mDevice
Bitstream device enumeration.
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:

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

Initialize the device information.

Reimplemented from torc::bitstream::Bitstream.

Definition at line 218 of file Spartan3E.cpp.

218  {
219  using namespace torc::common;
220  switch(mDevice) {
221  case eXC3S100E: setDeviceInfo(xc3s100e); break;
222  case eXC3S250E: setDeviceInfo(xc3s250e); break;
223  case eXC3S500E: setDeviceInfo(xc3s500e); break;
224  case eXC3S1200E: setDeviceInfo(xc3s1200e); break;
225  case eXC3S1600E: setDeviceInfo(xc3s1600e); break;
226  default: break;
227  }
228  }
EDevice mDevice
Bitstream device enumeration.
DeviceInfo xc3s1200e
DeviceInfo xc3s100e
DeviceInfo xc3s500e
DeviceInfo xc3s1600e
void setDeviceInfo(const DeviceInfo &rhs)
Assign static device information for the current bitstream.
DeviceInfo xc3s250e

+ Here is the call graph for this function:

void torc::bitstream::Spartan3E::initializeFrameMaps ( void  )
virtual

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

Reimplemented from torc::bitstream::Bitstream.

Definition at line 313 of file Spartan3E.cpp.

313  {
314 
315  uint32_t frameCount = 0;
316  uint32_t frameIndex = 0;
317  bool clockColumn = true;
318  uint32_t width;
319  for(uint32_t i = 0; i < Spartan3E::eFarBlockTypeCount; i++) {
321  //Set first frame index to 0
322  uint32_t bitIndex = 0;
323  uint32_t xdlIndex = 0;
324  mBitColumnIndexes[i].push_back(bitIndex);
325  mXdlColumnIndexes[i].push_back(xdlIndex);
326  // build the columns
327  uint32_t farMajor = 0;
329  if(clockColumn) {
330  if(mDeviceInfo.getColCount() > 41)
331  width = mColumnDefs[eColumnTypeClockLL][i];
332  else
333  width = mColumnDefs[eColumnTypeClock][i];
334  clockColumn = false;
335  for(uint32_t farMinor = 0; farMinor < width; farMinor++) {
336  Spartan3E::FrameAddress far(blockType, farMajor, farMinor);
337  mFrameIndexToAddress[frameIndex] = far;
338  mFrameAddressToIndex[far] = frameIndex;
339  frameIndex++;
340  }
341  if(width > 0) farMajor++;
342  frameCount += width;
343  }
344  for(ColumnIndex col; col < mDeviceInfo.getColCount(); col++) {
347  continue;
348  else
349  {
350  width = mColumnDefs[mDeviceInfo.getColumnTypes()[col]][i];
351  //printf("Width found: %d", width);
352  }
353  for(uint32_t farMinor = 0; farMinor < width; farMinor++) {
354  Spartan3E::FrameAddress far(blockType, farMajor, farMinor);
355  mFrameIndexToAddress[frameIndex] = far;
356  mFrameAddressToIndex[far] = frameIndex;
357  frameIndex++;
358  }
359  if(width > 0) farMajor++;
360  frameCount += width;
361 
362  //Indexes for Bitstream Columns, only stores non-empty tile types
364  bitIndex += width;
365  mBitColumnIndexes[i].push_back(bitIndex);
366  }
367  //Indexes for XDL Columns, stores interconnect and tile indexes for
368  //non-empty tiles
369  xdlIndex += width;
370  mXdlColumnIndexes[i].push_back(xdlIndex);
371  }
372  }
373 
374  //Test to check proper indexing
375  bool debug = false;
376  if(debug) {
377  for(uint32_t i = 0; i < Spartan3E::eFarBlockTypeCount; i++) {
378  for(uint32_t j = 0; j < mBitColumnIndexes[i].size(); j++)
379  std::cout << "Bit Value at index: (" << i << ", " << j << ") : " << mBitColumnIndexes[i][j] << std::endl;
380  for(uint32_t k = 0; k < mXdlColumnIndexes[i].size(); k++)
381  std::cout << "Xdl Value at index: (" << i << ", " << k << ") : " << mXdlColumnIndexes[i][k] << std::endl;
382  }
383  }
384  }
ColumnDefVector mColumnDefs
Column type widths.
FrameIndexToAddress mFrameIndexToAddress
Map of frame indexes to frame addresses.
Definition: Spartan3E.hpp:193
FrameAddressToIndex mFrameAddressToIndex
Map of frame addressee to frame indexes.
Definition: Spartan3E.hpp:195
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
EFarBlockType
Frame Address Register block type constants.
Definition: Spartan3E.hpp:73
Template base for encapsulated integers, to enforce strong typing.
boost::uint32_t uint32_t
Imported type name.
Definition: Spartan3E.hpp:46
ColumnIndexVector mBitColumnIndexes[Spartan3E::eFarBlockTypeCount]
Vector to store frame indexes of XDL columns.
Definition: Spartan3E.hpp:197
ColumnIndexVector mXdlColumnIndexes[Spartan3E::eFarBlockTypeCount]
Vector to store frame indexes of Bitstream columns.
Definition: Spartan3E.hpp:199

+ Here is the call graph for this function:

uint32_t torc::bitstream::Spartan3E::makeSubfield ( ERegister  inRegister,
const std::string &  inSubfield,
const std::string &  inSetting 
)
static

Return the masked value for a subfield of the specified register.

Definition at line 186 of file Spartan3E.cpp.

187  {
188  const Subfield* subfields;
189  switch(inRegister) {
190  case eRegisterCOR: subfields = sCOR; break;
191  case eRegisterSTAT: subfields = sSTAT; break;
192  case eRegisterCTL: subfields = sCTL; break;
193  case eRegisterMASK: subfields = sMASK; break;
194  default: return 0;
195  }
196  for(uint32_t field = 0; subfields[field].mMask != 0; field++) {
197  const Subfield& subfield = subfields[field];
198  if(inSubfield != subfield.mBitgenName && inSubfield != subfield.mConfigGuideName)
199  continue;
200  const char** ptr = subfield.mValues;
201  for(uint32_t i = 0; *ptr != 0; i++, ptr++) {
202  if(inSetting == *ptr) return (i << subfield.mShift) & subfield.mMask;
203  }
204  }
205  return 0;
206  }
static const Subfield sMASK[]
Control Mask Register (MASK) subfields.
Definition: Spartan3E.hpp:99
static const Subfield sCTL[]
Control Register (CTL) subfields.
Definition: Spartan3E.hpp:97
static const Subfield sCOR[]
Configuration Options Register (COR) subfields.
Definition: Spartan3E.hpp:93
static const Subfield sSTAT[]
Status Register (STAT) subfields.
Definition: Spartan3E.hpp:95
boost::uint32_t uint32_t
Imported type name.
Definition: Spartan3E.hpp:46
const char ** mValues
The allowable subfield values.

+ Here is the caller graph for this function:

void torc::bitstream::SpartanBitstream::preflightPackets ( void  )
virtualinherited

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

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

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

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

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

Insert the bitstream header into an output stream.

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

88  {
89  // insert the bitstream header
90  os << static_cast<const Bitstream>(rhs) << std::endl;
91  uint32_t cumulativeWordLength = 0;
92  bool newColumn = false;
93  bool newBlock = false;
94  uint32_t oldColumnValue = 0;
95  uint32_t oldBlockValue = 0;
96  uint32_t currentColumnValue = 0;
97  uint32_t currentBlockValue = 0;
98 
99  // iterate over the packets
101  //SpartanPacketVector::const_iterator p = rhs.begin();
102  std::vector<SpartanPacket>::const_iterator p = rhs.begin();
103  //SpartanPacketVector::const_iterator e = rhs.end();
104  std::vector<SpartanPacket>::const_iterator e = rhs.end();
105  while(p < e) {
106 
107  // insert the byte address
108  os << " " << Hex32(rhs.getHeaderByteLength() + (cumulativeWordLength << 2)) << ": ";
109  // look up the packet
110  const SpartanPacket& packet = *p++;
111  cumulativeWordLength += packet.getWordSize();
112 
113  // handle dummy words
114  if(packet.isDummyWord()) {
115  os << "DUMMY" << std::endl;
116 
117  // handle sync words
118  } else if(packet.isSyncWord()) {
119  os << "SYNC" << std::endl;
120 
121  // handle reserved packets
122  } else if(packet.isReserved()) {
123  os << Spartan3E::sOpcodeName[packet.getOpcode()] << std::endl;
124 
125  // handle NOP packets
126  } else if(packet.isNop()) {
127  int nops = 1;
128  while(p < e && p->isNop()) { nops++; p++; }
129  cumulativeWordLength += nops - 1;
130  os << "NOP x " << nops << std::endl;
131 
132  // handle regular type 1 or type 2 packets
133  } else {
134 
135  // look up the packet details
136  Spartan3E::EPacketType type = packet.getType();
137  Spartan3E::EOpcode opcode = packet.getOpcode();
138  uint32_t wordCount = packet.getWordCount();
139  const uint32_t word = packet[1];
140 
141  // account for the packet type
142  os << Spartan3E::sPacketTypeName[type];
143  switch(type) {
145  address = Spartan3E::ERegister(packet.getAddress());
146  break;
148  break;
149  default:
150  os << std::endl;
151  continue;
152  }
153 
154  // handle read packets
155  if(opcode == packet.isRead()) {
156  os << " READ " << Spartan3E::sRegisterName[address];
157 
158  // handle write packets
159  } else if(opcode == Spartan3E::eOpcodeWrite) {
160  os << " WRITE " << Spartan3E::sRegisterName[address];
161  // process according to register address
162  switch(address) {
164  os << ": " << Hex32(wordCount) << " words";
165  if(wordCount == 0) break;
166  // include the Auto CRC information
167  os << std::endl << " ";
168  os << Hex32(rhs.getHeaderByteLength() + (cumulativeWordLength << 2))
169  << ": Auto CRC: " << Hex16(p->getHeader());
170  cumulativeWordLength += 1;
171  p++;
172  break;
174  os << " " << Spartan3E::sCommandName[word];
175  break;
177  os << ": " << Hex32(word);
179  break;
181  os << ": " << Hex32(word);
183  break;
185  os << ": " << Hex32(word);
187  break;
189  os << ": " << Hex32(word);
191  break;
192  // Added to make frame mapping debug easier
194  oldColumnValue = currentColumnValue;
195  oldBlockValue = currentBlockValue;
196  currentColumnValue = (word & Virtex::eFarMaskMajor);
197  currentBlockValue = (word & Virtex::eFarMaskBlockType);
198  newColumn = (currentColumnValue != oldColumnValue);
199  newBlock = (currentBlockValue != oldBlockValue);
200  os << ": " << Hex32(word);
201  if(newColumn) std::cout << "\t\t\t!!!New Column!!!";
202  if(newBlock) std::cout << "\t\t\t\t\t***New Block***" << Hex32(currentBlockValue);
203  break;
204  default:
205  // output the register contents
206  os << ": " << Hex32(word);
207  break;
208  }
209  os << std::endl;
210  }
211 
212  }
213 
214  }
215 
216  // return the stream reference
217  return os;
218  }
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
Definition: Spartan3E.hpp:87
static const Subfield sMASK[]
Control Mask Register (MASK) subfields.
Definition: Spartan3E.hpp:99
static const char * sRegisterName[eRegisterCount]
Configuration register names.
Definition: Spartan3E.hpp:89
static const char * sCommandName[eCommandCount]
Configuration command names.
Definition: Spartan3E.hpp:91
static const Subfield sCTL[]
Control Register (CTL) subfields.
Definition: Spartan3E.hpp:97
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
Definition: Spartan3E.hpp:85
static const Subfield sCOR[]
Configuration Options Register (COR) subfields.
Definition: Spartan3E.hpp:93
EPacketType
Packet type enumeration.
EOpcode
Packet opcode enumeration.
static void writeSubfieldSettings(std::ostream &inStream, uint32_t inWord, const Subfield *inSubfields)
Insert 32 bit subfield settings into an output stream.
Definition: Bitstream.cpp:26
static const Subfield sSTAT[]
Status Register (STAT) subfields.
Definition: Spartan3E.hpp:95
boost::uint32_t uint32_t
Imported type name.
Definition: Spartan3E.hpp:46
ERegister
Configuration register enumeration.
Definition: Spartan3E.hpp:52
friend class torc::bitstream::bitstream::Spartan3EFarUnitTest
friend

Definition at line 40 of file Spartan3E.hpp.

friend class torc::bitstream::bitstream::Spartan3EUnitTest
friend

Definition at line 39 of file Spartan3E.hpp.

void torc::bitstream::bitstream::testSpartan3EDevice ( const std::string &  inDeviceName,
const boost::filesystem::path &  inWorkingPath 
)
friend

Field Documentation

ColumnIndexVector torc::bitstream::Spartan3E::mBitColumnIndexes[Spartan3E::eFarBlockTypeCount]
protected

Vector to store frame indexes of XDL columns.

Definition at line 197 of file Spartan3E.hpp.

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.

FrameAddressToIndex torc::bitstream::Spartan3E::mFrameAddressToIndex
protected

Map of frame addressee to frame indexes.

Definition at line 195 of file Spartan3E.hpp.

FrameIndexToAddress torc::bitstream::Spartan3E::mFrameIndexToAddress
protected

Map of frame indexes to frame addresses.

Definition at line 193 of file Spartan3E.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.

ColumnIndexVector torc::bitstream::Spartan3E::mXdlColumnIndexes[Spartan3E::eFarBlockTypeCount]
protected

Vector to store frame indexes of Bitstream columns.

Definition at line 199 of file Spartan3E.hpp.

const char * torc::bitstream::Spartan3E::sCommandName
staticprotected
Initial value:
= {
"NULL", "WCFG", "MFWR", "LFRM", "RCFG", "START", "RCAP", "RCRC", "AGHIGH", "SWITCH",
"GRESTORE", "SHUTDOWN", "GCAPTURE", "DESYNCH"
}

Configuration command names.

Definition at line 91 of file Spartan3E.hpp.

const Bitstream::Subfield torc::bitstream::Spartan3E::sCOR
staticprotected

Configuration Options Register (COR) subfields.

See Also
Configuration Options Register Description: XAPP452, v1.1, June 25, 2008, Table 5.

Definition at line 93 of file Spartan3E.hpp.

const Bitstream::Subfield torc::bitstream::Spartan3E::sCTL
staticprotected
Initial value:
= {
{0x00000001, 0, "GTS_USER_B", "GTS_USER_B", 0,
VALUES{"IoDisabled", "IoActive", 0}},
{0x00000008, 3, "Persist", "PERSIST", 0,
VALUES{"No", "Yes", 0}},
{0x00000030, 4, "Security", "SBITS", 0,
VALUES{"None", "Level1", "Level2", "Level2", 0}},
{0, 0, 0, 0, 0, 0}
}

Control Register (CTL) subfields.

See Also
Control Register Description: XAPP452, v1.1, June 25, 2008, Table 3.

Definition at line 97 of file Spartan3E.hpp.

const Bitstream::Subfield torc::bitstream::Spartan3E::sMASK
staticprotected
Initial value:
= {
{0x00000001, 0, "GTS_USER_B", "GTS_USER_B", 0, VALUES{"Protected", "Writable", 0}},
{0x00000008, 3, "Persist", "PERSIST", 0, VALUES{"Protected", "Writable", 0}},
{0x00000080, 4, "Security", "SBITS", 0,
VALUES{"Protected", "[UNKNOWN 1]", "[UNKNOWN 2]", "Writable", 0}},
{0, 0, 0, 0, 0, 0}
}

Control Mask Register (MASK) subfields.

See Also
Control Mask Register Description: Inferred from Table 3.

Definition at line 99 of file Spartan3E.hpp.

const char * torc::bitstream::Spartan3E::sOpcodeName
staticprotected
Initial value:
= {
"NOP", "READ", "WRITE", "RESERVED"
}

Packet opcode names.

Definition at line 87 of file Spartan3E.hpp.

const char * torc::bitstream::Spartan3E::sPacketTypeName
staticprotected
Initial value:
= {
"[UNKNOWN TYPE 0]", "TYPE1", "TYPE2", "[UNKNOWN TYPE 3]", "[UNKNOWN TYPE 4]",
"[UNKNOWN TYPE 5]", "[UNKNOWN TYPE 6]", "[UNKNOWN TYPE 7]"
}

Packet type names.

Definition at line 85 of file Spartan3E.hpp.

const char * torc::bitstream::Spartan3E::sRegisterName
staticprotected
Initial value:
= {
"CRC", "FAR", "FDRI", "FDRO", "CMD", "CTL", "MASK", "STAT", "LOUT", "COR", "MFWR", "FLR",
"[UNKNOWN_REGISTER 12]", "[UNKNOWN_REGISTER 13]", "IDCODE"
}

Configuration register names.

Definition at line 89 of file Spartan3E.hpp.

const Bitstream::Subfield torc::bitstream::Spartan3E::sSTAT
staticprotected

Status Register (STAT) subfields.

See Also
Status Register Description: XAPP452, v1.1, June 25, 2008, Table 4.
Note
The "bitgen" names attempt to mimic the general bitgen convention.

Definition at line 95 of file Spartan3E.hpp.


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