torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::bitstream::bitstream Namespace Reference

Functions

void testSpartan3EDevice (const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
 
void testVirtexDevice (const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
 
void testVirtexFullMapping (const boost::filesystem::path &inWorkingPath)
 
void testVirtex2Device (const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
 
void testVirtex2FullMapping (const boost::filesystem::path &inWorkingPath)
 
void testVirtex2PDevice (const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
 
void testVirtex2PFullMapping (const boost::filesystem::path &inWorkingPath)
 
void testVirtex4Device (const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
 
void testVirtex4FullMapping (const boost::filesystem::path &inWorkingPath)
 
void testVirtex4PartialMapping (const boost::filesystem::path &inWorkingPath)
 
void testVirtex5Device (const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
 
void testVirtex5FullMapping (const boost::filesystem::path &inWorkingPath)
 
void testVirtex5PartialMapping (const boost::filesystem::path &inWorkingPath)
 
void testVirtex6Device (const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
 
void testVirtex6FullMapping (const boost::filesystem::path &inWorkingPath)
 
void testVirtex6PartialMapping (const boost::filesystem::path &inWorkingPath)
 
void testVirtex7Device (const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
 
void testVirtexEDevice (const std::string &inDeviceName, const boost::filesystem::path &inWorkingPath)
 
void testVirtexEFullMapping (const boost::filesystem::path &inWorkingPath)
 

Function Documentation

void torc::bitstream::bitstream::testSpartan3EDevice ( const std::string &  inDeviceName,
const boost::filesystem::path &  inWorkingPath 
)

Definition at line 217 of file Spartan3EUnitTest.cpp.

217  {
218 
219  // build the file paths
220  boost::filesystem::path debugBitstreamPath = inWorkingPath / "torc" / "bitstream" / "regression";
221  //boost::filesystem::path generatedPath = debugBitstreamPath / (inDeviceName + ".debug.bit");
222  boost::filesystem::path referencePath = debugBitstreamPath / (inDeviceName + ".debug.bit");
223 std::cerr << "TRYING TO FIND " << referencePath << std::endl;
224 
225  // read the bitstream
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());
229  Spartan3E bitstream;
230  bitstream.read(fileStream, false);
231  // write the bitstream digest to the console
232  //std::cout << bitstream << std::endl;
233 
234 // // initialize the bitstream frame maps
235 // boost::filesystem::path deviceColumnsPath = inWorkingPath / "regression"
236 // / (inDeviceName + ".cpp");
237 // std::fstream deviceColumnsStream(deviceColumnsPath.string().c_str(), std::ios::out);
238  bitstream.initializeDeviceInfo(inDeviceName);
239  bitstream.initializeFrameMaps();
240 
241  // iterate through the packets, and extract all of the FARs
242  Spartan3E::FrameAddressToIndex farRemaining = bitstream.mFrameAddressToIndex;
243  Spartan3E::FrameAddressToIndex farVisited;
244  {
245  bool first = true;
246  Spartan3E::const_iterator p = bitstream.begin();
247  Spartan3E::const_iterator e = bitstream.end();
248  uint32_t header = SpartanPacket::makeHeader(SpartanPacket::ePacketType1,
249  SpartanPacket::eOpcodeWrite, Spartan3E::eRegisterLOUT, 1);
250  while(p < e) {
251  const SpartanPacket& packet = *p++;
252  if(packet.getHeader() != header) continue;
253  if(first) { first = false; continue; }
254  Spartan3E::FrameAddress far = packet[1];
255  //std::cout << std::endl << "Debug Far Address: " << Hex32(packet[1]) << std::endl;
256  farVisited[far] = 0;
257  Spartan3E::FrameAddressToIndex::iterator found = farRemaining.find(far);
258  if(found != farRemaining.end()) {
259  farRemaining.erase(found);
260  } else {
261  std::cerr << "missing " << far << " ";
262  }
263  }
264  }
265  {
266  std::cerr << std::endl;
267  Spartan3E::FrameAddressToIndex::const_iterator p = farRemaining.begin();
268  Spartan3E::FrameAddressToIndex::const_iterator e = farRemaining.end();
269  while(p != e) {
270  std::cerr << "remaining " << p->first << " ";
271  p++;
272  }
273  std::cerr << std::endl;
274  }
275  // verify that we have visited all of the expected FARs and no others
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);
281 
282 return;
283 }
boost::filesystem::path path

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtex2Device ( const std::string &  inDeviceName,
const boost::filesystem::path &  inWorkingPath 
)

Definition at line 219 of file Virtex2UnitTest.cpp.

219  {
220 
221  // build the file paths
222  boost::filesystem::path debugBitstreamPath = inWorkingPath / "torc" / "bitstream" / "regression";
223  //boost::filesystem::path generatedPath = debugBitstreamPath / (inDeviceName + ".debug.bit");
224  boost::filesystem::path referencePath = debugBitstreamPath / (inDeviceName + ".debug.bit");
225 std::cerr << "TRYING TO FIND " << referencePath << std::endl;
226 
227  // read the bitstream
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());
231  Virtex2 bitstream;
232  bitstream.read(fileStream, false);
233  // write the bitstream digest to the console
234 // std::cout << bitstream << std::endl;
235 
236 // // initialize the bitstream frame maps
237 // boost::filesystem::path deviceColumnsPath = inWorkingPath / "regression"
238 // / (inDeviceName + ".cpp");
239 // std::fstream deviceColumnsStream(deviceColumnsPath.string().c_str(), std::ios::out);
240  bitstream.initializeDeviceInfo(inDeviceName);
241  bitstream.initializeFrameMaps();
242 
243  // iterate through the packets, and extract all of the FARs
244  Virtex2::FrameAddressToIndex farRemaining = bitstream.mFrameAddressToIndex;
245  Virtex2::FrameAddressToIndex farVisited;
246  {
247  bool first = true;
248  Virtex2::const_iterator p = bitstream.begin();
249  Virtex2::const_iterator e = bitstream.end();
250  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
251  VirtexPacket::eOpcodeWrite, Virtex2::eRegisterLOUT, 1);
252  while(p < e) {
253  const VirtexPacket& packet = *p++;
254  if(packet.getHeader() != header) continue;
255  if(first) { first = false; continue; }
256  Virtex2::FrameAddress far = packet[1];
257  //std::cout << std::endl << "Debug Far Address: " << Hex32(packet[1]) << std::endl;
258  farVisited[far] = 0;
259  Virtex2::FrameAddressToIndex::iterator found = farRemaining.find(far);
260  if(found != farRemaining.end()) {
261  farRemaining.erase(found);
262  } else {
263  std::cerr << "missing " << far << " ";
264  }
265  }
266  }
267  // verify that we have visited all of the expected FARs and no others
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);
273 
274 return;
275 }
boost::filesystem::path path

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtex2FullMapping ( const boost::filesystem::path &  inWorkingPath)

Definition at line 293 of file Virtex2UnitTest.cpp.

293  {
294  // build the file paths
296  / "torc" / "bitstream" / "Virtex2UnitTest.reference.bit";
298  / "regression" / "Virtex2MapUnitTest.generated.bit";
299 
300  // read the bitstream
301  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
302  BOOST_REQUIRE(fileStream.good());
303  // read and gather bitstream frames
304  Virtex2 bitstream;
305  bitstream.read(fileStream, false);
306 
307  // initialize frame map
308  bitstream.initializeDeviceInfo("xc2v40");
309  bitstream.initializeFrameMaps();
310 
311  // load bitstream frames in data structure
312  bitstream.initializeFullFrameBlocks();
313 
314  // write full bitstream from frame blocks data structure
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();
319  while(p < e) {
320  const VirtexPacket& packet = *p++;
321  if(packet.isType2()) {
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++) {
326  VirtexFrameBlocks::word_t* words = const_cast<VirtexFrameBlocks::word_t*>(bitstream.mFrameBlocks.mBlock[block][frame]->getWords());
327  for(uint32_t index = 0; index < frameLength; index++) {
328  *ptr++ = words[index];
329  }
330  }
331  }
332  }
333  }
334  // write the test bitstream back out
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();
339  BOOST_REQUIRE(torc::common::fileContentsAreEqual(referencePath, generatedPath));
340 
341  return;
342 }
boost::filesystem::path path
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.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtex2PDevice ( const std::string &  inDeviceName,
const boost::filesystem::path &  inWorkingPath 
)

Definition at line 204 of file Virtex2PUnitTest.cpp.

204  {
205 
206  // build the file paths
207  boost::filesystem::path debugBitstreamPath = inWorkingPath / "torc" / "bitstream" / "regression";
208  //boost::filesystem::path generatedPath = debugBitstreamPath / (inDeviceName + ".debug.bit");
209  boost::filesystem::path referencePath = debugBitstreamPath / (inDeviceName + ".debug.bit");
210 std::cerr << "TRYING TO FIND " << referencePath << std::endl;
211 
212  // read the bitstream
213  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
214  std::cerr << "Trying to read: " << referencePath << std::endl;
215  BOOST_REQUIRE(fileStream.good());
216  Virtex2P bitstream;
217  bitstream.read(fileStream, false);
218  // write the bitstream digest to the console
219 // std::cout << bitstream << std::endl;
220 
221 // // initialize the bitstream frame maps
222 // boost::filesystem::path deviceColumnsPath = inWorkingPath / "regression"
223 // / (inDeviceName + ".cpp");
224 // std::fstream deviceColumnsStream(deviceColumnsPath.string().c_str(), std::ios::out);
225  bitstream.initializeDeviceInfo(inDeviceName);
226  bitstream.initializeFrameMaps();
227 
228  // iterate through the packets, and extract all of the FARs
229  Virtex2P::FrameAddressToIndex farRemaining = bitstream.mFrameAddressToIndex;
230  Virtex2P::FrameAddressToIndex farVisited;
231  {
232  bool first = true;
233  Virtex2P::const_iterator p = bitstream.begin();
234  Virtex2P::const_iterator e = bitstream.end();
235  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
236  VirtexPacket::eOpcodeWrite, Virtex2P::eRegisterLOUT, 1);
237  while(p < e) {
238  const VirtexPacket& packet = *p++;
239  if(packet.getHeader() != header) continue;
240  if(first) { first = false; continue; }
241  Virtex2P::FrameAddress far = packet[1];
242  //std::cout << std::endl << "Debug Far Address: " << Hex32(packet[1]) << std::endl;
243  farVisited[far] = 0;
244  Virtex2P::FrameAddressToIndex::iterator found = farRemaining.find(far);
245  if(found != farRemaining.end()) {
246  farRemaining.erase(found);
247  } else {
248  std::cerr << "missing " << far << " ";
249  }
250  }
251  }
252  // verify that we have visited all of the expected FARs and no others
253  std::cout << "Device: " << inDeviceName << std::endl;
254  std::cout << "Size of farRemaining: " << farRemaining.size() << std::endl;
255  std::cout << "Size of farVisited: " << farVisited.size() << std::endl;
256  BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
257  BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
258 
259 return;
260 
261 }
boost::filesystem::path path

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtex2PFullMapping ( const boost::filesystem::path &  inWorkingPath)

