ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
ErrorDefinition.h
Go to the documentation of this file.
1 
51 #ifndef ETISS_ERRORDEFINITION_H_
52 #define ETISS_ERRORDEFINITION_H_
53 #include "etiss/Misc.h"
54 #include <iostream>
55 #include <string>
56 #include <vector>
57 
58 #if defined(__GXX_EXPERIMENTAL_CXX0X) || __cplusplus >= 201103L // check if c++0x/c++11 is supported
59 #define ETISS_USE_CPP11 1
60 #else
61 #define ETISS_USE_CPP11 0
62 #endif
63 
64 namespace etiss
65 {
66 
67 namespace error
68 {
69 
76 class Error
77 {
78  public:
79  const bool persistent_;
80  int id_;
81  std::string name_;
86  Error(bool persistent, int id = -1, const std::string &name = "");
87  virtual ~Error();
88  virtual void apply(uint64_t &var) = 0;
89  virtual void apply(uint32_t &var);
90  virtual void apply(uint16_t &var);
91  virtual void apply(uint8_t &var);
92  virtual const std::vector<unsigned> affectedBits() = 0;
93 };
94 
95 class BitFlip : public Error
96 {
97  private:
98  std::vector<unsigned> flipped_positions;
100 
101  public:
102  template <typename iterateableT>
103  BitFlip(const iterateableT &positions, int id = -1, const std::string &name = "") : Error(false, id, name)
104  {
105  flip = 0;
106  flipped_positions.resize(positions.size());
107  for (typename iterateableT::const_iterator iter = positions.begin(); iter != positions.end(); ++iter)
108  {
109  flipped_positions.push_back(*iter);
110  flip |= 1 << (*iter);
111  }
112  }
113 
114  virtual void apply(uint64_t &var);
115 
116  template <typename T>
117  inline void fapply(T &var)
118  {
119  var = (T)(var ^ flip);
120  }
121 
122  virtual const std::vector<unsigned> affectedBits();
123 };
124 
125 class StuckHigh : public Error
126 {
127  private:
128  std::vector<unsigned> high_positions;
130 
131  public:
132  template <typename iterateableT>
133  StuckHigh(const iterateableT &positions, int id = -1, const std::string &name = "") : Error(true, id, name)
134  {
135  high = 0;
136  high_positions.resize(positions.size());
137  for (typename iterateableT::const_iterator iter = positions.begin(); iter != positions.end(); ++iter)
138  {
139  high_positions.push_back(*iter);
140  high |= 1 << (*iter);
141  }
142  }
143 
144  virtual void apply(uint64_t &var);
145 
146  template <typename T>
147  inline void fapply(T &var)
148  {
149  var = (T)(var | high);
150  }
151 
152  virtual const std::vector<unsigned> affectedBits();
153 };
154 
155 class StuckLow : public Error
156 {
157  private:
158  std::vector<unsigned> low_positions;
160 
161  public:
162  template <typename iterateableT>
163  StuckLow(const iterateableT &positions, int id = -1, const std::string &name = "") : Error(true, id, name)
164  {
165  low = 0;
166  low_positions.resize(positions.size());
167  for (typename iterateableT::const_iterator iter = positions.begin(); iter != positions.end(); ++iter)
168  {
169  low_positions.push_back(*iter);
170  low |= 1 << (*iter);
171  }
172  low = ~low;
173  }
174 
175  virtual void apply(uint64_t &var);
176 
177  template <typename T>
178  inline void fapply(T &var)
179  {
180  var = (T)(var & low);
181  }
182 
183  virtual const std::vector<unsigned> affectedBits();
184 };
185 
186 } // namespace error
187 
188 } // namespace etiss
189 
190 #endif // ETISS_ERRORDEFINITION_H_
general configuration and logging
static __inline__ uint32_t
Definition: arm_cde.h:25
static __inline__ uint64_t
Definition: arm_cde.h:31
static __inline__ uint8_t
Definition: arm_mve.h:323
static __inline__ uint16_t
Definition: arm_mve.h:315
virtual const std::vector< unsigned > affectedBits()
std::vector< unsigned > flipped_positions
BitFlip(const iterateableT &positions, int id=-1, const std::string &name="")
virtual void apply(uint64_t &var)
base error class for simple handling of errors
Error(bool persistent, int id=-1, const std::string &name="")
virtual const std::vector< unsigned > affectedBits()=0
virtual void apply(uint64_t &var)=0
std::vector< unsigned > high_positions
virtual void apply(uint64_t &var)
virtual const std::vector< unsigned > affectedBits()
StuckHigh(const iterateableT &positions, int id=-1, const std::string &name="")
virtual void apply(uint64_t &var)
std::vector< unsigned > low_positions
virtual const std::vector< unsigned > affectedBits()
StuckLow(const iterateableT &positions, int id=-1, const std::string &name="")
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition: Benchmark.h:53
#define true
Definition: stdbool.h:16
#define false
Definition: stdbool.h:17