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);
55 BOOST_CHECK_EQUAL(mask, 0x07FFFE00u);
111 /
"torc" /
"bitstream" /
"Virtex2PUnitTest.reference.bit";
113 /
"regression" /
"Virtex2PUnitTest.generated.bit";
116 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
117 BOOST_REQUIRE(fileStream.good());
119 bitstream.
read(fileStream,
false);
121 std::cout << bitstream << std::endl;
123 std::string designName = bitstream.getDesignName();
124 std::string deviceName = bitstream.getDeviceName();
125 std::string designDate = bitstream.getDesignDate();
126 std::string designTime = bitstream.getDesignTime();
128 std::cout <<
"family of " << deviceName <<
" is " << deviceDesignator.
getFamily() << std::endl;
131 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
132 BOOST_REQUIRE(outputStream.good());
133 bitstream.write(outputStream);
134 outputStream.flush();
185 int& argc = boost::unit_test::framework::master_test_suite().argc;
186 char**& argv = boost::unit_test::framework::master_test_suite().argv;
188 BOOST_REQUIRE(argc >= 1);
194 torc::common::DeviceVector::const_iterator dp = devices.begin();
195 torc::common::DeviceVector::const_iterator de = devices.end();
198 if(device.empty())
break;
210 std::cerr <<
"TRYING TO FIND " << referencePath << std::endl;
213 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
214 std::cerr <<
"Trying to read: " << referencePath << std::endl;
215 BOOST_REQUIRE(fileStream.good());
217 bitstream.
read(fileStream,
false);
225 bitstream.initializeDeviceInfo(inDeviceName);
226 bitstream.initializeFrameMaps();
233 Virtex2P::const_iterator p = bitstream.begin();
234 Virtex2P::const_iterator e = bitstream.end();
239 if(packet.
getHeader() != header)
continue;
240 if(first) { first =
false;
continue; }
244 Virtex2P::FrameAddressToIndex::iterator found = farRemaining.find(far);
245 if(found != farRemaining.end()) {
246 farRemaining.erase(found);
248 std::cerr <<
"missing " << far <<
" ";
253 std::cout <<
"Device: " << inDeviceName << std::endl;
254 std::cout <<
"Size of farRemaining: " << farRemaining.size() << std::endl;
255 std::cout <<
"Size of farVisited: " << farVisited.size() << std::endl;
256 BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
257 BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
268 int& argc = boost::unit_test::framework::master_test_suite().argc;
269 char**& argv = boost::unit_test::framework::master_test_suite().argv;
271 BOOST_REQUIRE(argc >= 1);
281 /
"torc" /
"bitstream" /
"Virtex2PUnitTest.reference.bit";
283 /
"regression" /
"Virtex2PMapUnitTest.generated.bit";
286 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
287 BOOST_REQUIRE(fileStream.good());
290 bitstream.
read(fileStream,
false);
293 bitstream.initializeDeviceInfo(
"xc2vp20");
294 bitstream.initializeFrameMaps();
297 bitstream.initializeFullFrameBlocks();
300 uint32_t frameLength = bitstream.getFrameLength();
301 typedef boost::shared_array<uint32_t> WordSharedArray;
302 Virtex2P::iterator p = bitstream.begin();
303 Virtex2P::iterator e = bitstream.end();
307 WordSharedArray words = packet.
getWords();
308 uint32_t* ptr = words.get();
309 for(uint32_t block = 0; block < 8; block++) {
310 for(uint32_t frame = 0; frame < bitstream.mBlockFrameIndexBounds[block]; frame++) {
312 for(uint32_t index = 0; index < frameLength; index++) {
313 *ptr++ = words[index];
320 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
321 BOOST_REQUIRE(outputStream.good());
322 bitstream.write(outputStream);
323 outputStream.flush();
329 BOOST_AUTO_TEST_SUITE_END()
Header for torc::bitstream output stream helpers.
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
static const DeviceVector & getVirtex2PDevices(void)
Returns the Virtex2P devices.
Encapsulation of a device designator and its constituent elements.
Header for the DeviceInfoHelper class.
Header for the Virtex2P class.
const EFamily & getFamily(void) const
Returns the device family.
Header for the DirectoryTree class.
void testVirtex2PDevice(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
Header for the DeviceDesignator class.
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
void testVirtex2PFullMapping(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 * sCommandName[eCommandCount]
Configuration command names.
Header for the DDB class.
static const char * sPacketTypeName[ePacketTypeCount]
Packet type 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.
std::map< Virtex2::FrameAddress, uint32_t > FrameAddressToIndex
Map from frame address to frame index.
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 * sRegisterName[eRegisterCount]
Configuration register names.
Virtex2P bitstream inherited from Virtex2 bitstream.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
uint32_t getHeader(void) const