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/SpartanPacket.hpp"
00021 #include "torc/bitstream/Spartan3E.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 BOOST_AUTO_TEST_CASE(SpartanPacketUnitTest) {
00033
00034
00035 boost::filesystem::path regressionPath
00036 = torc::common::DirectoryTree::getExecutablePath() / "regression";
00037 boost::filesystem::path generatedPath = regressionPath / "Spartan3EUnitTest.generated.bit";
00038 boost::filesystem::path referencePath = regressionPath / "Spartan3EUnitTest.reference.bit";
00039
00040
00041 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
00042 BOOST_REQUIRE(fileStream.good());
00043 Spartan3E bitstream;
00044 bitstream.readHeader(fileStream);
00045 std::string designName = bitstream.getDesignName();
00046 std::string deviceName = bitstream.getDeviceName();
00047 std::string designDate = bitstream.getDesignDate();
00048 std::string designTime = bitstream.getDesignTime();
00049 uint32_t bitstreamWordLength = bitstream.getBitstreamByteLength() >> 2;
00050 std::cout << bitstream << std::endl;
00051
00052
00053 uint32_t cumulativeWordLength = 0;
00054 std::vector<SpartanPacket> packets;
00055 while(cumulativeWordLength < bitstreamWordLength) {
00056 SpartanPacket packet = SpartanPacket::read(fileStream);
00057 packets.push_back(packet);
00058 cumulativeWordLength += packet.getWordSize();
00059 }
00060
00061 cumulativeWordLength = 0;
00062 std::vector<SpartanPacket>::iterator p = packets.begin();
00063 std::vector<SpartanPacket>::iterator e = packets.end();
00064 while(p < e) {
00065 SpartanPacket& packet = *p++;
00066 cumulativeWordLength += packet.getWordSize();
00067 }
00068
00069 }
00070
00071 BOOST_AUTO_TEST_SUITE_END()
00072
00073 }
00074 }