Definition at line 278 of file Virtex2PUnitTest.cpp.

278  {
279  // build the file paths
281  / "torc" / "bitstream" / "Virtex2PUnitTest.reference.bit";
283  / "regression" / "Virtex2PMapUnitTest.generated.bit";
284 
285  // read the bitstream
286  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
287  BOOST_REQUIRE(fileStream.good());
288  // read and gather bitstream frames
289  Virtex2P bitstream;
290  bitstream.read(fileStream, false);
291 
292  // initialize frame map
293  bitstream.initializeDeviceInfo("xc2vp20");
294  bitstream.initializeFrameMaps();
295 
296  // load bitstream frames in data structure
297  bitstream.initializeFullFrameBlocks();
298 
299  // write full bitstream from frame blocks data structure
300  uint32_t frameLength = bitstream.getFrameLength();
301  typedef boost::shared_array<uint32_t> WordSharedArray;
302  Virtex2P::iterator p = bitstream.begin();
303  Virtex2P::iterator e = bitstream.end();
304  while(p < e) {
305  const VirtexPacket& packet = *p++;
306  if(packet.isType2()) {
307  WordSharedArray words = packet.getWords();
308  uint32_t* ptr = words.get();
309  for(uint32_t block = 0; block < 8; block++) {
310  for(uint32_t frame = 0; frame < bitstream.mBlockFrameIndexBounds[block]; frame++) {
311  VirtexFrameBlocks::word_t* words = const_cast<VirtexFrameBlocks::word_t*>(bitstream.mFrameBlocks.mBlock[block][frame]->getWords());
312  for(uint32_t index = 0; index < frameLength; index++) {
313  *ptr++ = words[index];
314  }
315  }
316  }
317  }
318  }
319  // write the test bitstream back out
320  std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
321  BOOST_REQUIRE(outputStream.good());
322  bitstream.write(outputStream);
323  outputStream.flush();
324  BOOST_REQUIRE(torc::common::fileContentsAreEqual(referencePath, generatedPath));
325 
326  return;
327 }
boost::filesystem::path path
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.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtex4Device ( const std::string &  inDeviceName,
const boost::filesystem::path &  inWorkingPath 
)

