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

Bitstream packet for Virtex class architectures. More...

#include <VirtexPacket.hpp>

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

Public Types

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

 VirtexPacket (void)
 Null constructor. More...
 
 VirtexPacket (uint32_t inHeader, uint32_t inCount, uint32_t inWord, uint32_t *inWords)
 Full constructor. More...
 
 VirtexPacket (uint32_t inHeader, uint32_t inWord)
 Header plus single word constructor. More...
 
 VirtexPacket (uint32_t inHeader)
 Header only constructor. More...
 
 VirtexPacket (const VirtexPacket &rhs)
 Copy constructor. More...
 
void write (std::ostream &inStream) const
 Write a packet. More...
 
uint32_t operator[] (size_t inIndex) const
 
EPacketType getType (void) const
 
EOpcode getOpcode (void) const
 
int getAddress (void) const
 
uint32_t getHeader (void) const
 
uint32_t getWordCount (void) const
 Returns the number of payload words in the packet, excluding the header word. More...
 
uint32_t getWordSize (void) const
 Returns the total number of words in the packet, including the header word. More...
 
const WordSharedArray getWords (void) const
 brief Returns the raw packet words, including the header word. More...
 
bool isType1 (void) const
 
bool isType2 (void) const
 
bool isNop (void) const
 
bool isReserved (void) const
 
bool isRead (void) const
 
bool isWrite (void) const
 
bool isDummyWord (void) const
 
bool isSyncWord (void) const
 
bool isBusWidthSyncWord (void) const
 
bool isBusWidthDetectWord (void) const
 

Static Public Member Functions

static VirtexPacket read (std::istream &inStream)
 Read a packet. More...
 
static VirtexPacket makeNullType1Write (uint32_t inAddress)
 Construct a null type 1 write packet. More...
 
static VirtexPacket makeType1Write (uint32_t inAddress, uint32_t inWord)
 Construct a type 1 write packet. More...
 
static VirtexPacket makeType1Write (uint32_t inAddress, uint32_t inCount, uint32_t *inWords)
 Construct a multi-word type 1 write packet. More...
 
static VirtexPacket makeType2Write (uint32_t inCount, uint32_t *inWords)
 Construct a type 2 write packet. More...
 
static uint32_t makeHeader (EPacketType inType, EOpcode inOpcode, uint32_t inAddress, uint32_t inCount)
 Construct a packet header. More...
 

Data Fields

uint32_t mHeader
 
uint32_t mCount
 
uint32_t mWord
 
WordSharedArray mWords
 
EPacketType mType
 
EOpcode mOpcode
 
int mAddress
 

Static Public Attributes

static const char * sPacketTypeName [ePacketTypeCount]
 Packet type names. More...
 
static const char * sOpcodeName [eOpcodeCount]
 Packet opcode names. More...
 

Protected Types

typedef boost::uint32_t uint32_t
 Imported type name. More...
 
typedef boost::shared_array
< uint32_t
WordSharedArray
 Word shared array type. More...
 

Protected Member Functions

void initialize (void)
 

Friends

class torc::bitstream::bitstream::VirtexPacketUnitTest
 

Detailed Description

Bitstream packet for Virtex class architectures.

Definition at line 76 of file VirtexPacket.hpp.

Member Typedef Documentation

typedef boost::uint32_t torc::bitstream::VirtexPacket::uint32_t
protected

Imported type name.

Definition at line 81 of file VirtexPacket.hpp.

typedef boost::shared_array<uint32_t> torc::bitstream::VirtexPacket::WordSharedArray
protected

Word shared array type.

Definition at line 83 of file VirtexPacket.hpp.

Member Enumeration Documentation

Packet subfields.

See Also
type 1 packet format: UG071, v1.10, April 8, 2008, Table 7-2.
type 2 packet format: UG071, v1.10, April 8, 2008, Table 7-4.
type 1 packet format: XAPP151, v1.7, October 20, 2004, Figure 13.
type 2 packet format: XAPP151, v1.7, October 20, 2004, Figure 14.
Enumerator
ePacketMaskType 
ePacketShiftType 
ePacketMaskOpcode 
ePacketShiftOpcode 
ePacketMaskType1Address 
ePacketShiftType1Address 
ePacketMaskType1Reserved 
ePacketShiftType1Reserved 
ePacketMaskType1Count 
ePacketShiftType1Count 
ePacketMaskType2Count 
ePacketShiftType2Count 

Definition at line 51 of file VirtexPacket.hpp.

