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);
56 BOOST_CHECK_EQUAL(mask, 0x07FFFE00u);
110 /
"torc" /
"bitstream" /
"Spartan3EUnitTest.reference.bit";
112 /
"regression" /
"Spartan3EUnitTest.generated.bit";
115 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
116 BOOST_REQUIRE(fileStream.good());
118 bitstream.
read(fileStream,
false);
120 std::cout << bitstream << std::endl;
122 std::string designName = bitstream.getDesignName();
123 std::string deviceName = bitstream.getDeviceName();
124 std::string designDate = bitstream.getDesignDate();
125 std::string designTime = bitstream.getDesignTime();
127 std::cout <<
"family of " << deviceName <<
" is " << deviceDesignator.
getFamily() << std::endl;
130 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
131 BOOST_REQUIRE(outputStream.good());
132 bitstream.write(outputStream);
133 outputStream.flush();
183 int& argc = boost::unit_test::framework::master_test_suite().argc;
184 char**& argv = boost::unit_test::framework::master_test_suite().argv;
186 BOOST_REQUIRE(argc >= 1);
192 torc::common::DeviceVector::const_iterator dp = devices.begin();
193 torc::common::DeviceVector::const_iterator de = devices.end();
196 if(device.empty())
break;
223 std::cerr <<
"TRYING TO FIND " << referencePath << std::endl;
226 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
227 std::cerr <<
"Trying to read: " << referencePath << std::endl;
228 BOOST_REQUIRE(fileStream.good());
230 bitstream.
read(fileStream,
false);
238 bitstream.initializeDeviceInfo(inDeviceName);
239 bitstream.initializeFrameMaps();
246 Spartan3E::const_iterator p = bitstream.begin();
247 Spartan3E::const_iterator e = bitstream.end();
252 if(packet.
getHeader() != header)
continue;
253 if(first) { first =
false;
continue; }
257 Spartan3E::FrameAddressToIndex::iterator found = farRemaining.find(far);
258 if(found != farRemaining.end()) {
259 farRemaining.erase(found);
261 std::cerr <<
"missing " << far <<
" ";
266 std::cerr << std::endl;
267 Spartan3E::FrameAddressToIndex::const_iterator p = farRemaining.begin();
268 Spartan3E::FrameAddressToIndex::const_iterator e = farRemaining.end();
270 std::cerr <<
"remaining " << p->first <<
" ";
273 std::cerr << std::endl;
276 std::cout <<
"Device: " << inDeviceName << std::endl;
277 std::cout <<
"Size of farRemaining: " << farRemaining.size() << std::endl;
278 std::cout <<
"Size of farVisited: " << farVisited.size() << std::endl;
279 BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
280 BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
285 BOOST_AUTO_TEST_SUITE_END()
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
Header for torc::bitstream output stream helpers.
static const char * sRegisterName[eRegisterCount]
Configuration register names.
Encapsulation of a device designator and its constituent elements.
Header for the DeviceInfoHelper class.
const EFamily & getFamily(void) const
Returns the device family.
std::map< Spartan3E::FrameAddress, uint32_t > FrameAddressToIndex
Map from frame address to frame index.
static const char * sCommandName[eCommandCount]
Configuration command names.
Header for the DirectoryTree class.
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
Header for the DeviceDesignator class.
Header for Boost.Test helper functions.
static uint32_t makeHeader(EPacketType inType, EOpcode inOpcode, uint32_t inAddress, uint32_t inCount)
Construct a packet header.
Encapsulation of filesystem paths that are used by the library.
static const DeviceVector & getSpartan3EDevices(void)
Returns the Spartan3E devices.
Header for the Devices class.
boost::filesystem::path path
uint32_t getHeader(void) const
static const boost::filesystem::path & getWorkingPath(void)
Returns the absolute path to the working directory.
Header for the DDB class.
Header for the Spartan3E 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 Spartan class architectures.
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 boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
void testSpartan3EDevice(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)