VCDStandalone.cpp
Go to the documentation of this file.
1 /*!
2 @file
3 @brief Definition of the VCDFileParser class
4 */
5 
6 #include "VCDFileParser.hpp"
7 
8 /*!
9 @brief Standalone test function to allow testing of the VCD file parser.
10 */
11 int main(int argc, char **argv)
12 {
13 
14  std::string infile(argv[1]);
15 
16  std::cout << "Parsing " << infile << std::endl;
17 
18  VCDFileParser parser;
19 
20  VCDFile *trace = parser.parse_file(infile);
21 
22  if (trace)
23  {
24  std::cout << "Parse successful." << std::endl;
25  std::cout << "Version: " << trace->version << std::endl;
26  std::cout << "Date: " << trace->date << std::endl;
27  std::cout << "Signal count: " << trace->get_signals()->size() << std::endl;
28  std::cout << "Times Recorded:" << trace->get_timestamps()->size() << std::endl;
29 
30  // Print out every signal in every scope.
31  for (VCDScope *scope : *trace->get_scopes())
32  {
33 
34  std::cout << "Scope: " << scope->name << std::endl;
35 
36  for (VCDSignal *signal : scope->signals)
37  {
38 
39  std::cout << "\t" << signal->hash << "\t"
40  << signal->reference;
41 
42  if (signal->size > 1)
43  {
44  std::cout << " [" << signal->size << ":0]";
45  }
46 
47  std::cout << std::endl;
48  }
49  }
50 
51  delete trace;
52 
53  return 0;
54  }
55  else
56  {
57  std::cout << "Parse Failed." << std::endl;
58  return 1;
59  }
60 }
VCDSignalHash hash
Definition: VCDTypes.hpp:122
Class for parsing files containing CSP notation.
VCDSignalSize size
Definition: VCDTypes.hpp:125
std::vector< VCDScope * > * get_scopes()
Get a vector of all scopes present in the file.
Definition: VCDFile.cpp:104
VCDSignalReference reference
Definition: VCDTypes.hpp:123
std::vector< VCDSignal * > * get_signals()
Return a flattened vector of all signals in the file.
Definition: VCDFile.cpp:111
Represents a single signal reference within a VCD file.
Definition: VCDTypes.hpp:121
Represents a scope type, scope name pair and all of it&#39;s child signals.
Definition: VCDTypes.hpp:133
Contains the declaration of the parser driver class.
std::string date
Date string of the VCD file.
Definition: VCDFile.hpp:33
int main(int argc, char **argv)
Standalone test function to allow testing of the VCD file parser.
std::vector< VCDTime > * get_timestamps()
Return a pointer to the set of timestamp samples present in the VCD file.
Definition: VCDFile.cpp:97
std::string version
Version string of the simulator which generated the VCD.
Definition: VCDFile.hpp:36
Top level object to represent a single VCD file.
Definition: VCDFile.hpp:16
VCDFile * parse_file(const std::string &filepath)
Parse the suppled file.