51  {
52  // generic packet subfields
53  ePacketMaskType = 0xe0000000, ePacketShiftType = 29,
54  ePacketMaskOpcode = 0x18000000, ePacketShiftOpcode = 27,
55  // type 1 packet subfields
59  // type 2 packet subfields
61  };

Packet type enumeration.

See Also
packet type: UG071, v1.10, April 8, 2008, Tables 7-2 and 7-4.
packet type: XAPP151, v1.7, October 20, 2004, Figure 13, 14.
Enumerator
ePacketType1 
ePacketType2 
ePacketTypeCount 

Definition at line 41 of file VirtexPacket.hpp.

Synchronization words.

See Also
Configuration Sequence: UG191, v3.7, June 24, 2009, Table 6-15.
Configuration Sequence: UG071, v1.10, April 8, 2008, Table 7-11.
Configuration Sequence: XAPP511, v1.7, October 20, 2004, Figure 23.
Enumerator
eSynchronizationDummy 
eSynchronizationSync 
eSynchronizationBusWidthSync 
eSynchronizationBusWidthDetect 

Definition at line 67 of file VirtexPacket.hpp.

Constructor & Destructor Documentation

torc::bitstream::VirtexPacket::VirtexPacket ( void  )
inline
torc::bitstream::VirtexPacket::VirtexPacket ( uint32_t  inHeader,
uint32_t  inCount,
uint32_t  inWord,
uint32_t inWords 
)
inline

Full constructor.

Definition at line 111 of file VirtexPacket.hpp.

+ Here is the call graph for this function:

torc::bitstream::VirtexPacket::VirtexPacket ( uint32_t  inHeader,
uint32_t  inWord 
)
inline

Header plus single word constructor.

Definition at line 117 of file VirtexPacket.hpp.

+ Here is the call graph for this function:

torc::bitstream::VirtexPacket::VirtexPacket ( uint32_t  inHeader)
inline

Header only constructor.

Definition at line 122 of file VirtexPacket.hpp.

+ Here is the call graph for this function:

torc::bitstream::VirtexPacket::VirtexPacket ( const VirtexPacket rhs)
inline

Copy constructor.

Definition at line 127 of file VirtexPacket.hpp.

+ Here is the call graph for this function:

Member Function Documentation

int torc::bitstream::VirtexPacket::getAddress ( void  ) const
inline

Definition at line 243 of file VirtexPacket.hpp.

+ Here is the caller graph for this function:

uint32_t torc::bitstream::VirtexPacket::getHeader ( void  ) const
inline

Definition at line 244 of file VirtexPacket.hpp.

244 { return mHeader; }

+ Here is the caller graph for this function:

EOpcode torc::bitstream::VirtexPacket::getOpcode ( void  ) const
inline

Definition at line 242 of file VirtexPacket.hpp.

242 { return mOpcode; }

+ Here is the caller graph for this function:

EPacketType torc::bitstream::VirtexPacket::getType ( void  ) const
inline

Definition at line 241 of file VirtexPacket.hpp.

241 { return mType; }

+ Here is the caller graph for this function:

uint32_t torc::bitstream::VirtexPacket::getWordCount ( void  ) const
inline

Returns the number of payload words in the packet, excluding the header word.

Definition at line 246 of file VirtexPacket.hpp.

246 { return mCount; }

+ Here is the caller graph for this function:

const WordSharedArray torc::bitstream::VirtexPacket::getWords ( void  ) const
inline

brief Returns the raw packet words, including the header word.

Definition at line 250 of file VirtexPacket.hpp.

250 { return mWords; }

+ Here is the caller graph for this function:

uint32_t torc::bitstream::VirtexPacket::getWordSize ( void  ) const
inline

Returns the total number of words in the packet, including the header word.

Definition at line 248 of file VirtexPacket.hpp.

248 { return mCount + 1; }

+ Here is the caller graph for this function:

void torc::bitstream::VirtexPacket::initialize ( void  )
inlineprotected

Definition at line 85 of file VirtexPacket.hpp.

+ Here is the caller graph for this function:

bool torc::bitstream::VirtexPacket::isBusWidthDetectWord ( void  ) const
inline

Definition at line 261 of file VirtexPacket.hpp.

+ Here is the caller graph for this function:

bool torc::bitstream::VirtexPacket::isBusWidthSyncWord ( void  ) const
inline

Definition at line 260 of file VirtexPacket.hpp.

+ Here is the caller graph for this function:

bool torc::bitstream::VirtexPacket::isDummyWord ( void  ) const
inline