Definition at line 234 of file Virtex4UnitTest.cpp.

234  {
235 
236  // build the file paths
237  boost::filesystem::path debugBitstreamPath = inWorkingPath / "torc" / "bitstream" / "regression";
238  //boost::filesystem::path generatedPath = debugBitstreamPath / (inDeviceName + ".debug.bit");
239  boost::filesystem::path referencePath = debugBitstreamPath / (inDeviceName + ".debug.bit");
240 std::cerr << "TRYING TO FIND " << referencePath << std::endl;
241 
242  // read the bitstream
243  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
244  std::cerr << "Trying to read: " << referencePath << std::endl;
245  BOOST_REQUIRE(fileStream.good());
246  Virtex4 bitstream;
247  bitstream.read(fileStream, false);
248  // write the bitstream digest to the console
249 // std::cout << bitstream << std::endl;
250 
251 // // initialize the bitstream frame maps
252 // boost::filesystem::path deviceColumnsPath = inWorkingPath / "regression"
253 // / (inDeviceName + ".cpp");
254 // std::fstream deviceColumnsStream(deviceColumnsPath.string().c_str(), std::ios::out);
255  bitstream.initializeDeviceInfo(inDeviceName);
256  bitstream.initializeFrameMaps();
257 
258  // iterate through the packets, and extract all of the FARs
259  Virtex4::FrameAddressToIndex farRemaining = bitstream.mFrameAddressToIndex;
260  Virtex4::FrameAddressToIndex farVisited;
261  {
262  bool first = true;
263  Virtex4::const_iterator p = bitstream.begin();
264  Virtex4::const_iterator e = bitstream.end();
265  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
266  VirtexPacket::eOpcodeWrite, Virtex4::eRegisterLOUT, 1);
267  while(p < e) {
268  const VirtexPacket& packet = *p++;
269  if(packet.getHeader() != header) continue;
270  if(first) { first = false; continue; }
271  Virtex4::FrameAddress far = packet[1];
272  farVisited[far] = 0;
273  Virtex4::FrameAddressToIndex::iterator found = farRemaining.find(far);
274  if(found != farRemaining.end()) {
275  farRemaining.erase(found);
276  } else {
277  std::cerr << "missing " << far << " ";
278  }
279  }
280  }
281  // verify that we have visited all of the expected FARs and no others
282  std::cout << "Device: " << inDeviceName << std::endl;
283  std::cout << "Size of farRemaining: " << farRemaining.size() << std::endl;
284  std::cout << "Size of farVisited: " << farVisited.size() << std::endl;
285  BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
286  BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
287 
288 return;
289 
290  // iterate through the debug bitstream packets, and extract all of the FARs
291  // this isn't currently being used, but it may come in handy for debugging
292  for(int half = 0; half < 2; half++) {
293  for(uint32_t row = 0; row < 2; row++) {
294  typedef std::map<uint32_t, uint32_t> ColumnMaxFrame;
295  ColumnMaxFrame maxFrames[Virtex4::eFarBlockTypeCount];
296  Virtex4::const_iterator p = bitstream.begin();
297  Virtex4::const_iterator e = bitstream.end();
298  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
299  VirtexPacket::eOpcodeWrite, Virtex4::eRegisterLOUT, 1);
300  while(p < e) {
301  const VirtexPacket& packet = *p++;
302  if(packet.getHeader() != header) continue;
303  Virtex4::FrameAddress far = packet[1];
304 // uint32_t far = packet[1];
305 // std::cerr << Hex32(far) << " ";
306  if(far.mTopBottom == half && far.mRow == row) {
307 // std::cerr << far << " ";
308  ColumnMaxFrame::iterator i = maxFrames[far.mBlockType].find(far.mMajor);
309  if(i == maxFrames[far.mBlockType].end()) {
310  maxFrames[far.mBlockType][far.mMajor] = 0;
311  } else {
312  if(maxFrames[far.mBlockType][far.mMajor] < far.mMinor)
313  maxFrames[far.mBlockType][far.mMajor] = far.mMinor;
314  }
315  }
316  }
317  std::cerr << std::endl;
318  uint32_t frameCount = 0;
319  for(uint32_t i = 0; i < Virtex4::eFarBlockTypeCount; i++) {
320  Virtex4::EFarBlockType blockType = Virtex4::EFarBlockType(i);
321  uint32_t majorCount = maxFrames[blockType].size();
322  for(uint32_t major = 0; major < majorCount; major++) {
323  frameCount += maxFrames[blockType][major] + 1;
324  std::cerr << blockType << "(" << major << "): "
325  << (maxFrames[blockType][major] + 1) << " (" << frameCount << ")"
326  << std::endl;
327  }
328  }
329  }
330  }
331 
332 }
boost::filesystem::path path

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtex4FullMapping ( const boost::filesystem::path &  inWorkingPath)

Definition at line 351 of file Virtex4UnitTest.cpp.

351  {
352  // build the file paths
354  / "torc" / "bitstream" / "Virtex4UnitTest.reference.bit";
356  / "regression" / "Virtex4MapUnitTest.generated.bit";
357 
358  // read the bitstream
359  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
360  BOOST_REQUIRE(fileStream.good());
361  // read and gather bitstream frames
362  Virtex4 bitstream;
363  bitstream.read(fileStream, false);
364 
365  // initialize frame map
366  bitstream.initializeDeviceInfo("xc4vlx15");
367  bitstream.initializeFrameMaps();
368 
369  // load bitstream frames in data structure
370  bitstream.readFramePackets();
371 
372  // write full bitstream from frame blocks data structure
373  uint32_t frameLength = bitstream.getFrameLength();
374  typedef boost::shared_array<uint32_t> WordSharedArray;
375  Virtex4::iterator p = bitstream.begin();
376  Virtex4::iterator e = bitstream.end();
377  while(p < e) {
378  const VirtexPacket& packet = *p++;
379  if(packet.isType2()) {
380  WordSharedArray words = packet.getWords();
381  uint32_t* ptr = words.get();
382  for(uint32_t block = 0; block < 8; block++) {
383  for(uint32_t frame = 0; frame < bitstream.mBlockFrameIndexBounds[block]; frame++) {
384  VirtexFrameBlocks::word_t* words = const_cast<VirtexFrameBlocks::word_t*>(bitstream.mFrameBlocks.mBlock[block][frame]->getWords());
385  for(uint32_t index = 0; index < frameLength; index++) {
386  *ptr++ = words[index];
387  }
388  }
389  }
390  }
391  }
392  // write the test bitstream back out
393  std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
394  BOOST_REQUIRE(outputStream.good());
395  bitstream.write(outputStream);
396  outputStream.flush();
397  BOOST_REQUIRE(torc::common::fileContentsAreEqual(referencePath, generatedPath));
398 
399  return;
400 }
boost::filesystem::path path
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.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtex4PartialMapping ( const boost::filesystem::path &  inWorkingPath)
void torc::bitstream::bitstream::testVirtex5Device ( const std::string &  inDeviceName,
const boost::filesystem::path &  inWorkingPath 
)

