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);
102 /
"torc" /
"bitstream" /
"VirtexEUnitTest.reference.bit";
104 /
"regression" /
"VirtexEUnitTest.generated.bit";
107 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
108 BOOST_REQUIRE(fileStream.good());
110 bitstream.
read(fileStream,
false);
112 std::cout << bitstream << std::endl;
114 std::string designName = bitstream.getDesignName();
115 std::string deviceName = bitstream.getDeviceName();
116 std::string designDate = bitstream.getDesignDate();
117 std::string designTime = bitstream.getDesignTime();
119 std::cout <<
"family of " << deviceName <<
" is " << deviceDesignator.
getFamily() << std::endl;
122 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
123 BOOST_REQUIRE(outputStream.good());
124 bitstream.write(outputStream);
125 outputStream.flush();
176 int& argc = boost::unit_test::framework::master_test_suite().argc;
177 char**& argv = boost::unit_test::framework::master_test_suite().argv;
179 BOOST_REQUIRE(argc >= 1);
185 torc::common::DeviceVector::const_iterator dp = devices.begin();
186 torc::common::DeviceVector::const_iterator de = devices.end();
189 if(device.empty())
break;
216 std::cerr <<
"TRYING TO FIND " << referencePath << std::endl;
219 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
220 std::cerr <<
"Trying to read: " << referencePath << std::endl;
221 BOOST_REQUIRE(fileStream.good());
223 bitstream.
read(fileStream,
false);
231 bitstream.initializeDeviceInfo(inDeviceName);
232 bitstream.initializeFrameMaps();
239 VirtexE::const_iterator p = bitstream.begin();
240 VirtexE::const_iterator e = bitstream.end();
245 if(packet.
getHeader() != header)
continue;
246 if(first) { first =
false;
continue; }
250 VirtexE::FrameAddressToIndex::iterator found = farRemaining.find(far);
251 if(found != farRemaining.end()) {
252 farRemaining.erase(found);
254 std::cerr <<
"missing " << far <<
" ";
259 std::cout <<
"Device: " << inDeviceName << std::endl;
260 std::cout <<
"Size of farRemaining: " << farRemaining.size() << std::endl;
261 std::cout <<
"Size of farVisited: " << farVisited.size() << std::endl;
262 BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
263 BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
273 int& argc = boost::unit_test::framework::master_test_suite().argc;
274 char**& argv = boost::unit_test::framework::master_test_suite().argv;
276 BOOST_REQUIRE(argc >= 1);
286 /
"torc" /
"bitstream" /
"VirtexEUnitTest.reference.bit";
288 /
"regression" /
"VirtexEMapUnitTest.generated.bit";
291 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
292 BOOST_REQUIRE(fileStream.good());
295 bitstream.
read(fileStream,
false);
298 bitstream.initializeDeviceInfo(
"xcv50e");
299 bitstream.initializeFrameMaps();
302 bitstream.initializeFullFrameBlocks();
305 uint32_t frameLength = bitstream.getFrameLength();
306 typedef boost::shared_array<uint32_t> WordSharedArray;
307 VirtexE::iterator p = bitstream.begin();
308 VirtexE::iterator e = bitstream.end();
312 WordSharedArray words = packet.
getWords();
313 uint32_t* ptr = words.get();
314 for(uint32_t block = 0; block < 8; block++) {
315 for(uint32_t frame = 0; frame < bitstream.mBlockFrameIndexBounds[block]; frame++) {
317 for(uint32_t index = 0; index < frameLength; index++) {
318 *ptr++ = words[index];
328 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
329 BOOST_REQUIRE(outputStream.good());
330 bitstream.write(outputStream);
331 outputStream.flush();
337 BOOST_AUTO_TEST_SUITE_END()
Header for torc::bitstream output stream helpers.
Header for the VirtexE class.
static const DeviceVector & getVirtexEDevices(void)
Returns the VirtexE devices.
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.
void testVirtexEDevice(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
void testVirtexEFullMapping(const boost::filesystem::path &inWorkingPath)
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
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.
VirtexE bitstream inherited from Virtex bitstream.
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 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