Definition at line 258 of file VirtexPacket.hpp.

+ Here is the caller graph for this function:

bool torc::bitstream::VirtexPacket::isNop ( void  ) const
inline

Definition at line 254 of file VirtexPacket.hpp.

+ Here is the caller graph for this function:

bool torc::bitstream::VirtexPacket::isRead ( void  ) const
inline

Definition at line 256 of file VirtexPacket.hpp.

+ Here is the caller graph for this function:

bool torc::bitstream::VirtexPacket::isReserved ( void  ) const
inline

Definition at line 255 of file VirtexPacket.hpp.

+ Here is the caller graph for this function:

bool torc::bitstream::VirtexPacket::isSyncWord ( void  ) const
inline

Definition at line 259 of file VirtexPacket.hpp.

+ Here is the caller graph for this function:

bool torc::bitstream::VirtexPacket::isType1 ( void  ) const
inline

Definition at line 252 of file VirtexPacket.hpp.

+ Here is the caller graph for this function:

bool torc::bitstream::VirtexPacket::isType2 ( void  ) const
inline

Definition at line 253 of file VirtexPacket.hpp.

+ Here is the caller graph for this function:

bool torc::bitstream::VirtexPacket::isWrite ( void  ) const
inline

Definition at line 257 of file VirtexPacket.hpp.

+ Here is the caller graph for this function:

static uint32_t torc::bitstream::VirtexPacket::makeHeader ( EPacketType  inType,
EOpcode  inOpcode,
uint32_t  inAddress,
uint32_t  inCount 
)
inlinestatic

Construct a packet header.

Todo:
Generate an error or throw an exception on invalid packet types?

Definition at line 215 of file VirtexPacket.hpp.

216  {
217  // type 1 packets
218  if(inType == ePacketType1) return
219  ((inType << ePacketShiftType) & ePacketMaskType) |
220  ((inOpcode << ePacketShiftOpcode) & ePacketMaskOpcode) |
223  // type 2 packets
224  else if(inType == ePacketType2) return
225  ((inType << ePacketShiftType) & ePacketMaskType) |
226  ((inOpcode << ePacketShiftOpcode) & ePacketMaskOpcode) |
228  // undefined packet types
229  else
230  /// \todo Generate an error or throw an exception on invalid packet types?
231  return 0;
232  }

+ Here is the caller graph for this function:

static VirtexPacket torc::bitstream::VirtexPacket::makeNullType1Write ( uint32_t  inAddress)
inlinestatic

Construct a null type 1 write packet.

A type 1 write packet to the FDRI register is generally only useful to specify the current register in preparation for a type 2 write. The type 2 write header includes a size but specifies no target register, hence the prior null type 1 packet.

Definition at line 188 of file VirtexPacket.hpp.

188  {
189  return VirtexPacket(makeHeader(ePacketType1, eOpcodeWrite, inAddress, 0), 0, 0, 0);
190  }
VirtexPacket(void)
Null constructor.
static uint32_t makeHeader(EPacketType inType, EOpcode inOpcode, uint32_t inAddress, uint32_t inCount)
Construct a packet header.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static VirtexPacket torc::bitstream::VirtexPacket::makeType1Write ( uint32_t  inAddress,
uint32_t  inWord 
)
inlinestatic

Construct a type 1 write packet.

Definition at line 192 of file VirtexPacket.hpp.

192  {
193  return VirtexPacket(makeHeader(ePacketType1, eOpcodeWrite, inAddress, 1), 1, inWord, 0);
194  }
VirtexPacket(void)
Null constructor.
static uint32_t makeHeader(EPacketType inType, EOpcode inOpcode, uint32_t inAddress, uint32_t inCount)
Construct a packet header.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static VirtexPacket torc::bitstream::VirtexPacket::makeType1Write ( uint32_t  inAddress,
uint32_t  inCount,
uint32_t inWords 
)
inlinestatic

Construct a multi-word type 1 write packet.

Definition at line 196 of file VirtexPacket.hpp.

197  {
198  return VirtexPacket(makeHeader(ePacketType1, eOpcodeWrite, inAddress, inCount),
199  inCount, 0, inWords);
200  }
VirtexPacket(void)
Null constructor.
static uint32_t makeHeader(EPacketType inType, EOpcode inOpcode, uint32_t inAddress, uint32_t inCount)
Construct a packet header.

+ Here is the call graph for this function:

static VirtexPacket torc::bitstream::VirtexPacket::makeType2Write ( uint32_t  inCount,
uint32_t inWords 
)
inlinestatic