Definition at line 254 of file Virtex5UnitTest.cpp.

254  {
255 
256  // build the file paths
257  boost::filesystem::path debugBitstreamPath = inWorkingPath / "torc" / "bitstream" / "regression";
258  //boost::filesystem::path generatedPath = debugBitstreamPath / (inDeviceName + ".debug.bit");
259  boost::filesystem::path referencePath = debugBitstreamPath / (inDeviceName + ".debug.bit");
260 std::cerr << "TRYING TO FIND " << referencePath << std::endl;
261 
262  // read the bitstream
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());
266  Virtex5 bitstream;
267 std::cerr << "test0" << std::endl;
268  bitstream.read(fileStream, false);
269 std::cerr << "test1" << std::endl;
270  // write the bitstream digest to the console
271 // std::cout << bitstream << std::endl;
272 
273 // // initialize the bitstream frame maps
274 // boost::filesystem::path deviceColumnsPath = inWorkingPath / "torc" / "bitstream" / "regression"
275 // / (inDeviceName + ".cpp");
276 // std::fstream deviceColumnsStream(deviceColumnsPath.string().c_str(), std::ios::out);
277  bitstream.initializeDeviceInfo(inDeviceName);
278 std::cerr << "test2" << std::endl;
279  bitstream.initializeFrameMaps();
280 std::cerr << "test3" << std::endl;
281 
282  // iterate through the packets, and extract all of the FARs
283  Virtex5::FrameAddressToIndex farRemaining = bitstream.mFrameAddressToIndex;
284  Virtex5::FrameAddressToIndex farVisited;
285  {
286  bool first = true;
287  Virtex5::const_iterator p = bitstream.begin();
288  Virtex5::const_iterator e = bitstream.end();
289  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
290  VirtexPacket::eOpcodeWrite, Virtex5::eRegisterLOUT, 1);
291  while(p < e) {
292  const VirtexPacket& packet = *p++;
293  if(packet.getHeader() != header) continue;
294  if(first) { first = false; continue; }
295  Virtex5::FrameAddress far = packet[1];
296  farVisited[far] = 0;
297  Virtex5::FrameAddressToIndex::iterator found = farRemaining.find(far);
298  if(found != farRemaining.end()) {
299  farRemaining.erase(found);
300  } else {
301  std::cerr << "missing " << far << " ";
302  }
303  }
304  }
305  // verify that we have visited all of the expected FARs and no others
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);
311 
312 return;
313 
314  // iterate through the debug bitstream packets, and extract all of the FARs
315  // this isn't currently being used, but it may come in handy for debugging
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;
319  ColumnMaxFrame maxFrames[Virtex5::eFarBlockTypeCount];
320  Virtex5::const_iterator p = bitstream.begin();
321  Virtex5::const_iterator e = bitstream.end();
322  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
323  VirtexPacket::eOpcodeWrite, Virtex5::eRegisterLOUT, 1);
324  while(p < e) {
325  const VirtexPacket& packet = *p++;
326  if(packet.getHeader() != header) continue;
327  Virtex5::FrameAddress far = packet[1];
328 // uint32_t far = packet[1];
329 // std::cerr << Hex32(far) << " ";
330  if(far.mTopBottom == half && far.mRow == row) {
331 // std::cerr << far << " ";
332  ColumnMaxFrame::iterator i = maxFrames[far.mBlockType].find(far.mMajor);
333  if(i == maxFrames[far.mBlockType].end()) {
334  maxFrames[far.mBlockType][far.mMajor] = 0;
335  } else {
336  if(maxFrames[far.mBlockType][far.mMajor] < far.mMinor)
337  maxFrames[far.mBlockType][far.mMajor] = far.mMinor;
338  }
339  }
340  }
341  std::cerr << std::endl;
342  uint32_t frameCount = 0;
343  for(uint32_t i = 0; i < Virtex5::eFarBlockTypeCount; i++) {
344  Virtex5::EFarBlockType blockType = Virtex5::EFarBlockType(i);
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 << ")"
350  << std::endl;
351  }
352  }
353  }
354  }
355 
356 }
boost::filesystem::path path

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtex5FullMapping ( const boost::filesystem::path &  inWorkingPath)

Definition at line 375 of file Virtex5UnitTest.cpp.

375  {
376  // build the file paths
378  / "torc" / "bitstream" / "Virtex5UnitTest.reference.bit";
380  / "regression" / "Virtex5MapUnitTest.generated.bit";
381 
382  // read the bitstream
383  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
384  BOOST_REQUIRE(fileStream.good());
385  // read and gather bitstream frames
386  Virtex5 bitstream;
387  bitstream.read(fileStream, false);
388 
389  // initialize frame map
390  bitstream.initializeDeviceInfo("xc5vlx20t");
391  bitstream.initializeFrameMaps();
392 
393  // load bitstream frames in data structure
394  bitstream.readFramePackets();
395 
396  // write full bitstream from frame blocks data structure
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();
401  while(p < e) {
402  const VirtexPacket& packet = *p++;
403  if(packet.isType2()) {
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++) {
408  VirtexFrameBlocks::word_t* words = const_cast<VirtexFrameBlocks::word_t*>(bitstream.mFrameBlocks.mBlock[block][frame]->getWords());
409  for(uint32_t index = 0; index < frameLength; index++) {
410  *ptr++ = words[index];
411  }
412  }
413  }
414  }
415  }
416  // write the test bitstream back out
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();
421  BOOST_REQUIRE(torc::common::fileContentsAreEqual(referencePath, generatedPath));
422 
423  return;
424 }
boost::filesystem::path path
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.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtex5PartialMapping ( const boost::filesystem::path &  inWorkingPath)
void torc::bitstream::bitstream::testVirtex6Device ( const std::string &  inDeviceName,
const boost::filesystem::path &  inWorkingPath 
)

