VCDFile.hpp
Go to the documentation of this file.
1 
2 #include <map>
3 #include <string>
4 #include <vector>
5 
6 #include "VCDTypes.hpp"
7 #include "VCDValue.hpp"
8 
9 #ifndef VCDFile_HPP
10 #define VCDFile_HPP
11 
12 
13 /*!
14 @brief Top level object to represent a single VCD file.
15 */
16 class VCDFile {
17 
18  public:
19 
20  //! Instance a new VCD file container.
21  VCDFile();
22 
23  //! Destructor
24  ~VCDFile();
25 
26  //! Timescale of the VCD file.
28 
29  //! Multiplier of the VCD file time units.
31 
32  //! Date string of the VCD file.
33  std::string date;
34 
35  //! Version string of the simulator which generated the VCD.
36  std::string version;
37 
38  //! Version string of the simulator which generated the VCD.
39  std::string comment;
40 
41  //! Root scope node of the VCD signals
43 
44  /*!
45  @brief Add a new scope object to the VCD file
46  @param s in - The VCDScope object to add to the VCD file.
47  */
48  void add_scope(
49  VCDScope * s
50  );
51 
52  /*!
53  @brief Add a new signal to the VCD file
54  @param s in - The VCDSignal object to add to the VCD file.
55  */
56  void add_signal(
57  VCDSignal * s
58  );
59 
60 
61  /*!
62  @brief Add a new timestamp value to the VCD file.
63  @details Add a time stamp to the sorted array of existing
64  timestamps in the file.
65  @param time in - The timestamp value to add to the file.
66  */
67  void add_timestamp(
68  VCDTime time
69  );
70 
71 
72  /*!
73  @brief Return the scope object in the VCD file with this name
74  @param name in - The name of the scope to get and return.
75  */
77  VCDScopeName name
78  );
79 
80 
81  /*!
82  @brief Add a new signal value to the VCD file, tagged by time.
83  @param time_val in - A signal value, tagged by the time it occurs.
84  @param hash in - The VCD hash value representing the signal.
85  */
86  void add_signal_value(
87  VCDTimedValue * time_val,
88  VCDSignalHash hash
89  );
90 
91 
92  /*!
93  @brief Get the value of a particular signal at a specified time.
94  @note The supplied time value does not need to exist in the
95  vector returned by get_timestamps().
96  @param hash in - The hashcode for the signal to identify it.
97  @param time in - The time at which we want the value of the signal.
98  @param erase_prior in - Erase signals prior to this time. Avoids O(n^2) searching times when scanning large .vcd files sequentially.
99  @returns A pointer to the value at the supplie time, or nullptr if
100  no such record can be found.
101  */
103  const VCDSignalHash& hash,
104  VCDTime time,
105  bool erase_prior = false
106  );
107 
108  /*!
109  @brief Get a vector of VCD time values
110  @param hash in - The hashcode for the signal to identify it.
111  @returns A pointer to the vector of time values, or nullptr if hash not found
112  */
114  VCDSignalHash hash
115  );
116 
117  /*!
118  @brief Return a pointer to the set of timestamp samples present in
119  the VCD file.
120  */
121  std::vector<VCDTime>* get_timestamps();
122 
123  /*!
124  @brief Get a vector of all scopes present in the file.
125  */
126  std::vector<VCDScope*>* get_scopes();
127 
128  /*!
129  @brief Return a flattened vector of all signals in the file.
130  */
131  std::vector<VCDSignal*>* get_signals();
132 
133  protected:
134 
135  //! Flat vector of all signals in the file.
136  std::vector<VCDSignal*> signals;
137 
138  //! Flat mao of all scope objects in the file, keyed by name.
139  std::vector<VCDScope*> scopes;
140 
141  //! Vector of time values present in the VCD file - sorted, asc
142  std::vector<VCDTime> times;
143 
144  //! Map of hashes onto vectors of times and signal values.
145  std::map<VCDSignalHash, VCDSignalValues*> val_map;
146 };
147 
148 
149 #endif
VCDTimeUnit time_units
Timescale of the VCD file.
Definition: VCDFile.hpp:27
std::string VCDSignalHash
Compressed hash representation of a signal.
Definition: VCDTypes.hpp:23
A file for common types and data structures used by the VCD parser.
void add_signal(VCDSignal *s)
Add a new signal to the VCD file.
Definition: VCDFile.cpp:59
std::vector< VCDScope * > * get_scopes()
Get a vector of all scopes present in the file.
Definition: VCDFile.cpp:104
std::vector< VCDTime > times
Vector of time values present in the VCD file - sorted, asc.
Definition: VCDFile.hpp:142
std::map< VCDSignalHash, VCDSignalValues * > val_map
Map of hashes onto vectors of times and signal values.
Definition: VCDFile.hpp:145
std::vector< VCDScope * > scopes
Flat mao of all scope objects in the file, keyed by name.
Definition: VCDFile.hpp:139
VCDScope * root_scope
Root scope node of the VCD signals.
Definition: VCDFile.hpp:42
std::vector< VCDSignal * > * get_signals()
Return a flattened vector of all signals in the file.
Definition: VCDFile.cpp:111
Represents a single value found in a VCD File.
Definition: VCDValue.hpp:12
A signal value tagged with times.
Definition: VCDTypes.hpp:63
std::deque< VCDTimedValue * > VCDSignalValues
A vector of tagged time/value pairs, sorted by time values.
Definition: VCDTypes.hpp:70
Represents a single signal reference within a VCD file.
Definition: VCDTypes.hpp:121
VCDValue * get_signal_value_at(const VCDSignalHash &hash, VCDTime time, bool erase_prior=false)
Get the value of a particular signal at a specified time.
Definition: VCDFile.cpp:126
void add_scope(VCDScope *s)
Add a new scope object to the VCD file.
Definition: VCDFile.cpp:49
void add_timestamp(VCDTime time)
Add a new timestamp value to the VCD file.
Definition: VCDFile.cpp:118
std::vector< VCDSignal * > signals
Flat vector of all signals in the file.
Definition: VCDFile.hpp:136
~VCDFile()
Destructor.
Definition: VCDFile.cpp:13
Represents a scope type, scope name pair and all of it&#39;s child signals.
Definition: VCDTypes.hpp:133
std::string date
Date string of the VCD file.
Definition: VCDFile.hpp:33
VCDFile()
Instance a new VCD file container.
Definition: VCDFile.cpp:8
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
void add_signal_value(VCDTimedValue *time_val, VCDSignalHash hash)
Add a new signal value to the VCD file, tagged by time.
Definition: VCDFile.cpp:87
unsigned VCDTimeRes
Specifies the timing resoloution along with VCDTimeUnit.
Definition: VCDTypes.hpp:29
VCDScope * get_scope(VCDScopeName name)
Return the scope object in the VCD file with this name.
Definition: VCDFile.cpp:74
Top level object to represent a single VCD file.
Definition: VCDFile.hpp:16
VCDSignalValues * get_signal_values(VCDSignalHash hash)
Get a vector of VCD time values.
Definition: VCDFile.cpp:169
std::string comment
Version string of the simulator which generated the VCD.
Definition: VCDFile.hpp:39
VCDTimeRes time_resolution
Multiplier of the VCD file time units.
Definition: VCDFile.hpp:30
double VCDTime
Represents a single instant in time in a trace.
Definition: VCDTypes.hpp:26
VCDTimeUnit
Represents the possible time units a VCD file is specified in.
Definition: VCDTypes.hpp:97
std::string VCDScopeName
Friendly name for a scope.
Definition: VCDTypes.hpp:20