Construct a type 2 write packet.

Definition at line 202 of file VirtexPacket.hpp.

202  {
203  return VirtexPacket(makeHeader(ePacketType2, eOpcodeWrite, 0, inCount), inCount, 0,
204  inWords);
205  }
VirtexPacket(void)
Null constructor.
static uint32_t makeHeader(EPacketType inType, EOpcode inOpcode, uint32_t inAddress, uint32_t inCount)
Construct a packet header.

+ Here is the call graph for this function:

uint32_t torc::bitstream::VirtexPacket::operator[] ( size_t  inIndex) const
inline

Definition at line 234 of file VirtexPacket.hpp.

234  {
235  if(inIndex == 0) return mHeader;
236  if(inIndex == 1 && mCount == 1) return mWord;
237  if(inIndex <= mCount) return mWords[inIndex-1];
238  return 0;
239  }
static VirtexPacket torc::bitstream::VirtexPacket::read ( std::istream &  inStream)
inlinestatic

Read a packet.

Todo:
we should throw an exception on invalid packet types

Definition at line 134 of file VirtexPacket.hpp.

134  {
135  uint32_t count = 0;
136  uint32_t header = 0;
137  uint32_t word = 0;
138  uint32_t* raw_words = 0;
139  // read the header
140  inStream.read((char*) &header, sizeof(header));
141  header = ntohl(header);
142  // process synchronization packets
143  if(header == eSynchronizationDummy || header == eSynchronizationSync
144  || header == eSynchronizationBusWidthSync
145  || header == eSynchronizationBusWidthDetect) {
146  return VirtexPacket(header, 0, 0, 0);
147  }
148  // determine the payload length
150  switch(type) {
151  case ePacketType1:
152  count = (header & ePacketMaskType1Count) >> ePacketShiftType1Count;
153  break;
154  case ePacketType2:
155  count = (header & ePacketMaskType2Count) >> ePacketShiftType2Count;
156  break;
157  default:
158  /// \todo we should throw an exception on invalid packet types
159  count = 0;
160  break;
161  }
162  // read the packet payload
163  if(count == 1) {
164  inStream.read((char*) &word, sizeof(word));
165  word = ntohl(word);
166  } else if(count > 1) {
167  raw_words = new uint32_t[count];
168  inStream.read((char*) raw_words, count << 2);
169  uint32_t* wordPtr = raw_words;
170  for(uint32_t i = 0; i < count; i++, wordPtr++) *wordPtr = ntohl(*wordPtr);
171  }
172  // create and return the packet
173  return VirtexPacket(header, count, word, raw_words);
174  }
VirtexPacket(void)
Null constructor.
boost::uint32_t uint32_t
Imported type name.
EPacketType
Packet type enumeration.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::VirtexPacket::write ( std::ostream &  inStream) const
inline

Write a packet.

Definition at line 176 of file VirtexPacket.hpp.

176  {
177  uint32_t size = getWordSize();
178  for(uint32_t i = 0; i < size; i++) {
179  uint32_t word = htonl(operator[](i));
180  inStream.write((char*) &word, sizeof(word));
181  }
182  }
uint32_t getWordSize(void) const
Returns the total number of words in the packet, including the header word.
boost::uint32_t uint32_t
Imported type name.

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend class torc::bitstream::bitstream::VirtexPacketUnitTest
friend

Definition at line 77 of file VirtexPacket.hpp.

Field Documentation

int torc::bitstream::VirtexPacket::mAddress

Definition at line 100 of file VirtexPacket.hpp.

uint32_t torc::bitstream::VirtexPacket::mCount

Definition at line 95 of file VirtexPacket.hpp.

uint32_t torc::bitstream::VirtexPacket::mHeader

Definition at line 94 of file VirtexPacket.hpp.

EOpcode torc::bitstream::VirtexPacket::mOpcode

Definition at line 99 of file VirtexPacket.hpp.

EPacketType torc::bitstream::VirtexPacket::mType

Definition at line 98 of file VirtexPacket.hpp.

uint32_t torc::bitstream::VirtexPacket::mWord

Definition at line 96 of file VirtexPacket.hpp.

WordSharedArray torc::bitstream::VirtexPacket::mWords

Definition at line 97 of file VirtexPacket.hpp.

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

Packet opcode names.

Definition at line 104 of file VirtexPacket.hpp.

const char * torc::bitstream::VirtexPacket::sPacketTypeName
static
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 102 of file VirtexPacket.hpp.


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