00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <boost/test/unit_test.hpp>
00020 #include "torc/bitstream/VirtexPacket.hpp"
00021 #include "torc/bitstream/Virtex4.hpp"
00022 #include "torc/common/DirectoryTree.hpp"
00023 #include <fstream>
00024 #include <iostream>
00025 #include <iomanip>
00026
00027 namespace torc {
00028 namespace bitstream {
00029
00030 BOOST_AUTO_TEST_SUITE(bitstream)
00031
00032
00033 BOOST_AUTO_TEST_CASE(VirtexPacketUnitTest) {
00034
00035
00036 boost::filesystem::path regressionPath
00037 = torc::common::DirectoryTree::getExecutablePath() / "regression";
00038 boost::filesystem::path generatedPath = regressionPath / "Virtex4UnitTest.generated.bit";
00039 boost::filesystem::path referencePath = regressionPath / "Virtex4UnitTest.reference.bit";
00040
00041
00042 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
00043 BOOST_REQUIRE(fileStream.good());
00044 Virtex4 bitstream;
00045 bitstream.readHeader(fileStream);
00046 std::string designName = bitstream.getDesignName();
00047 std::string deviceName = bitstream.getDeviceName();
00048 std::string designDate = bitstream.getDesignDate();
00049 std::string designTime = bitstream.getDesignTime();
00050 uint32_t bitstreamWordLength = bitstream.getBitstreamByteLength() >> 2;
00051 std::cout << bitstream << std::endl;
00052
00053
00054 uint32_t cumulativeWordLength = 0;
00055 std::vector<VirtexPacket> packets;
00056 while(cumulativeWordLength < bitstreamWordLength) {
00057 VirtexPacket packet = VirtexPacket::read(fileStream);
00058 packets.push_back(packet);
00059 cumulativeWordLength += packet.getWordSize();
00060 }
00061
00062 cumulativeWordLength = 0;
00063 std::vector<VirtexPacket>::iterator p = packets.begin();
00064 std::vector<VirtexPacket>::iterator e = packets.end();
00065 while(p < e) {
00066 VirtexPacket& packet = *p++;
00067 cumulativeWordLength += packet.getWordSize();
00068 }
00069
00070 }
00071
00072 BOOST_AUTO_TEST_SUITE_END()
00073
00074 }
00075 }