Definition at line 234 of file Virtex6UnitTest.cpp.

234  {
235 
236  // build the file paths
237  boost::filesystem::path debugBitstreamPath = inWorkingPath / "torc" / "bitstream" / "regression";
238  //boost::filesystem::path generatedPath = debugBitstreamPath / (inDeviceName + ".debug.bit");
239  boost::filesystem::path referencePath = debugBitstreamPath / (inDeviceName + ".debug.bit");
240 
241  // read the bitstream
242  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
243  std::cerr << "Trying to read: " << referencePath << std::endl;
244  BOOST_REQUIRE(fileStream.good());
245  Virtex6 bitstream;
246  bitstream.read(fileStream, false);
247  // write the bitstream digest to the console
248 // std::cout << bitstream << std::endl;
249 
250 // // initialize the bitstream frame maps
251 // boost::filesystem::path deviceColumnsPath = inWorkingPath / "torc" / "bitstream" / "regression"
252 // / (inDeviceName + ".cpp");
253 // std::fstream deviceColumnsStream(deviceColumnsPath.string().c_str(), std::ios::out);
254  bitstream.initializeDeviceInfo(inDeviceName);
255  bitstream.initializeFrameMaps();
256 
257  // iterate through the packets, and extract all of the FARs
258  Virtex6::FrameAddressToIndex farRemaining = bitstream.mFrameAddressToIndex;
259  Virtex6::FrameAddressToIndex farVisited;
260  {
261  bool first = true;
262  Virtex6::const_iterator p = bitstream.begin();
263  Virtex6::const_iterator e = bitstream.end();
264  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
265  VirtexPacket::eOpcodeWrite, Virtex6::eRegisterLOUT, 1);
266  while(p < e) {
267  const VirtexPacket& packet = *p++;
268  if(packet.getHeader() != header) continue;
269  if(first) { first = false; continue; }
270  Virtex6::FrameAddress far = packet[1];
271  farVisited[far] = 0;
272  Virtex6::FrameAddressToIndex::iterator found = farRemaining.find(far);
273  if(found != farRemaining.end()) {
274  farRemaining.erase(found);
275  } else {
276  std::cerr << "missing " << far << " ";
277  }
278  }
279  }
280  {
281  Virtex6::FrameAddressToIndex::const_iterator p = farRemaining.begin();
282  Virtex6::FrameAddressToIndex::const_iterator e = farRemaining.end();
283  while(p != e) {
284  std::cerr << "remaining " << (*p++).first << " ";
285  }
286  std::cerr << std::endl;
287  }
288  // verify that we have visited all of the expected FARs and no others
289  std::cout << "Device: " << inDeviceName << std::endl;
290  std::cout << "Size of farRemaining: " << farRemaining.size() << std::endl;
291  std::cout << "Size of farVisited: " << farVisited.size() << std::endl;
292  BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
293  BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
294 
295 return;
296 
297  // iterate through the debug bitstream packets, and extract all of the FARs
298  // this isn't currently being used, but it may come in handy for debugging
299  for(int half = 0; half < 2; half++) {
300  for(uint32_t row = 0; row < 2; row++) {
301  typedef std::map<uint32_t, uint32_t> ColumnMaxFrame;
302  ColumnMaxFrame maxFrames[Virtex6::eFarBlockTypeCount];
303  Virtex6::const_iterator p = bitstream.begin();
304  Virtex6::const_iterator e = bitstream.end();
305  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
306  VirtexPacket::eOpcodeWrite, Virtex6::eRegisterLOUT, 1);
307  while(p < e) {
308  const VirtexPacket& packet = *p++;
309  if(packet.getHeader() != header) continue;
310  Virtex6::FrameAddress far = packet[1];
311 // uint32_t far = packet[1];
312 // std::cerr << Hex32(far) << " ";
313  if(far.mTopBottom == half && far.mRow == row) {
314 // std::cerr << far << " ";
315  ColumnMaxFrame::iterator i = maxFrames[far.mBlockType].find(far.mMajor);
316  if(i == maxFrames[far.mBlockType].end()) {
317  maxFrames[far.mBlockType][far.mMajor] = 0;
318  } else {
319  if(maxFrames[far.mBlockType][far.mMajor] < far.mMinor)
320  maxFrames[far.mBlockType][far.mMajor] = far.mMinor;
321  }
322  }
323  }
324  std::cerr << std::endl;
325  uint32_t frameCount = 0;
326  for(uint32_t i = 0; i < Virtex6::eFarBlockTypeCount; i++) {
327  Virtex6::EFarBlockType blockType = Virtex6::EFarBlockType(i);
328  uint32_t majorCount = maxFrames[blockType].size();
329  for(uint32_t major = 0; major < majorCount; major++) {
330  frameCount += maxFrames[blockType][major] + 1;
331  std::cerr << blockType << "(" << major << "): "
332  << (maxFrames[blockType][major] + 1) << " (" << frameCount << ")"
333  << std::endl;
334  }
335  }
336  }
337  }
338 
339 }
boost::filesystem::path path

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtex6FullMapping ( const boost::filesystem::path &  inWorkingPath)

Definition at line 358 of file Virtex6UnitTest.cpp.

358  {
359  // build the file paths
361  / "torc" / "bitstream" / "Virtex6UnitTest.reference.bit";
363  / "regression" / "Virtex6MapUnitTest.generated.bit";
364 
365  // read the bitstream
366  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
367  BOOST_REQUIRE(fileStream.good());
368  // read and gather bitstream frames
369  Virtex6 bitstream;
370  bitstream.read(fileStream, false);
371 
372  // initialize frame map
373  bitstream.initializeDeviceInfo("xc6vlx75t");
374  bitstream.initializeFrameMaps();
375 
376  // load bitstream frames in data structure
377  bitstream.readFramePackets();
378 
379  // write full bitstream from frame blocks data structure
380  uint32_t frameLength = bitstream.getFrameLength();
381  typedef boost::shared_array<uint32_t> WordSharedArray;
382  Virtex6::iterator p = bitstream.begin();
383  Virtex6::iterator e = bitstream.end();
384  while(p < e) {
385  const VirtexPacket& packet = *p++;
386  if(packet.isType2()) {
387  WordSharedArray words = packet.getWords();
388  uint32_t* ptr = words.get();
389  for(uint32_t block = 0; block < 8; block++) {
390  for(uint32_t frame = 0; frame < bitstream.mBlockFrameIndexBounds[block]; frame++) {
391  VirtexFrameBlocks::word_t* words = const_cast<VirtexFrameBlocks::word_t*>(bitstream.mFrameBlocks.mBlock[block][frame]->getWords());
392  for(uint32_t index = 0; index < frameLength; index++) {
393  *ptr++ = words[index];
394  }
395  }
396  }
397  }
398  }
399  // write the test bitstream back out
400  std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
401  BOOST_REQUIRE(outputStream.good());
402  bitstream.write(outputStream);
403  outputStream.flush();
404  BOOST_REQUIRE(torc::common::fileContentsAreEqual(referencePath, generatedPath));
405 
406  return;
407 }
boost::filesystem::path path
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.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtex6PartialMapping ( const boost::filesystem::path &  inWorkingPath)
void torc::bitstream::bitstream::testVirtex7Device ( const std::string &  inDeviceName,
const boost::filesystem::path &  inWorkingPath 
)

