19 #ifndef TORC_BITSTREAM_SPARTAN6PACKET_HPP
20 #define TORC_BITSTREAM_SPARTAN6PACKET_HPP
23 #include <boost/smart_ptr.hpp>
32 namespace bitstream {
class Spartan6PacketUnitTest; }
140 inStream.
read((
char*) &header,
sizeof(header));
141 header = ntohs(header);
156 inStream.read((
char*) &count2,
sizeof(count2));
157 inStream.read((
char*) &count1,
sizeof(count1));
158 count2 = ntohs(count2);
159 count1 = ntohs(count1);
160 count = (count2 << 16) | count1;
173 inStream.read((
char*) &word,
sizeof(word));
175 }
else if(count > 1) {
177 inStream.read((
char*) raw_words, count << 1);
179 for(
uint32_t i = 0; i < count; i++, wordPtr++) *wordPtr = ntohs(*wordPtr);
185 inStream.read((
char*) &word,
sizeof(word));
187 }
else if(count > 1) {
189 inStream.read((
char*) raw_words, count << 1);
191 for(
uint32_t i = 0; i < count; i++, wordPtr++) *wordPtr = ntohs(*wordPtr);
199 void write(std::ostream& inStream)
const {
201 for(
uint32_t i = 0; i < size; i++) {
202 uint16_t word = htons(
operator[](i));
203 inStream.write((
char*) &word,
sizeof(word));
207 word = htons(
mCount >> 16);
208 inStream.write((
char*) &word,
sizeof(word));
209 word = htons(
mCount & 0x0000ffff);
210 inStream.write((
char*) &word,
sizeof(word));
226 words[0] = inWord >> 16;
227 words[1] = inWord & 0x0000ffff;
245 inCount, 0, inWords);
274 if(inIndex == 0)
return mHeader;
318 #endif // TORC_BITSTREAM_SPARTAN6PACKET_HPP
uint16_t getHeader(void) const
static Spartan6Packet makeType1Write(uint16_t inAddress, uint16_t inWord1, uint16_t inWord2)
Construct a type 1 write packet for two words.
uint32_t getWordCount(void) const
Returns the number of payload words in the packet, excluding the header word.
bool isBusWidthDetectWord0(void) const
EOpcode getOpcode(void) const
uint16_t operator[](size_t inIndex) const
bool isBusWidthSyncWord1(void) const
bool isSyncWord0(void) const
const WordSharedArray getWords(void) const
brief Returns the raw packet words, including the header word.
Bitstream packet for Spartan 16 bit class architectures.
Spartan6Packet(uint16_t inHeader, uint16_t inWord)
Header plus single word constructor.
EPacketType getType(void) const
static uint16_t makeHeader(EPacketType inType, EOpcode inOpcode, uint16_t inAddress, uint32_t inCount)
Construct a packet header.
static Spartan6Packet makeType1Write(uint16_t inAddress, uint16_t inWord)
Construct a type 1 write packet.
bool isSyncWord1(void) const
EPacketType
Packet type enumeration.
Bitstream packet constants for Spartan 16 bit class architectures.
uint32_t getWordSize(void) const
Returns the total number of words in the packet, including the header word. In the case of Type 2 pa...
std::vector< Spartan6Packet > Spartan6PacketVector
Vector of Spartan 16 bit packets.
Spartan6Packet(uint16_t inHeader, uint32_t inCount, uint16_t inWord, uint16_t *inWords)
Full constructor.
static Spartan6Packet makeType2Write(uint32_t inCount, uint16_t inAddress, uint16_t *inWords)
Construct a type 2 write packet.
void write(std::ostream &inStream) const
Write a packet.
boost::shared_array< uint16_t > WordSharedArray
Word shared array type.
boost::uint16_t uint16_t
Imported type name.
static Spartan6Packet makeType1Write32(uint16_t inAddress, uint32_t inWord)
Construct a type 1 write packet for two words.
bool isBusWidthDetectWord1(void) const
Spartan6Packet(uint16_t inHeader)
Header only constructor.
bool isDummyWord(void) const
EOpcode
Packet opcode enumeration.
Spartan6Packet(const Spartan6Packet &rhs)
Copy constructor.
friend class torc::bitstream::bitstream::Spartan6PacketUnitTest
int getAddress(void) const
bool isReserved(void) const
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
Header for endian conversion.
static Spartan6Packet makeType1Write(uint32_t inCount, uint16_t inAddress, uint16_t *inWords)
Construct a type 1 write packet for multiple words.
static Spartan6Packet read(std::istream &inStream)
Read a packet.
ESynchronization
Synchronization words.
bool isBusWidthSyncWord0(void) const
Spartan6Packet(void)
Null constructor.