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" /
"Virtex2UnitTest.reference.bit";
113 /
"regression" /
"Virtex2UnitTest.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;
225 std::cerr <<
"TRYING TO FIND " << referencePath << std::endl;
228 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
229 std::cerr <<
"Trying to read: " << referencePath << std::endl;
230 BOOST_REQUIRE(fileStream.good());
232 bitstream.
read(fileStream,
false);
240 bitstream.initializeDeviceInfo(inDeviceName);
241 bitstream.initializeFrameMaps();
248 Virtex2::const_iterator p = bitstream.begin();
249 Virtex2::const_iterator e = bitstream.end();
254 if(packet.
getHeader() != header)
continue;
255 if(first) { first =
false;
continue; }
259 Virtex2::FrameAddressToIndex::iterator found = farRemaining.find(far);
260 if(found != farRemaining.end()) {
261 farRemaining.erase(found);
263 std::cerr <<
"missing " << far <<
" ";
268 std::cout <<
"Device: " << inDeviceName << std::endl;
269 std::cout <<
"Size of farRemaining: " << farRemaining.size() << std::endl;
270 std::cout <<
"Size of farVisited: " << farVisited.size() << std::endl;
271 BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
272 BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
283 int& argc = boost::unit_test::framework::master_test_suite().argc;
284 char**& argv = boost::unit_test::framework::master_test_suite().argv;
286 BOOST_REQUIRE(argc >= 1);
296 /
"torc" /
"bitstream" /
"Virtex2UnitTest.reference.bit";
298 /
"regression" /
"Virtex2MapUnitTest.generated.bit";
301 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
302 BOOST_REQUIRE(fileStream.good());
305 bitstream.
read(fileStream,
false);
308 bitstream.initializeDeviceInfo(
"xc2v40");
309 bitstream.initializeFrameMaps();
312 bitstream.initializeFullFrameBlocks();
315 uint32_t frameLength = bitstream.getFrameLength();
316 typedef boost::shared_array<uint32_t> WordSharedArray;
317 Virtex2::iterator p = bitstream.begin();
318 Virtex2::iterator e = bitstream.end();
322 WordSharedArray words = packet.
getWords();
323 uint32_t* ptr = words.get();
324 for(uint32_t block = 0; block < 8; block++) {
325 for(uint32_t frame = 0; frame < bitstream.mBlockFrameIndexBounds[block]; frame++) {
327 for(uint32_t index = 0; index < frameLength; index++) {
328 *ptr++ = words[index];
335 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
336 BOOST_REQUIRE(outputStream.good());
337 bitstream.write(outputStream);
338 outputStream.flush();
344 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 DeviceInfoHelper class.
const EFamily & getFamily(void) const
Returns the device family.
Header for the DirectoryTree class.
Header for the DeviceDesignator class.
void testVirtex2Device(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
Header for Boost.Test helper functions.
static const DeviceVector & getVirtex2Devices(void)
Returns the Virtex2 devices.
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 * sCommandName[eCommandCount]
Configuration command names.
Header for the DDB class.
Header for the Virtex2 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)
void testVirtex2FullMapping(const boost::filesystem::path &inWorkingPath)
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.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
uint32_t getHeader(void) const