ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
ErrorDefinition.h
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2//
3// This file is part of ETISS. It is licensed under the BSD 3-Clause License; you may not use this file except in
4// compliance with the License. You should have received a copy of the license along with this project. If not, see the
5// LICENSE file.
13#ifndef ETISS_ERRORDEFINITION_H_
14#define ETISS_ERRORDEFINITION_H_
15#include "etiss/Misc.h"
16#include <iostream>
17#include <string>
18#include <vector>
19
20#if defined(__GXX_EXPERIMENTAL_CXX0X) || __cplusplus >= 201103L // check if c++0x/c++11 is supported
21#define ETISS_USE_CPP11 1
22#else
23#define ETISS_USE_CPP11 0
24#endif
25
26namespace etiss
27{
28
29namespace error
30{
31
38class Error
39{
40 public:
41 const bool persistent_;
42 int id_;
43 std::string name_;
48 Error(bool persistent, int id = -1, const std::string &name = "");
49 virtual ~Error();
50 virtual void apply(uint64_t &var) = 0;
51 virtual void apply(uint32_t &var);
52 virtual void apply(uint16_t &var);
53 virtual void apply(uint8_t &var);
54 virtual const std::vector<unsigned> affectedBits() = 0;
55};
56
57class BitFlip : public Error
58{
59 private:
60 std::vector<unsigned> flipped_positions;
62
63 public:
64 template <typename iterateableT>
65 BitFlip(const iterateableT &positions, int id = -1, const std::string &name = "") : Error(false, id, name)
66 {
67 flip = 0;
68 flipped_positions.resize(positions.size());
69 for (typename iterateableT::const_iterator iter = positions.begin(); iter != positions.end(); ++iter)
70 {
71 flipped_positions.push_back(*iter);
72 flip |= 1 << (*iter);
73 }
74 }
75
76 virtual void apply(uint64_t &var);
77
78 template <typename T>
79 inline void fapply(T &var)
80 {
81 var = (T)(var ^ flip);
82 }
83
84 virtual const std::vector<unsigned> affectedBits();
85};
86
87class StuckHigh : public Error
88{
89 private:
90 std::vector<unsigned> high_positions;
92
93 public:
94 template <typename iterateableT>
95 StuckHigh(const iterateableT &positions, int id = -1, const std::string &name = "") : Error(true, id, name)
96 {
97 high = 0;
98 high_positions.resize(positions.size());
99 for (typename iterateableT::const_iterator iter = positions.begin(); iter != positions.end(); ++iter)
100 {
101 high_positions.push_back(*iter);
102 high |= 1 << (*iter);
103 }
104 }
105
106 virtual void apply(uint64_t &var);
107
108 template <typename T>
109 inline void fapply(T &var)
110 {
111 var = (T)(var | high);
112 }
113
114 virtual const std::vector<unsigned> affectedBits();
115};
116
117class StuckLow : public Error
118{
119 private:
120 std::vector<unsigned> low_positions;
122
123 public:
124 template <typename iterateableT>
125 StuckLow(const iterateableT &positions, int id = -1, const std::string &name = "") : Error(true, id, name)
126 {
127 low = 0;
128 low_positions.resize(positions.size());
129 for (typename iterateableT::const_iterator iter = positions.begin(); iter != positions.end(); ++iter)
130 {
131 low_positions.push_back(*iter);
132 low |= 1 << (*iter);
133 }
134 low = ~low;
135 }
136
137 virtual void apply(uint64_t &var);
138
139 template <typename T>
140 inline void fapply(T &var)
141 {
142 var = (T)(var & low);
143 }
144
145 virtual const std::vector<unsigned> affectedBits();
146};
147
148} // namespace error
149
150} // namespace etiss
151
152#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
virtual void apply(uint64_t &var)=0
virtual const std::vector< unsigned > affectedBits()=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="")
forwards: include/jit/*
Definition Benchmark.h:17
#define true
Definition stdbool.h:16
#define false
Definition stdbool.h:17