19 #include <boost/test/unit_test.hpp>
30 #include <boost/filesystem.hpp>
35 BOOST_AUTO_TEST_SUITE(bitstream)
49 BOOST_CHECK_EQUAL(mask, 0xFFFFFFFFu);
53 BOOST_CHECK_EQUAL(mask, 0xFFFFFFFFu);
57 BOOST_CHECK_EQUAL(mask, 0x07FFFE00u);
103 /
"torc" /
"bitstream" /
"VirtexUnitTest.reference.bit";
105 /
"regression" /
"VirtexUnitTest.generated.bit";
108 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
109 BOOST_REQUIRE(fileStream.good());
111 bitstream.
read(fileStream,
false);
113 std::cout << bitstream << std::endl;
115 std::string designName = bitstream.getDesignName();
116 std::string deviceName = bitstream.getDeviceName();
117 std::string designDate = bitstream.getDesignDate();
118 std::string designTime = bitstream.getDesignTime();
120 std::cout <<
"family of " << deviceName <<
" is " << deviceDesignator.
getFamily() << std::endl;
123 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
124 BOOST_REQUIRE(outputStream.good());
125 bitstream.write(outputStream);
126 outputStream.flush();
177 int& argc = boost::unit_test::framework::master_test_suite().argc;
178 char**& argv = boost::unit_test::framework::master_test_suite().argv;
180 BOOST_REQUIRE(argc >= 1);
186 torc::common::DeviceVector::const_iterator dp = devices.begin();
187 torc::common::DeviceVector::const_iterator de = devices.end();
190 if(device.empty())
break;
217 std::cerr <<
"TRYING TO FIND " << referencePath << std::endl;
220 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
221 std::cerr <<
"Trying to read: " << referencePath << std::endl;
222 BOOST_REQUIRE(fileStream.good());
224 bitstream.
read(fileStream,
false);
232 bitstream.initializeDeviceInfo(inDeviceName);
233 bitstream.initializeFrameMaps();
240 Virtex::const_iterator p = bitstream.begin();
241 Virtex::const_iterator e = bitstream.end();
246 if(packet.
getHeader() != header)
continue;
247 if(first) { first =
false;
continue; }
251 Virtex::FrameAddressToIndex::iterator found = farRemaining.find(far);
252 if(found != farRemaining.end()) {
253 farRemaining.erase(found);
255 std::cerr <<
"missing " << far <<
" ";
260 std::cout <<
"Device: " << inDeviceName << std::endl;
261 std::cout <<
"Size of farRemaining: " << farRemaining.size() << std::endl;
262 std::cout <<
"Size of farVisited: " << farVisited.size() << std::endl;
263 BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
264 BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
318 int& argc = boost::unit_test::framework::master_test_suite().argc;
319 char**& argv = boost::unit_test::framework::master_test_suite().argv;
321 BOOST_REQUIRE(argc >= 1);
331 /
"torc" /
"bitstream" /
"VirtexUnitTest.reference.bit";
333 /
"regression" /
"VirtexMapUnitTest.generated.bit";
336 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
337 BOOST_REQUIRE(fileStream.good());
340 bitstream.
read(fileStream,
false);
343 bitstream.initializeDeviceInfo(
"xcv50");
344 bitstream.initializeFrameMaps();
347 bitstream.initializeFullFrameBlocks();
350 uint32_t frameLength = bitstream.getFrameLength();
351 typedef boost::shared_array<uint32_t> WordSharedArray;
352 Virtex::iterator p = bitstream.begin();
353 Virtex::iterator e = bitstream.end();
357 WordSharedArray words = packet.
getWords();
358 uint32_t* ptr = words.get();
359 for(uint32_t block = 0; block < 8; block++) {
360 for(uint32_t frame = 0; frame < bitstream.mBlockFrameIndexBounds[block]; frame++) {
362 for(uint32_t index = 0; index < frameLength; index++) {
363 *ptr++ = words[index];
370 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
371 BOOST_REQUIRE(outputStream.good());
372 bitstream.write(outputStream);
373 outputStream.flush();
379 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.
std::map< Virtex::FrameAddress, uint32_t > FrameAddressToIndex
Map from frame address to frame index.
const EFamily & getFamily(void) const
Returns the device family.
Header for the DirectoryTree class.
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
Header for the DeviceDesignator class.
static const char * sRegisterName[eRegisterCount]
Configuration register names.
Header for Boost.Test helper functions.
VirtexFrame::word_t word_t
FrameSet word type.
Encapsulation of filesystem paths that are used by the library.
Header for the Devices class.
boost::filesystem::path path
Header for the Virtex class.
void testVirtexFullMapping(const boost::filesystem::path &inWorkingPath)
static const boost::filesystem::path & getWorkingPath(void)
Returns the absolute path to the working directory.
const WordSharedArray getWords(void) const
brief Returns the raw packet words, including the header word.
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
Header for the DDB class.
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 const DeviceVector & getVirtexDevices(void)
Returns the Virtex devices.
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 char * sCommandName[eCommandCount]
Configuration command names.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
uint32_t getHeader(void) const
void testVirtexDevice(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)