Bitstream Interpretation Library (BIL)  0.1
xdlcmp.cpp
Go to the documentation of this file.
1 
7 #include <cstdlib>
8 #include <cstring>
9 #include <fstream>
10 #include <iostream>
16 #include <xdl/parser/XDLParser.hpp>
17 
18 using namespace bil;
19 
20 
21 int main(int argc, char** argv)
22 {
23  try
24  {
25  //======================================================================
26  // process given command line
27  std::cout << SPLASH_MSG;
28  parseCommandLine(argc, argv);
29 
30 
31  //======================================================================
32  // parse reference XDL file
33  std::cout << READING_REFERENCE_XDL_MSG;
34  Device device;
35  Design refDesign;
36  {
37  // open XDL file and parse its header
38  XDLParser parser;
39  std::ifstream xdlInputStream(xdlRefFileName.c_str());
40  std::cout << PARSING_XDL_HEADER_MSG;
41  parser.parseHeader(xdlInputStream, refDesign);
42 
43  // load device file of corresponding device
44  std::string devicePackageName = removeSpeed((refDesign.deviceName()).c_str());
45  std::cout << LOADING_DEVICE1_MSG << devicePackageName << LOADING_DEVICE2_MSG;
46  std::string deviceFileName = dataPathName + devicePackageName + DEVICE_FILE_EXT;
47  std::ifstream deviceInputStream(deviceFileName.c_str(), std::ios::binary);
48  readBinary(device, deviceInputStream);
49 
50  // parse XDL
51  std::cout << PARSING_XDL_MSG;
52  parser.parseBody(device);
53  }
54 
55  //======================================================================
56  // parse test XDL file
57  std::cout << READING_TEST_XDL_MSG;
58  Design testDesign;
59  {
60  // open XDL file and parse it
61  XDLParser parser;
62  std::ifstream xdlInputStream(xdlTestFileName.c_str());
63  std::cout << PARSING_XDL_HEADER_MSG;
64  parser.parseHeader(xdlInputStream, testDesign);
65  std::cout << PARSING_XDL_MSG;
66  parser.parseBody(device);
67  }
68 
69 
70  //======================================================================
71  // get PIPs and compare them
72  std::cout << COMPARING_MSG;
73  PIPRefs refPIPRefs;
74  getPIPs(refDesign, refPIPRefs);
75  refDesign.clear();
76 
77  PIPRefs testPIPRefs;
78  getPIPs(testDesign, testPIPRefs);
79  testDesign.clear();
80 
81  std::ofstream reportOutputStream(reportFileName.c_str());
82  comparePIPs(refPIPRefs, testPIPRefs, device, reportOutputStream);
83 
84 
85  //======================================================================
86  // finished
87  std::cout << FINISHED_MSG;
88  }
89  catch (const CommandLineException& e)
90  {
91  std::cout << ERROR_MSG << e.what() << INFO_MSG;
92  return EXIT_FAILURE;
93  }
94  catch (...)
95  {
96  std::cout << ERROR_UNKNOWN_MSG;
97  return EXIT_FAILURE;
98  }
99  return EXIT_SUCCESS;
100 }