ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
ErrorDefinition.cpp
Go to the documentation of this file.
1 /*
2 
3  @copyright
4 
5  <pre>
6 
7  Copyright 2018 Infineon Technologies AG
8 
9  This file is part of ETISS tool, see <https://github.com/tum-ei-eda/etiss>.
10 
11  The initial version of this software has been created with the funding support by the German Federal
12  Ministry of Education and Research (BMBF) in the project EffektiV under grant 01IS13022.
13 
14  Redistribution and use in source and binary forms, with or without modification, are permitted
15  provided that the following conditions are met:
16 
17  1. Redistributions of source code must retain the above copyright notice, this list of conditions and
18  the following disclaimer.
19 
20  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
21  and the following disclaimer in the documentation and/or other materials provided with the distribution.
22 
23  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse
24  or promote products derived from this software without specific prior written permission.
25 
26  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
27  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
28  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
29  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  POSSIBILITY OF SUCH DAMAGE.
34 
35  </pre>
36 
37  @author Chair of Electronic Design Automation, TUM
38 
39  @version 0.1
40 
41 */
42 
43 #include "etiss/ErrorDefinition.h"
44 
45 #if ETISS_USE_CPP11
46 #include <mutex>
47 #endif
48 
49 namespace etiss
50 {
51 
52 namespace error
53 {
54 
55 namespace
56 {
57 
59 {
60  static int cur = -1;
61 #if ETISS_USE_CPP11
62  static std::mutex id_lock;
63  std::lock_guard<std::mutex> lock(id_lock);
64 #endif
65  int ret = cur;
66  --cur;
67  if (cur >= 0)
68  {
69  std::cerr << "\n\nWARNING: etiss::error::Error ran out of ids. From now on negative ids may be assigned "
70  "multiple times.\n\n"
71  << std::endl;
72  cur = -1;
73  }
74  return ret;
75 }
76 
77 } // namespace
78 
79 Error::Error(bool persistent, int id, const std::string &name)
80  : persistent_(persistent), id_(id < 0 ? getGlobalId() : id), name_(name)
81 {
82 }
84 
86 {
87  uint64_t tmp = var;
88  apply(tmp);
89  var = (uint32_t)tmp;
90 }
92 {
93  uint64_t tmp = var;
94  apply(tmp);
95  var = (uint16_t)tmp;
96 }
98 {
99  uint64_t tmp = var;
100  apply(tmp);
101  var = (uint8_t)tmp;
102 }
103 
105 {
106  var ^= flip;
107 }
109 {
110  var |= high;
111 }
113 {
114  var &= low;
115 }
116 
117 const std::vector<unsigned> BitFlip::affectedBits()
118 {
119  return flipped_positions;
120 }
121 const std::vector<unsigned> StuckHigh::affectedBits()
122 {
123  return high_positions;
124 }
125 const std::vector<unsigned> StuckLow::affectedBits()
126 {
127  return low_positions;
128 }
129 
130 } // namespace error
131 
132 } // namespace etiss
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
virtual void apply(uint64_t &var)
Error(bool persistent, int id=-1, const std::string &name="")
virtual void apply(uint64_t &var)=0
std::vector< unsigned > high_positions
virtual void apply(uint64_t &var)
virtual const std::vector< unsigned > affectedBits()
virtual void apply(uint64_t &var)
std::vector< unsigned > low_positions
virtual const std::vector< unsigned > affectedBits()
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition: Benchmark.h:53