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

Bitstream packet for Spartan class architectures. More...

#include <SpartanPacket.hpp>

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

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

 SpartanPacket (void)
 Null constructor. More...
 
 SpartanPacket (uint32_t inHeader, uint32_t inCount, uint32_t inWord, uint32_t *inWords)
 Full constructor. More...
 
 SpartanPacket (uint32_t inHeader, uint32_t inWord)
 Header plus single word constructor. More...
 
 SpartanPacket (uint32_t inHeader)
 Header only constructor. More...
 
 SpartanPacket (const SpartanPacket &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...
 
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 SpartanPacket read (std::istream &inStream)
 Read a packet. More...
 
static SpartanPacket makeNullType1Write (uint32_t inAddress)
 Construct a null type 1 write packet. More...
 
static SpartanPacket makeType1Write (uint32_t inAddress, uint32_t inWord)
 Construct a type 1 write packet. More...
 
static SpartanPacket 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::SpartanPacketUnitTest
 

Detailed Description

Bitstream packet for Spartan class architectures.

Definition at line 69 of file SpartanPacket.hpp.

Member Typedef Documentation

typedef boost::uint32_t torc::bitstream::SpartanPacket::uint32_t
protected

Imported type name.

Definition at line 74 of file SpartanPacket.hpp.

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

Word shared array type.

Definition at line 76 of file SpartanPacket.hpp.

Member Enumeration Documentation

Packet subfields.

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

Definition at line 46 of file SpartanPacket.hpp.

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

Packet type enumeration.

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

Definition at line 39 of file SpartanPacket.hpp.

Synchronization words.

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

Definition at line 60 of file SpartanPacket.hpp.

Constructor & Destructor Documentation

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

Full constructor.

Definition at line 104 of file SpartanPacket.hpp.

+ Here is the call graph for this function:

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

Header plus single word constructor.

Definition at line 110 of file SpartanPacket.hpp.

+ Here is the call graph for this function:

torc::bitstream::SpartanPacket::SpartanPacket ( uint32_t  inHeader)
inline
torc::bitstream::SpartanPacket::SpartanPacket ( const SpartanPacket rhs)
inline

Copy constructor.

Definition at line 120 of file SpartanPacket.hpp.

+ Here is the call graph for this function:

Member Function Documentation

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

Definition at line 237 of file SpartanPacket.hpp.

+ Here is the caller graph for this function:

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

Definition at line 238 of file SpartanPacket.hpp.

238 { return mHeader; }

+ Here is the caller graph for this function:

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

Definition at line 236 of file SpartanPacket.hpp.

236 { return mOpcode; }

+ Here is the caller graph for this function:

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

Definition at line 235 of file SpartanPacket.hpp.

235 { return mType; }

+ Here is the caller graph for this function:

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

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

Definition at line 240 of file SpartanPacket.hpp.

240 { return mCount; }

+ Here is the caller graph for this function:

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

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

Definition at line 242 of file SpartanPacket.hpp.

242 { return mCount + 1; }

+ Here is the caller graph for this function:

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

Definition at line 78 of file SpartanPacket.hpp.

78  {
81  if(mType == ePacketType1)
83  }
EPacketType
Packet type enumeration.
EOpcode
Packet opcode enumeration.

+ Here is the caller graph for this function:

bool torc::bitstream::SpartanPacket::isBusWidthDetectWord ( void  ) const
inline
bool torc::bitstream::SpartanPacket::isBusWidthSyncWord ( void  ) const
inline
bool torc::bitstream::SpartanPacket::isDummyWord ( void  ) const
inline

Definition at line 251 of file SpartanPacket.hpp.

+ Here is the caller graph for this function:

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

Definition at line 247 of file SpartanPacket.hpp.

+ Here is the caller graph for this function:

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

Definition at line 249 of file SpartanPacket.hpp.

+ Here is the caller graph for this function:

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

Definition at line 248 of file SpartanPacket.hpp.

+ Here is the caller graph for this function:

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

Definition at line 252 of file SpartanPacket.hpp.

+ Here is the caller graph for this function:

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

Definition at line 245 of file SpartanPacket.hpp.

+ Here is the caller graph for this function:

bool torc::bitstream::SpartanPacket::isType2 ( void  ) const
inline
bool torc::bitstream::SpartanPacket::isWrite ( void  ) const
inline

Definition at line 250 of file SpartanPacket.hpp.

+ Here is the caller graph for this function:

static uint32_t torc::bitstream::SpartanPacket::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 209 of file SpartanPacket.hpp.

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

+ Here is the caller graph for this function:

static SpartanPacket torc::bitstream::SpartanPacket::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 187 of file SpartanPacket.hpp.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Construct a type 1 write packet.

Definition at line 191 of file SpartanPacket.hpp.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Construct a type 2 write packet.

Definition at line 196 of file SpartanPacket.hpp.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 228 of file SpartanPacket.hpp.

228  {
229  if(inIndex == 0) return mHeader;
230  if(inIndex == 1 && mCount == 1) return mWord;
231  if(inIndex <= mCount) return mWords[inIndex-1];
232  return 0;
233  }
static SpartanPacket torc::bitstream::SpartanPacket::read ( std::istream &  inStream)
inlinestatic

Read a packet.

Todo:
we should throw an exception on invalid packet types

Definition at line 127 of file SpartanPacket.hpp.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Write a packet.

Definition at line 175 of file SpartanPacket.hpp.

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

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend class torc::bitstream::bitstream::SpartanPacketUnitTest
friend

Definition at line 70 of file SpartanPacket.hpp.

Field Documentation

int torc::bitstream::SpartanPacket::mAddress

Definition at line 93 of file SpartanPacket.hpp.

uint32_t torc::bitstream::SpartanPacket::mCount

Definition at line 88 of file SpartanPacket.hpp.

uint32_t torc::bitstream::SpartanPacket::mHeader

Definition at line 87 of file SpartanPacket.hpp.

EOpcode torc::bitstream::SpartanPacket::mOpcode

Definition at line 92 of file SpartanPacket.hpp.

EPacketType torc::bitstream::SpartanPacket::mType

Definition at line 91 of file SpartanPacket.hpp.

uint32_t torc::bitstream::SpartanPacket::mWord

Definition at line 89 of file SpartanPacket.hpp.

WordSharedArray torc::bitstream::SpartanPacket::mWords

Definition at line 90 of file SpartanPacket.hpp.

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

Packet opcode names.

Definition at line 97 of file SpartanPacket.hpp.

const char * torc::bitstream::SpartanPacket::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 95 of file SpartanPacket.hpp.


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