19 #include <boost/test/unit_test.hpp>
30 #include <boost/filesystem.hpp>
37 BOOST_AUTO_TEST_SUITE(bitstream)
49 std::cerr << col <<
": " << tileInfo.
getName() <<
", ";
51 std::cerr << std::endl;
58 for(uint32_t xdlCol = 0; xdlCol < 190; xdlCol++) {
60 std::cerr << xdlCol <<
": " << primaryXdlCol <<
", ";
62 std::cerr << std::endl;
77 BOOST_CHECK_EQUAL(mask, 0xFFFFFFFFu);
81 BOOST_CHECK_EQUAL(mask, 0xFFFFFFFFu);
85 BOOST_CHECK_EQUAL(mask, 0x00FFFFFFu);
148 uint32_t u1 = 0xffffffff & mask;
150 uint32_t u2 = 0xffff0000 & mask;
152 uint32_t u3 = 0xff00ff00 & mask;
154 uint32_t u4 = 0xf0f0f0f0 & mask;
156 uint32_t u5 = 0xcccccccc & mask;
158 uint32_t u6 = 0xaaaaaaaa & mask;
163 /
"torc" /
"bitstream" /
"Virtex5UnitTest.reference.bit";
165 /
"regression" /
"Virtex5UnitTest.generated.bit";
168 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
169 BOOST_REQUIRE(fileStream.good());
171 bitstream.
read(fileStream,
false);
173 std::cout << bitstream << std::endl;
175 std::string designName = bitstream.getDesignName();
176 std::string deviceName = bitstream.getDeviceName();
177 std::string designDate = bitstream.getDesignDate();
178 std::string designTime = bitstream.getDesignTime();
180 std::cout <<
"family of " << deviceName <<
" is " << deviceDesignator.
getFamily() << std::endl;
183 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
184 BOOST_REQUIRE(outputStream.good());
185 bitstream.write(outputStream);
186 outputStream.flush();
234 int& argc = boost::unit_test::framework::master_test_suite().argc;
235 char**& argv = boost::unit_test::framework::master_test_suite().argv;
237 BOOST_REQUIRE(argc >= 1);
243 torc::common::DeviceVector::const_iterator dp = devices.begin();
244 torc::common::DeviceVector::const_iterator de = devices.end();
247 if(device.empty())
break;
260 std::cerr <<
"TRYING TO FIND " << referencePath << std::endl;
263 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
264 std::cerr <<
"Trying to read: " << referencePath << std::endl;
265 BOOST_REQUIRE(fileStream.good());
267 std::cerr <<
"test0" << std::endl;
268 bitstream.
read(fileStream,
false);
269 std::cerr <<
"test1" << std::endl;
277 bitstream.initializeDeviceInfo(inDeviceName);
278 std::cerr <<
"test2" << std::endl;
279 bitstream.initializeFrameMaps();
280 std::cerr <<
"test3" << std::endl;
287 Virtex5::const_iterator p = bitstream.begin();
288 Virtex5::const_iterator e = bitstream.end();
293 if(packet.
getHeader() != header)
continue;
294 if(first) { first =
false;
continue; }
297 Virtex5::FrameAddressToIndex::iterator found = farRemaining.find(far);
298 if(found != farRemaining.end()) {
299 farRemaining.erase(found);
301 std::cerr <<
"missing " << far <<
" ";
306 std::cout <<
"Device: " << inDeviceName << std::endl;
307 std::cout <<
"Size of farRemaining: " << farRemaining.size() << std::endl;
308 std::cout <<
"Size of farVisited: " << farVisited.size() << std::endl;
309 BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
310 BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
316 for(
int half = 0; half < 2; half++) {
317 for(uint32_t row = 0; row < 2; row++) {
318 typedef std::map<uint32_t, uint32_t> ColumnMaxFrame;
320 Virtex5::const_iterator p = bitstream.begin();
321 Virtex5::const_iterator e = bitstream.end();
326 if(packet.
getHeader() != header)
continue;
341 std::cerr << std::endl;
342 uint32_t frameCount = 0;
345 uint32_t majorCount = maxFrames[blockType].size();
346 for(uint32_t major = 0; major < majorCount; major++) {
347 frameCount += maxFrames[blockType][major] + 1;
348 std::cerr << blockType <<
"(" << major <<
"): "
349 << (maxFrames[blockType][major] + 1) <<
" (" << frameCount <<
")"
364 int& argc = boost::unit_test::framework::master_test_suite().argc;
365 char**& argv = boost::unit_test::framework::master_test_suite().argv;
367 BOOST_REQUIRE(argc >= 1);
378 /
"torc" /
"bitstream" /
"Virtex5UnitTest.reference.bit";
380 /
"regression" /
"Virtex5MapUnitTest.generated.bit";
383 std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
384 BOOST_REQUIRE(fileStream.good());
387 bitstream.
read(fileStream,
false);
390 bitstream.initializeDeviceInfo(
"xc5vlx20t");
391 bitstream.initializeFrameMaps();
394 bitstream.readFramePackets();
397 uint32_t frameLength = bitstream.getFrameLength();
398 typedef boost::shared_array<uint32_t> WordSharedArray;
399 Virtex5::iterator p = bitstream.begin();
400 Virtex5::iterator e = bitstream.end();
404 WordSharedArray words = packet.
getWords();
405 uint32_t* ptr = words.get();
406 for(uint32_t block = 0; block < 8; block++) {
407 for(uint32_t frame = 0; frame < bitstream.mBlockFrameIndexBounds[block]; frame++) {
409 for(uint32_t index = 0; index < frameLength; index++) {
410 *ptr++ = words[index];
417 std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
418 BOOST_REQUIRE(outputStream.good());
419 bitstream.write(outputStream);
420 outputStream.flush();
469 BOOST_AUTO_TEST_SUITE_END()
Header for torc::bitstream output stream helpers.
virtual void initializeFrameMaps(void)
Initialize the maps between frame indexes and frame addresses.
Encapsulation of a tile index in an unsigned 32-bit integer.
Encapsulation of a tile row in an unsigned 16-bit integer.
Encapsulation of a tile column in an unsigned 16-bit integer.
Main torc::architecture namespace header.
Encapsulation of a device designator and its constituent elements.
Device database, including complete wiring and logic support.
TileRow getRowCount(void) const
Returns the row count for this device.
Header for the DeviceInfoHelper class.
const EFamily & getFamily(void) const
Returns the device family.
Header for the DirectoryTree class.
const Tiles & getTiles(void) const
Returns a constant reference to the family and device tile data.
static const char * sRegisterName[eRegisterCount]
Configuration register names.
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Header for the Virtex5 class.
Header for the DeviceDesignator class.
EFarBlockType
Frame Address Register block type constants.
void testVirtex5FullMapping(const boost::filesystem::path &inWorkingPath)
Header for Boost.Test helper functions.
static const char * sPacketTypeName[ePacketTypeCount]
Packet type names.
static const DeviceVector & getVirtex5Devices(void)
Returns the Virtex5 devices.
void testVirtex5Device(const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
VirtexFrame::word_t word_t
FrameSet word type.
static const char * sOpcodeName[eOpcodeCount]
Packet opcode names.
Tile map, tile type, and wire information for the family and device.
Encapsulation of filesystem paths that are used by the library.
static const char * sCommandName[eCommandCount]
Configuration command names.
Encapsulation of a tile within a device tile map.
Header for the Devices class.
boost::filesystem::path path
void setDevice(const std::string &inDeviceName)
Assign the device enumeration constant for the given device name.
std::map< Virtex5::FrameAddress, uint32_t > FrameAddressToIndex
Map from frame address to frame index.
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.
TileCol getColCount(void) const
Returns the column count for this device.
const char * getName(void) const
Returns the name for this tile.
Header for the DDB 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 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.
uint32_t getPrimaryXdlColumn(uint32_t inXdlCol)
Returns the primary column corresponding to the given column. If immediately to the left of a BRAM...
void testVirtex5PartialMapping(const boost::filesystem::path &inWorkingPath)
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
uint32_t getHeader(void) const
TileIndex getTileIndex(TileRow inRow, TileCol inCol) const
Returns the tile index for the given [row,column] pair.
virtual void initializeDeviceInfo(const std::string &inDeviceName)
Initialize the device information.