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, 0x007FFFFFu);
111 uint32_t u1 = 0xffffffff & mask;
113 uint32_t u2 = 0xffff0000 & mask;
115 uint32_t u3 = 0xff00ff00 & mask;
117 uint32_t u4 = 0xf0f0f0f0 & mask;
119 uint32_t u5 = 0xcccccccc & mask;
121 uint32_t u6 = 0xaaaaaaaa & mask;
126 /
"torc" /
"bitstream" /
"Virtex4UnitTest.reference.bit";
128 /
"regression" /
"Virtex4UnitTest.generated.bit";
131 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
132 BOOST_REQUIRE(fileStream.good());
134 bitstream.
read(fileStream,
false);
136 std::cout << bitstream << std::endl;
138 std::string designName = bitstream.getDesignName();
139 std::string deviceName = bitstream.getDeviceName();
140 std::string designDate = bitstream.getDesignDate();
141 std::string designTime = bitstream.getDesignTime();
143 std::cout <<
"family of " << deviceName <<
" is " << deviceDesignator.
getFamily() << std::endl;
146 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
147 BOOST_REQUIRE(outputStream.good());
148 bitstream.write(outputStream);
149 outputStream.flush();
200 int& argc = boost::unit_test::framework::master_test_suite().argc;
201 char**& argv = boost::unit_test::framework::master_test_suite().argv;
203 BOOST_REQUIRE(argc >= 1);
209 torc::common::DeviceVector::const_iterator dp = devices.begin();
210 torc::common::DeviceVector::const_iterator de = devices.end();
213 if(device.empty())
break;
240 std::cerr <<
"TRYING TO FIND " << referencePath << std::endl;
243 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
244 std::cerr <<
"Trying to read: " << referencePath << std::endl;
245 BOOST_REQUIRE(fileStream.good());
247 bitstream.
read(fileStream,
false);
255 bitstream.initializeDeviceInfo(inDeviceName);
256 bitstream.initializeFrameMaps();
263 Virtex4::const_iterator p = bitstream.begin();
264 Virtex4::const_iterator e = bitstream.end();
269 if(packet.
getHeader() != header)
continue;
270 if(first) { first =
false;
continue; }
273 Virtex4::FrameAddressToIndex::iterator found = farRemaining.find(far);
274 if(found != farRemaining.end()) {
275 farRemaining.erase(found);
277 std::cerr <<
"missing " << far <<
" ";
282 std::cout <<
"Device: " << inDeviceName << std::endl;
283 std::cout <<
"Size of farRemaining: " << farRemaining.size() << std::endl;
284 std::cout <<
"Size of farVisited: " << farVisited.size() << std::endl;
285 BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
286 BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
292 for(
int half = 0; half < 2; half++) {
293 for(uint32_t row = 0; row < 2; row++) {
294 typedef std::map<uint32_t, uint32_t> ColumnMaxFrame;
296 Virtex4::const_iterator p = bitstream.begin();
297 Virtex4::const_iterator e = bitstream.end();
302 if(packet.
getHeader() != header)
continue;
317 std::cerr << std::endl;
318 uint32_t frameCount = 0;
321 uint32_t majorCount = maxFrames[blockType].size();
322 for(uint32_t major = 0; major < majorCount; major++) {
323 frameCount += maxFrames[blockType][major] + 1;
324 std::cerr << blockType <<
"(" << major <<
"): "
325 << (maxFrames[blockType][major] + 1) <<
" (" << frameCount <<
")"
340 int& argc = boost::unit_test::framework::master_test_suite().argc;
341 char**& argv = boost::unit_test::framework::master_test_suite().argv;
343 BOOST_REQUIRE(argc >= 1);
354 /
"torc" /
"bitstream" /
"Virtex4UnitTest.reference.bit";
356 /
"regression" /
"Virtex4MapUnitTest.generated.bit";
359 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
360 BOOST_REQUIRE(fileStream.good());
363 bitstream.
read(fileStream,
false);
366 bitstream.initializeDeviceInfo(
"xc4vlx15");
367 bitstream.initializeFrameMaps();
370 bitstream.readFramePackets();
373 uint32_t frameLength = bitstream.getFrameLength();
374 typedef boost::shared_array<uint32_t> WordSharedArray;
375 Virtex4::iterator p = bitstream.begin();
376 Virtex4::iterator e = bitstream.end();
380 WordSharedArray words = packet.
getWords();
381 uint32_t* ptr = words.get();
382 for(uint32_t block = 0; block < 8; block++) {
383 for(uint32_t frame = 0; frame < bitstream.mBlockFrameIndexBounds[block]; frame++) {
385 for(uint32_t index = 0; index < frameLength; index++) {
386 *ptr++ = words[index];
393 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
394 BOOST_REQUIRE(outputStream.good());
395 bitstream.write(outputStream);
396 outputStream.flush();
402 BOOST_AUTO_TEST_SUITE_END()
Header for torc::bitstream output stream helpers.
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
Encapsulation of a device designator and its constituent elements.
Header for the Virtex4 class.
Header for the DeviceInfoHelper class.
const EFamily & getFamily(void) const
Returns the device family.
Header for the DirectoryTree class.
Header for the DeviceDesignator class.
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
std::map< Virtex4::FrameAddress, uint32_t > FrameAddressToIndex
Map from frame address to frame index.
static const char * sCommandName[eCommandCount]
Configuration command names.
Header for Boost.Test helper functions.
static const char * sRegisterName[eRegisterCount]
Configuration register names.
VirtexFrame::word_t word_t
FrameSet word type.
EFarBlockType
Frame Address Register block type constants.
Encapsulation of filesystem paths that are used by the library.
static const DeviceVector & getVirtex4Devices(void)
Returns the Virtex4 devices.
Header for the Devices class.
boost::filesystem::path path
void testVirtex4PartialMapping(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.
Header for the DDB class.
void testVirtex4FullMapping(const boost::filesystem::path &inWorkingPath)
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.
void testVirtex4Device(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
uint32_t getHeader(void) const