19 #include <boost/test/unit_test.hpp>
30 #include <boost/filesystem.hpp>
35 BOOST_AUTO_TEST_SUITE(bitstream)
48 BOOST_CHECK_EQUAL(mask, 0xFFFFFFFFu);
52 BOOST_CHECK_EQUAL(mask, 0xFFFFFFFFu);
56 BOOST_CHECK_EQUAL(mask, 0x00FFFFFFu);
123 /
"torc" /
"bitstream" /
"Virtex6UnitTest.reference.bit";
125 /
"regression" /
"Virtex6UnitTest.generated.bit";
128 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
129 BOOST_REQUIRE(fileStream.good());
131 bitstream.
read(fileStream,
false);
135 std::string designName = bitstream.getDesignName();
136 std::string deviceName = bitstream.getDeviceName();
137 std::string designDate = bitstream.getDesignDate();
138 std::string designTime = bitstream.getDesignTime();
143 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
144 BOOST_REQUIRE(outputStream.good());
145 bitstream.write(outputStream);
146 outputStream.flush();
197 int& argc = boost::unit_test::framework::master_test_suite().argc;
198 char**& argv = boost::unit_test::framework::master_test_suite().argv;
200 BOOST_REQUIRE(argc >= 1);
207 torc::common::DeviceVector::const_iterator dp = devices.begin();
208 torc::common::DeviceVector::const_iterator de = devices.end();
211 if(device.empty())
break;
242 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
243 std::cerr <<
"Trying to read: " << referencePath << std::endl;
244 BOOST_REQUIRE(fileStream.good());
246 bitstream.
read(fileStream,
false);
254 bitstream.initializeDeviceInfo(inDeviceName);
255 bitstream.initializeFrameMaps();
262 Virtex6::const_iterator p = bitstream.begin();
263 Virtex6::const_iterator e = bitstream.end();
268 if(packet.
getHeader() != header)
continue;
269 if(first) { first =
false;
continue; }
272 Virtex6::FrameAddressToIndex::iterator found = farRemaining.find(far);
273 if(found != farRemaining.end()) {
274 farRemaining.erase(found);
276 std::cerr <<
"missing " << far <<
" ";
281 Virtex6::FrameAddressToIndex::const_iterator p = farRemaining.begin();
282 Virtex6::FrameAddressToIndex::const_iterator e = farRemaining.end();
284 std::cerr <<
"remaining " << (*p++).first <<
" ";
286 std::cerr << std::endl;
289 std::cout <<
"Device: " << inDeviceName << std::endl;
290 std::cout <<
"Size of farRemaining: " << farRemaining.size() << std::endl;
291 std::cout <<
"Size of farVisited: " << farVisited.size() << std::endl;
292 BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
293 BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
299 for(
int half = 0; half < 2; half++) {
300 for(uint32_t row = 0; row < 2; row++) {
301 typedef std::map<uint32_t, uint32_t> ColumnMaxFrame;
303 Virtex6::const_iterator p = bitstream.begin();
304 Virtex6::const_iterator e = bitstream.end();
309 if(packet.
getHeader() != header)
continue;
324 std::cerr << std::endl;
325 uint32_t frameCount = 0;
328 uint32_t majorCount = maxFrames[blockType].size();
329 for(uint32_t major = 0; major < majorCount; major++) {
330 frameCount += maxFrames[blockType][major] + 1;
331 std::cerr << blockType <<
"(" << major <<
"): "
332 << (maxFrames[blockType][major] + 1) <<
" (" << frameCount <<
")"
347 int& argc = boost::unit_test::framework::master_test_suite().argc;
348 char**& argv = boost::unit_test::framework::master_test_suite().argv;
350 BOOST_REQUIRE(argc >= 1);
361 /
"torc" /
"bitstream" /
"Virtex6UnitTest.reference.bit";
363 /
"regression" /
"Virtex6MapUnitTest.generated.bit";
366 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
367 BOOST_REQUIRE(fileStream.good());
370 bitstream.
read(fileStream,
false);
373 bitstream.initializeDeviceInfo(
"xc6vlx75t");
374 bitstream.initializeFrameMaps();
377 bitstream.readFramePackets();
380 uint32_t frameLength = bitstream.getFrameLength();
381 typedef boost::shared_array<uint32_t> WordSharedArray;
382 Virtex6::iterator p = bitstream.begin();
383 Virtex6::iterator e = bitstream.end();
387 WordSharedArray words = packet.
getWords();
388 uint32_t* ptr = words.get();
389 for(uint32_t block = 0; block < 8; block++) {
390 for(uint32_t frame = 0; frame < bitstream.mBlockFrameIndexBounds[block]; frame++) {
392 for(uint32_t index = 0; index < frameLength; index++) {
393 *ptr++ = words[index];
400 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
401 BOOST_REQUIRE(outputStream.good());
402 bitstream.write(outputStream);
403 outputStream.flush();
409 BOOST_AUTO_TEST_SUITE_END()
Header for torc::bitstream output stream helpers.
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
Encapsulation of a device designator and its constituent elements.
static const char * sRegisterName[eRegisterCount]
Configuration register names.
Header for the DeviceInfoHelper class.
Header for the DirectoryTree class.
std::map< Virtex6::FrameAddress, uint32_t > FrameAddressToIndex
Map from frame address to frame index.
Header for the Virtex6 class.
Header for the DeviceDesignator class.
void testVirtex6FullMapping(const boost::filesystem::path &inWorkingPath)
Header for Boost.Test helper functions.
static const char * sCommandName[eCommandCount]
Configuration command names.
VirtexFrame::word_t word_t
FrameSet word type.
static const DeviceVector & getVirtex6Devices(void)
Returns the Virtex6 devices.
Encapsulation of filesystem paths that are used by the library.
Header for the Devices class.
boost::filesystem::path path
EFarBlockType
Frame Address Register block type constants.
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.
void testVirtex6PartialMapping(const boost::filesystem::path &inWorkingPath)
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 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 boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
uint32_t getHeader(void) const
void testVirtex6Device(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)