Definition at line 252 of file Virtex7UnitTest.cpp.

252  {
253 
254  // build the file paths
255  boost::filesystem::path debugBitstreamPath = inWorkingPath / "torc" / "bitstream" / "regression";
256  //boost::filesystem::path generatedPath = debugBitstreamPath / (inDeviceName + ".debug.bit");
257  boost::filesystem::path referencePath = debugBitstreamPath / (inDeviceName + ".debug.bit");
258 
259  // read the bitstream
260  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
261  std::cerr << "Trying to read: " << referencePath << std::endl;
262  BOOST_REQUIRE(fileStream.good());
263  Virtex7 bitstream;
264  bitstream.read(fileStream, false);
265  // write the bitstream digest to the console
266 // std::cout << bitstream << std::endl;
267 
268 
269  typedef std::map<Virtex7::FrameAddress, Virtex7::FrameAddress> FrameAddressMap;
270  FrameAddressMap fars;
271  // determine the far count in every column
272  Virtex7::const_iterator p = bitstream.begin();
273  Virtex7::const_iterator e = bitstream.end();
274  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
275  VirtexPacket::eOpcodeWrite, Virtex7::eRegisterLOUT, 1);
276  while(p < e) {
277  const VirtexPacket& packet = *p++;
278  if(packet.getHeader() != header) continue;
279  Virtex7::FrameAddress far = packet[1];
280  Virtex7::FrameAddress base = far;
281  base.mMinor = 0;
282  fars[base] = std::max(fars[base], far);
283  }
284  // write out the maximum far for every column
285  FrameAddressMap::const_iterator fp = fars.begin();
286  FrameAddressMap::const_iterator fe = fars.end();
287  while(fp != fe) {
288  const FrameAddressMap::value_type& value = *fp++;
289 (void) value;
290 // std::cerr << value.second << std::endl;
291  }
292 
293  // initialize the bitstream frame maps
294 // boost::filesystem::path deviceColumnsPath = inWorkingPath / "torc" / "bitstream" / "regression"
295 // / (inDeviceName + ".cpp");
296 // std::fstream deviceColumnsStream(deviceColumnsPath.string().c_str(), std::ios::out);
297  bitstream.initializeDeviceInfo(inDeviceName);
298  bitstream.initializeFrameMaps();
299 
300 
301  // iterate through the packets, and extract all of the FARs
302  Virtex7::FrameAddressToIndex farRemaining = bitstream.mFrameAddressToIndex;
303  Virtex7::FrameAddressToIndex farVisited;
304  {
305  bool enabled = false;
306  Virtex7::const_iterator p = bitstream.begin();
307  Virtex7::const_iterator e = bitstream.end();
308  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
309  VirtexPacket::eOpcodeWrite, Virtex7::eRegisterLOUT, 1);
310  uint32_t enable = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
311  VirtexPacket::eOpcodeWrite, Virtex7::eRegisterCMD, 1);
312  while(p < e) {
313  const VirtexPacket& packet = *p++;
314  if(packet.getHeader() == enable) enabled = true;
315  if(!enabled) continue;
316  if(packet.getHeader() != header) continue;
317  Virtex7::FrameAddress far = packet[1];
318  farVisited[far] = 0;
319  Virtex7::FrameAddressToIndex::iterator found = farRemaining.find(far);
320  if(found != farRemaining.end()) {
321  farRemaining.erase(found);
322  } else {
323  std::cerr << "missing " << far << " ";
324  }
325  }
326  }
327  {
328  Virtex7::FrameAddressToIndex::const_iterator p = farRemaining.begin();
329  Virtex7::FrameAddressToIndex::const_iterator e = farRemaining.end();
330  while(p != e) {
331  std::cerr << "remaining " << (*p++).first << " ";
332  }
333  std::cerr << std::endl;
334  }
335  // verify that we have visited all of the expected FARs and no others
336  std::cout << "Device: " << inDeviceName << std::endl;
337  std::cout << "Size of farRemaining: " << farRemaining.size() << std::endl;
338  std::cout << "Size of farVisited: " << farVisited.size() << std::endl;
339  BOOST_CHECK_EQUAL(farRemaining.size(), 0u);
340  BOOST_CHECK_EQUAL(farVisited.size(), bitstream.mFrameAddressToIndex.size());
341 
342  // iterate through the debug bitstream packets, and extract all of the FARs
343  // this isn't currently being used, but it may come in handy for debugging
344  for(int half = 0; half < 2; half++) {
345 break;
346  for(uint32_t row = 0; row < 2; row++) {
347  typedef std::map<uint32_t, uint32_t> ColumnMaxFrame;
348  ColumnMaxFrame maxFrames[Virtex7::eFarBlockTypeCount];
349  Virtex7::const_iterator p = bitstream.begin();
350  Virtex7::const_iterator e = bitstream.end();
351  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
352  VirtexPacket::eOpcodeWrite, Virtex7::eRegisterLOUT, 1);
353  while(p < e) {
354  const VirtexPacket& packet = *p++;
355  if(packet.getHeader() != header) continue;
356  Virtex7::FrameAddress far = packet[1];
357 // uint32_t far = packet[1];
358 // std::cerr << Hex32(far) << " ";
359  if(far.mTopBottom == half && far.mRow == row) {
360 // std::cerr << far << " ";
361  ColumnMaxFrame::iterator i = maxFrames[far.mBlockType].find(far.mMajor);
362  if(i == maxFrames[far.mBlockType].end()) {
363  maxFrames[far.mBlockType][far.mMajor] = 0;
364  } else {
365  if(maxFrames[far.mBlockType][far.mMajor] < far.mMinor)
366  maxFrames[far.mBlockType][far.mMajor] = far.mMinor;
367  }
368  }
369  }
370  std::cerr << std::endl;
371  uint32_t frameCount = 0;
372  for(uint32_t i = 0; i < Virtex7::eFarBlockTypeCount; i++) {
373  Virtex7::EFarBlockType blockType = Virtex7::EFarBlockType(i);
374  uint32_t majorCount = maxFrames[blockType].size();
375  for(uint32_t major = 0; major < majorCount; major++) {
376  frameCount += maxFrames[blockType][major] + 1;
377  std::cerr << blockType << "(" << major << "): "
378  << (maxFrames[blockType][major] + 1) << " (" << frameCount << ")"
379  << std::endl;
380  }
381  }
382  }
383  }
384 
385 // BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
386 // BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
387 }
boost::filesystem::path path

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtexDevice ( const std::string &  inDeviceName,
const boost::filesystem::path &  inWorkingPath 
)

