VCDValue.hpp
Go to the documentation of this file.
1 
2 #ifndef VCDValue_HPP
3 #define VCDValue_HPP
4 
5 #include "VCDTypes.hpp"
6 
7 /*!
8 @brief Represents a single value found in a VCD File.
9 @details Can contain a single bit (a scalar), a bti vector, or an
10 IEEE floating point number.
11 */
12 class VCDValue {
13 
14 
15  //! Convert a VCDBit to a single char
16  static char VCDBit2Char(VCDBit b) {
17  switch(b) {
18  case(VCD_0):
19  return '0';
20  case(VCD_1):
21  return '1';
22  case(VCD_Z):
23  return 'Z';
24  case(VCD_X):
25  default:
26  return 'X';
27  }
28  }
29 
30  public:
31 
32  /*!
33  @brief Create a new VCDValue with the type VCD_SCALAR
34  */
35  VCDValue (
37  );
38 
39  /*!
40  @brief Create a new VCDValue with the type VCD_VECTOR
41  */
42  VCDValue (
43  VCDBitVector * value
44  );
45 
46  /*!
47  @brief Create a new VCDValue with the type VCD_VECTOR
48  */
49  VCDValue (
50  VCDReal value
51  );
52 
53 
54  ~VCDValue () {
55  if(this -> type == VCD_VECTOR) {
56  delete this -> value.val_vector;
57  }
58  }
59 
60 
61  //! Return the type of value stored by this class instance.
63 
64  //! Get the bit value of the instance.
66 
67  //! Get the vector value of the instance.
69 
70  //! Get the real value of the instance.
72 
73 
74  protected:
75 
76  //! The type of value this instance stores.
78 
79  //! The actual value stored, as identified by type.
80  union valstore {
81  VCDBit val_bit; //!< Value as a bit
82  VCDBitVector * val_vector;//!< Value as a bit vector
83  VCDReal val_real; //!< Value as a real number (double).
84  } value;
85 };
86 
87 
88 
89 #endif
VCDValueType type
The type of value this instance stores.
Definition: VCDValue.hpp:77
std::vector< VCDBit > VCDBitVector
A vector of VCDBit values.
Definition: VCDTypes.hpp:44
VCDValueType get_type()
Return the type of value stored by this class instance.
Definition: VCDValue.cpp:33
VCDBitVector * val_vector
Value as a bit vector.
Definition: VCDValue.hpp:82
VCDReal val_real
Value as a real number (double).
Definition: VCDValue.hpp:83
A file for common types and data structures used by the VCD parser.
Logic one.
Definition: VCDTypes.hpp:37
union VCDValue::valstore value
Unknown / Undefined.
Definition: VCDTypes.hpp:38
~VCDValue()
Definition: VCDValue.hpp:54
VCDBit val_bit
Value as a bit.
Definition: VCDValue.hpp:81
Represents a single value found in a VCD File.
Definition: VCDValue.hpp:12
The actual value stored, as identified by type.
Definition: VCDValue.hpp:80
VCDBitVector * get_value_vector()
Get the vector value of the instance.
Definition: VCDValue.cpp:47
double VCDReal
Typedef to identify a real number as stored in a VCD.
Definition: VCDTypes.hpp:47
VCDValueType
Describes how a signal value is represented in the VCD trace.
Definition: VCDTypes.hpp:51
Logic zero.
Definition: VCDTypes.hpp:36
Vector of VCDBit.
Definition: VCDTypes.hpp:53
VCDBit
Represents the four-state signal values of a VCD file.
Definition: VCDTypes.hpp:35
VCDReal get_value_real()
Get the real value of the instance.
Definition: VCDValue.cpp:54
High Impedence.
Definition: VCDTypes.hpp:39
VCDBit get_value_bit()
Get the bit value of the instance.
Definition: VCDValue.cpp:40
VCDValue(VCDBit value)
Create a new VCDValue with the type VCD_SCALAR.
Definition: VCDValue.cpp:7