19 #include <boost/test/unit_test.hpp>
30 #include <boost/filesystem.hpp>
35 BOOST_AUTO_TEST_SUITE(bitstream)
47 BOOST_CHECK_EQUAL(mask, 0xFFFFFFFFu);
51 BOOST_CHECK_EQUAL(mask, 0xFFFFFFFFu);
55 BOOST_CHECK_EQUAL(mask, 0x03FFFFFFu);
121 /
"torc" /
"bitstream" /
"Virtex7UnitTest.reference.bit";
123 /
"regression" /
"Virtex7UnitTest.generated.bit";
126 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
127 BOOST_REQUIRE(fileStream.good());
129 bitstream.
read(fileStream,
false);
131 std::cout << bitstream << std::endl;
134 std::string designName = bitstream.getDesignName();
135 std::string deviceName = bitstream.getDeviceName();
136 std::string designDate = bitstream.getDesignDate();
137 std::string designTime = bitstream.getDesignTime();
139 std::cout <<
"family of " << deviceName <<
" is " << deviceDesignator.
getFamily() << std::endl;
142 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
143 BOOST_REQUIRE(outputStream.good());
144 bitstream.write(outputStream);
145 outputStream.flush();
172 int& argc = boost::unit_test::framework::master_test_suite().argc;
173 char**& argv = boost::unit_test::framework::master_test_suite().argv;
175 BOOST_REQUIRE(argc >= 1);
182 torc::common::DeviceVector::const_iterator dp = devices.begin();
183 torc::common::DeviceVector::const_iterator de = devices.end();
186 if(device.empty())
break;
195 torc::common::DeviceVector::const_iterator dp = devices.begin();
196 torc::common::DeviceVector::const_iterator de = devices.end();
199 if(device.empty())
break;
208 torc::common::DeviceVector::const_iterator dp = devices.begin();
209 torc::common::DeviceVector::const_iterator de = devices.end();
212 if(device.empty())
break;
214 if(device !=
"xc7v585t" && device !=
"xc7vx330t" && device !=
"xc7vx415t"
215 && device !=
"xc7vx485t" && device !=
"xc7vx550t" && device !=
"xc7vx690t"
216 && device !=
"xc7vx980t")
continue;
225 torc::common::DeviceVector::const_iterator dp = devices.begin();
226 torc::common::DeviceVector::const_iterator de = devices.end();
229 if(device.empty())
break;
230 if(device !=
"xc7z045")
continue;
260 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
261 std::cerr <<
"Trying to read: " << referencePath << std::endl;
262 BOOST_REQUIRE(fileStream.good());
264 bitstream.
read(fileStream,
false);
269 typedef std::map<Virtex7::FrameAddress, Virtex7::FrameAddress> FrameAddressMap;
270 FrameAddressMap fars;
272 Virtex7::const_iterator p = bitstream.begin();
273 Virtex7::const_iterator e = bitstream.end();
278 if(packet.
getHeader() != header)
continue;
282 fars[base] = std::max(fars[base], far);
285 FrameAddressMap::const_iterator fp = fars.begin();
286 FrameAddressMap::const_iterator fe = fars.end();
288 const FrameAddressMap::value_type& value = *fp++;
297 bitstream.initializeDeviceInfo(inDeviceName);
298 bitstream.initializeFrameMaps();
305 bool enabled =
false;
306 Virtex7::const_iterator p = bitstream.begin();
307 Virtex7::const_iterator e = bitstream.end();
314 if(packet.
getHeader() == enable) enabled =
true;
315 if(!enabled)
continue;
316 if(packet.
getHeader() != header)
continue;
319 Virtex7::FrameAddressToIndex::iterator found = farRemaining.find(far);
320 if(found != farRemaining.end()) {
321 farRemaining.erase(found);
323 std::cerr <<
"missing " << far <<
" ";
328 Virtex7::FrameAddressToIndex::const_iterator p = farRemaining.begin();
329 Virtex7::FrameAddressToIndex::const_iterator e = farRemaining.end();
331 std::cerr <<
"remaining " << (*p++).first <<
" ";
333 std::cerr << std::endl;
336 std::cout <<
"Device: " << inDeviceName << std::endl;
337 std::cout <<
"Size of farRemaining: " << farRemaining.size() << std::endl;
338 std::cout <<
"Size of farVisited: " << farVisited.size() << std::endl;
339 BOOST_CHECK_EQUAL(farRemaining.size(), 0u);
340 BOOST_CHECK_EQUAL(farVisited.size(), bitstream.mFrameAddressToIndex.size());
344 for(
int half = 0; half < 2; half++) {
346 for(uint32_t row = 0; row < 2; row++) {
347 typedef std::map<uint32_t, uint32_t> ColumnMaxFrame;
349 Virtex7::const_iterator p = bitstream.begin();
350 Virtex7::const_iterator e = bitstream.end();
355 if(packet.
getHeader() != header)
continue;
370 std::cerr << std::endl;
371 uint32_t frameCount = 0;
374 uint32_t majorCount = maxFrames[blockType].size();
375 for(uint32_t major = 0; major < majorCount; major++) {
376 frameCount += maxFrames[blockType][major] + 1;
377 std::cerr << blockType <<
"(" << major <<
"): "
378 << (maxFrames[blockType][major] + 1) <<
" (" << frameCount <<
")"
394 /
"torc" /
"bitstream" /
"Virtex7UnitTest.reference.bit";
395 std::fstream fileStream(bitstreamPath.string().c_str(), std::ios::binary | std::ios::in);
396 BOOST_REQUIRE(fileStream.good());
400 bitstream.
read(fileStream);
401 bitstream.initializeDeviceInfo(bitstream.getDeviceName());
402 bitstream.initializeFrameMaps();
403 bitstream.readFramePackets();
412 /
"torc" /
"bitstream" /
"Virtex7UnitTest.reference.bit";
414 /
"regression" /
"Virtex7WriteUnitTest.generated.bit";
417 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
418 BOOST_REQUIRE(fileStream.good());
420 bitstream.
read(fileStream,
false);
422 std::cout << bitstream << std::endl;
426 bitstream.initializeDeviceInfo(designator.getDeviceName());
427 bitstream.initializeFrameMaps();
428 bitstream.readFramePackets();
431 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
432 BOOST_REQUIRE(outputStream.good());
440 bitstream.getFrameBlocks().mBlock[0][7661]->setDirty();
443 bitstream.write(outputStream);
444 outputStream.flush();
445 std::cout << bitstream << std::endl;
453 std::fstream refFileStream(
"v7_routing.bit", std::ios::binary | std::ios::in);
454 std::fstream genFileStream(
"v7_routing.custom.bit", std::ios::binary | std::ios::in);
455 BOOST_REQUIRE(refFileStream.good());
456 BOOST_REQUIRE(genFileStream.good());
457 Virtex7 refBitstream;
458 Virtex7 genBitstream;
459 refBitstream.read(refFileStream,
false);
460 genBitstream.read(genFileStream,
false);
463 refBitstream.initializeDeviceInfo(designator.getDeviceName());
464 genBitstream.initializeDeviceInfo(designator.getDeviceName());
465 refBitstream.initializeFrameMaps();
466 genBitstream.initializeFrameMaps();
467 refBitstream.readFramePackets();
468 genBitstream.readFramePackets();
478 VirtexFrameSet::iterator rp = refFrameSet.begin();
479 VirtexFrameSet::iterator re = refFrameSet.end();
480 VirtexFrameSet::iterator gp = genFrameSet.begin();
481 VirtexFrameSet::iterator ge = genFrameSet.end();
482 while(rp < re && gp < ge) {
487 uint32_t length = refFrame->getLength();
489 const word_t* refWords = refFrame->getWords();
490 const word_t* genWords = genFrame->getWords();
492 const word_t* refWordsEnd = refWords + length;
493 while(refWords < refWordsEnd) {
494 if(*refWords++ != *genWords++) {
496 Virtex7::FrameAddress frameAddress = refBitstream.mFrameIndexToAddress[index];
498 std::cout <<
" Difference in frame index " << index <<
": "
499 << frameAddress << std::endl;
511 uint32_t xdlRow = 277;
512 uint32_t xdlCol = 225;
513 uint32_t primaryXdlCol = refBitstream.getPrimaryXdlColumn(xdlRow, xdlCol);
514 VirtexFrameBlocks frameBlocks = refBitstream.getXdlFrames(xdlRow, primaryXdlCol, beginBit,
527 BOOST_AUTO_TEST_SUITE_END()
Header for torc::bitstream output stream helpers.
Encapsulation of a device designator and its constituent elements.
Header for the DeviceInfoHelper class.
const EFamily & getFamily(void) const
Returns the device family.
static const DeviceVector & getArtix7Devices(void)
Returns the Artix7 devices.
Header for the DirectoryTree class.
std::map< Virtex7::FrameAddress, uint32_t > FrameAddressToIndex
Map from frame address to frame index.
Header for the DeviceDesignator class.
FrameSet< VirtexFrame > VirtexFrameSet
Virtex frame set type.
EFarBlockType
Frame Address Register block type constants.
Header for Boost.Test helper functions.
static const DeviceVector & getZynq7000Devices(void)
Returns the Zynq7000 devices.
Encapsulation of filesystem paths that are used by the library.
static const char * sPacketTypeName[ePacketTypeCount]
Configuration controller registers.
static const char * sCommandName[eCommandCount]
Configuration Command names.
Header for the Devices class.
boost::filesystem::path path
void testVirtex7Device(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
static const boost::filesystem::path & getWorkingPath(void)
Returns the absolute path to the working directory.
boost::shared_ptr< VirtexFrame > VirtexFrameSharedPtr
Virtex frame type.
static const char * sRegisterName[eRegisterCount]
Configuration Register names.
Header for the DDB class.
FrameBlocks< VirtexFrame > VirtexFrameBlocks
Virtex frame blocks type.
static const char * sOpcodeName[eOpcodeCount]
Packet Opcode names.
bool fileContentsAreEqual(const boost::filesystem::path &inA, const boost::filesystem::path &inB)
Compare the raw contents of two files to determine whether they are identical.
Bitstream packet for Virtex class architectures.
static uint32_t makeHeader(EPacketType inType, EOpcode inOpcode, uint32_t inAddress, uint32_t inCount)
Construct a packet header.
BOOST_AUTO_TEST_CASE(hexCharacterToDec)
std::vector< std::string > DeviceVector
Vector of device names.
virtual void read(std::istream &inStream, bool inCleanDateAndTime=true)
Read the bitstream header and packets from a stream.
static const DeviceVector & getVirtex7Devices(void)
Returns the Virtex7 devices.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
uint32_t getHeader(void) const
WORD_TYPE word_t
Frame word type.
Header for the Virtex7 class.
static const DeviceVector & getKintex7Devices(void)
Returns the Virtex7L devices.