Definition at line 211 of file VirtexUnitTest.cpp.

211  {
212 
213  // build the file paths
214  boost::filesystem::path debugBitstreamPath = inWorkingPath / "torc" / "bitstream" / "regression";
215  //boost::filesystem::path generatedPath = debugBitstreamPath / (inDeviceName + ".debug.bit");
216  boost::filesystem::path referencePath = debugBitstreamPath / (inDeviceName + ".debug.bit");
217 std::cerr << "TRYING TO FIND " << referencePath << std::endl;
218 
219  // read the bitstream
220  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
221  std::cerr << "Trying to read: " << referencePath << std::endl;
222  BOOST_REQUIRE(fileStream.good());
223  Virtex bitstream;
224  bitstream.read(fileStream, false);
225  // write the bitstream digest to the console
226 // std::cout << bitstream << std::endl;
227 
228 // // initialize the bitstream frame maps
229 // boost::filesystem::path deviceColumnsPath = inWorkingPath / "regression"
230 // / (inDeviceName + ".cpp");
231 // std::fstream deviceColumnsStream(deviceColumnsPath.string().c_str(), std::ios::out);
232  bitstream.initializeDeviceInfo(inDeviceName);
233  bitstream.initializeFrameMaps();
234 
235  // iterate through the packets, and extract all of the FARs
236  Virtex::FrameAddressToIndex farRemaining = bitstream.mFrameAddressToIndex;
237  Virtex::FrameAddressToIndex farVisited;
238  {
239  bool first = true;
240  Virtex::const_iterator p = bitstream.begin();
241  Virtex::const_iterator e = bitstream.end();
242  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
243  VirtexPacket::eOpcodeWrite, Virtex::eRegisterLOUT, 1);
244  while(p < e) {
245  const VirtexPacket& packet = *p++;
246  if(packet.getHeader() != header) continue;
247  if(first) { first = false; continue; }
248  Virtex::FrameAddress far = packet[1];
249  //std::cout << std::endl << "Debug Far Address: " << Hex32(packet[1]) << std::endl;
250  farVisited[far] = 0;
251  Virtex::FrameAddressToIndex::iterator found = farRemaining.find(far);
252  if(found != farRemaining.end()) {
253  farRemaining.erase(found);
254  } else {
255  std::cerr << "missing " << far << " ";
256  }
257  }
258  }
259  // verify that we have visited all of the expected FARs and no others
260  std::cout << "Device: " << inDeviceName << std::endl;
261  std::cout << "Size of farRemaining: " << farRemaining.size() << std::endl;
262  std::cout << "Size of farVisited: " << farVisited.size() << std::endl;
263  BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
264  BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
265 
266 return;
267 /*
268  // iterate through the debug bitstream packets, and extract all of the FARs
269  // this isn't currently being used, but it may come in handy for debugging
270  for(int half = 0; half < 2; half++) {
271  for(uint32_t row = 0; row < 2; row++) {
272  typedef std::map<uint32_t, uint32_t> ColumnMaxFrame;
273  ColumnMaxFrame maxFrames[Virtex::eFarBlockTypeCount];
274  Virtex::const_iterator p = bitstream.begin();
275  Virtex::const_iterator e = bitstream.end();
276  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
277  VirtexPacket::eOpcodeWrite, Virtex::eRegisterLOUT, 1);
278  while(p < e) {
279  const VirtexPacket& packet = *p++;
280  if(packet.getHeader() != header) continue;
281  Virtex::FrameAddress far = packet[1];
282 // uint32_t far = packet[1];
283 // std::cerr << Hex32(far) << " ";
284  if(far.mTopBottom == half && far.mRow == row) {
285 // std::cerr << far << " ";
286  ColumnMaxFrame::iterator i = maxFrames[far.mBlockType].find(far.mMajor);
287  if(i == maxFrames[far.mBlockType].end()) {
288  maxFrames[far.mBlockType][far.mMajor] = 0;
289  } else {
290  if(maxFrames[far.mBlockType][far.mMajor] < far.mMinor)
291  maxFrames[far.mBlockType][far.mMajor] = far.mMinor;
292  }
293  }
294  }
295  std::cerr << std::endl;
296  uint32_t frameCount = 0;
297  for(uint32_t i = 0; i < Virtex::eFarBlockTypeCount; i++) {
298  Virtex::EFarBlockType blockType = Virtex::EFarBlockType(i);
299  uint32_t majorCount = maxFrames[blockType].size();
300  for(uint32_t major = 0; major < majorCount; major++) {
301  frameCount += maxFrames[blockType][major] + 1;
302  std::cerr << blockType << "(" << major << "): "
303  << (maxFrames[blockType][major] + 1) << " (" << frameCount << ")"
304  << std::endl;
305  }
306  }
307  }
308  }
309 
310 */
311 }
boost::filesystem::path path

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtexEDevice ( const std::string &  inDeviceName,
const boost::filesystem::path &  inWorkingPath 
)

Definition at line 210 of file VirtexEUnitTest.cpp.

