19 #include <boost/crc.hpp>
22 using namespace torc::common;
27 void Spartan6Bitstream::readPackets(std::istream& inStream) {
28 uint16_t bitstreamWordLength = mBitstreamByteLength >> 1;
30 while(cumulativeWordLength < bitstreamWordLength) {
31 push_back(Spartan6Packet::read(inStream));
32 uint32_t wordSize = back().getWordSize();
33 cumulativeWordLength += wordSize;
35 if(wordSize <= getFrameLength())
continue;
38 inStream.read((
char*) &autoCrcHi,
sizeof(autoCrcHi));
39 inStream.read((
char*) &autoCrcLo,
sizeof(autoCrcLo));
40 autoCrcHi = ntohs(autoCrcHi);
41 autoCrcLo = ntohs(autoCrcLo);
43 cumulativeWordLength += 2;
47 void Spartan6Bitstream::writePackets(std::ostream& inStream) {
48 const_iterator p = begin();
49 const_iterator e = end();
50 while(p < e) p++->write(inStream);
53 void Spartan6Bitstream::preflightPackets(
void) {
66 cmdRegister = Spartan6::eRegisterCMD; rcrcCommand = Spartan6::eCommandRCRC;
67 fdriRegister = Spartan6::eRegisterFDRI; crcRegister = Spartan6::eRegisterCRC;
68 (void) addressLength; autoCrc =
true;
71 std::cerr <<
"Unsupported architecture in Spartan6Bitstream::preflightPackets()."
88 if(wordCount == 0)
continue;
90 if(address == crcRegister) {
93 *(p-1) = Spartan6Packet::makeType1Write32(crcRegister, crc);
96 }
else if(address == cmdRegister && wordCount >= 1 && packet[1] == rcrcCommand) {
99 }
else if(address == Spartan6::eRegisterBOOSTS || address == Spartan6::eRegisterSTAT
100 || address == Spartan6::eRegisterLOUT || address == Spartan6::eRegisterCSBO
101 || address == Spartan6::eRegisterRDBK_SIGN || address == Spartan6::eRegisterFDRO) {
104 for(
uint32_t i = 1; i <= wordCount; i++) {
108 crc.
update(address, word);
114 if(autoCrc && address == fdriRegister) {
126 void Spartan6Bitstream::updatePacketLength(
void) {
128 iterator p = begin();
130 while(p < e) totalWordCount += (p++)->getWordSize();
131 mBitstreamByteLength = totalWordCount << 1;
Header for the Spartan6Bitstream class.
Encapsulation of a device designator and its constituent elements.
uint32_t getWordCount(void) const
Returns the number of payload words in the packet, excluding the header word.
const EFamily & getFamily(void) const
Returns the device family.
void reset(void)
Function to clear the CRC calculation.
void update(uint32_t inAddress, uint32_t inWord)
Update the CRC with new data.
Bitstream packet for Spartan 16 bit class architectures.
Header for the DeviceDesignator class.
Header for the Spartan6 class.
boost::uint32_t uint32_t
Imported type name.
CRC class for the Spartan6 architecture.
boost::uint16_t uint16_t
Imported type name.
int getAddress(void) const