210  {
211 
212  // build the file paths
213  boost::filesystem::path debugBitstreamPath = inWorkingPath / "torc" / "bitstream" / "regression";
214  //boost::filesystem::path generatedPath = debugBitstreamPath / (inDeviceName + ".debug.bit");
215  boost::filesystem::path referencePath = debugBitstreamPath / (inDeviceName + ".debug.bit");
216 std::cerr << "TRYING TO FIND " << referencePath << std::endl;
217 
218  // read the bitstream
219  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
220  std::cerr << "Trying to read: " << referencePath << std::endl;
221  BOOST_REQUIRE(fileStream.good());
222  VirtexE bitstream;
223  bitstream.read(fileStream, false);
224  // write the bitstream digest to the console
225 // std::cout << bitstream << std::endl;
226 
227 // // initialize the bitstream frame maps
228 // boost::filesystem::path deviceColumnsPath = inWorkingPath / "regression"
229 // / (inDeviceName + ".cpp");
230 // std::fstream deviceColumnsStream(deviceColumnsPath.string().c_str(), std::ios::out);
231  bitstream.initializeDeviceInfo(inDeviceName);
232  bitstream.initializeFrameMaps();
233 
234  // iterate through the packets, and extract all of the FARs
235  VirtexE::FrameAddressToIndex farRemaining = bitstream.mFrameAddressToIndex;
236  VirtexE::FrameAddressToIndex farVisited;
237  {
238  bool first = true;
239  VirtexE::const_iterator p = bitstream.begin();
240  VirtexE::const_iterator e = bitstream.end();
241  uint32_t header = VirtexPacket::makeHeader(VirtexPacket::ePacketType1,
242  VirtexPacket::eOpcodeWrite, VirtexE::eRegisterLOUT, 1);
243  while(p < e) {
244  const VirtexPacket& packet = *p++;
245  if(packet.getHeader() != header) continue;
246  if(first) { first = false; continue; }
247  VirtexE::FrameAddress far = packet[1];
248  //std::cout << std::endl << "Debug Far Address: " << Hex32(packet[1]) << std::endl;
249  farVisited[far] = 0;
250  VirtexE::FrameAddressToIndex::iterator found = farRemaining.find(far);
251  if(found != farRemaining.end()) {
252  farRemaining.erase(found);
253  } else {
254  std::cerr << "missing " << far << " ";
255  }
256  }
257  }
258  // verify that we have visited all of the expected FARs and no others
259  std::cout << "Device: " << inDeviceName << std::endl;
260  std::cout << "Size of farRemaining: " << farRemaining.size() << std::endl;
261  std::cout << "Size of farVisited: " << farVisited.size() << std::endl;
262  BOOST_REQUIRE_EQUAL(bitstream.mFrameAddressToIndex.size(), farVisited.size());
263  BOOST_REQUIRE_EQUAL(farRemaining.size(), 0u);
264 
265 return;
266 }
boost::filesystem::path path

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtexEFullMapping ( const boost::filesystem::path &  inWorkingPath)

Definition at line 283 of file VirtexEUnitTest.cpp.

283  {
284  // build the file paths
286  / "torc" / "bitstream" / "VirtexEUnitTest.reference.bit";
288  / "regression" / "VirtexEMapUnitTest.generated.bit";
289 
290  // read the bitstream
291  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
292  BOOST_REQUIRE(fileStream.good());
293  // read and gather bitstream frames
294  VirtexE bitstream;
295  bitstream.read(fileStream, false);
296 
297  // initialize frame map
298  bitstream.initializeDeviceInfo("xcv50e");
299  bitstream.initializeFrameMaps();
300 
301  // load bitstream frames in data structure
302  bitstream.initializeFullFrameBlocks();
303 
304  // write full bitstream from frame blocks data structure
305  uint32_t frameLength = bitstream.getFrameLength();
306  typedef boost::shared_array<uint32_t> WordSharedArray;
307  VirtexE::iterator p = bitstream.begin();
308  VirtexE::iterator e = bitstream.end();
309  while(p < e) {
310  const VirtexPacket& packet = *p++;
311  if(packet.isType2()) {
312  WordSharedArray words = packet.getWords();
313  uint32_t* ptr = words.get();
314  for(uint32_t block = 0; block < 8; block++) {
315  for(uint32_t frame = 0; frame < bitstream.mBlockFrameIndexBounds[block]; frame++) {
316  VirtexFrameBlocks::word_t* words = const_cast<VirtexFrameBlocks::word_t*>(bitstream.mFrameBlocks.mBlock[block][frame]->getWords());
317  for(uint32_t index = 0; index < frameLength; index++) {
318  *ptr++ = words[index];
319  }
320  }
321  // only block type 0 is present in this particular bitstream
322  // if we try to copy block type 1 frames into the packet, we will trash memory
323  break;
324  }
325  }
326  }
327  // write the test bitstream back out
328  std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
329  BOOST_REQUIRE(outputStream.good());
330  bitstream.write(outputStream);
331  outputStream.flush();
332  BOOST_REQUIRE(torc::common::fileContentsAreEqual(referencePath, generatedPath));
333 
334  return;
335 }
boost::filesystem::path path
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.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void torc::bitstream::bitstream::testVirtexFullMapping ( const boost::filesystem::path &  inWorkingPath)

Definition at line 328 of file VirtexUnitTest.cpp.

328  {
329  // build the file paths
331  / "torc" / "bitstream" / "VirtexUnitTest.reference.bit";
333  / "regression" / "VirtexMapUnitTest.generated.bit";
334 
335  // read the bitstream
336  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
337  BOOST_REQUIRE(fileStream.good());
338  // read and gather bitstream frames
339  Virtex bitstream;
340  bitstream.read(fileStream, false);
341 
342  // initialize frame map
343  bitstream.initializeDeviceInfo("xcv50");
344  bitstream.initializeFrameMaps();
345 
346  // load bitstream frames in data structure
347  bitstream.initializeFullFrameBlocks();
348 
349  // write full bitstream from frame blocks data structure
350  uint32_t frameLength = bitstream.getFrameLength();
351  typedef boost::shared_array<uint32_t> WordSharedArray;
352  Virtex::iterator p = bitstream.begin();
353  Virtex::iterator e = bitstream.end();
354  while(p < e) {
355  const VirtexPacket& packet = *p++;
356  if(packet.isType2()) {
357  WordSharedArray words = packet.getWords();
358  uint32_t* ptr = words.get();
359  for(uint32_t block = 0; block < 8; block++) {
360  for(uint32_t frame = 0; frame < bitstream.mBlockFrameIndexBounds[block]; frame++) {
361  VirtexFrameBlocks::word_t* words = const_cast<VirtexFrameBlocks::word_t*>(bitstream.mFrameBlocks.mBlock[block][frame]->getWords());
362  for(uint32_t index = 0; index < frameLength; index++) {
363  *ptr++ = words[index];
364  }
365  }
366  }
367  }
368  }
369  // write the test bitstream back out
370  std::fstream outputStream(generatedPath.string().c_str(), std::ios::binary | std::ios::out);
371  BOOST_REQUIRE(outputStream.good());
372  bitstream.write(outputStream);
373  outputStream.flush();
374  BOOST_REQUIRE(torc::common::fileContentsAreEqual(referencePath, generatedPath));
375 
376  return;
377 }
boost::filesystem::path path
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.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: