ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
InterruptVector.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.
15#ifndef ETISS_INCLUDE_INTERRUPTVECTOR_H_
16#define ETISS_INCLUDE_INTERRUPTVECTOR_H_
17
18#include "etiss/Misc.h"
19#include "etiss/jit/types.h"
20#include <list>
21#include <mutex>
22#include <set>
23#include <vector>
24
25namespace etiss
26{
27
32{
33 public:
34 virtual ~InterruptVector();
38 virtual void setBit(unsigned bit, bool state) = 0;
42 virtual bool getBit(unsigned bit) const = 0;
46 virtual unsigned width() const = 0;
50 virtual bool isActive() const;
54 virtual void clear();
55
57};
58
59template <typename INT>
65{
66 public:
67 typedef typename std::vector<INT *> Vector;
72 {
73 if (vector_.size() > mask.size())
74 {
75 vector_.resize(mask.size());
76 etiss::log(etiss::ERROR, "MappedInterruptVector: the interrupt and mask vectors must have equal size.");
77 }
78 if (vector_.size() < mask.size())
79 {
80 mask.resize(vector_.size());
81 etiss::log(etiss::ERROR, "MappedInterruptVector: the interrupt and mask vectors must have equal size.");
82 }
83 }
85 virtual void setBit(unsigned bit, bool state)
86 {
87 unsigned o = bit % (sizeof(INT) * 8);
88 unsigned i = (bit - o) / (sizeof(INT) * 8);
89 if (i < vector_.size())
90 {
91 INT mask = ((INT)1) << o;
92 *vector_[i] = (*vector_[i] & ~mask) | (state ? mask : 0);
93 }
94 // std::cout << "etiss::InterruptVector::setBit called i=" << std::dec << i << "
95 // vector[i]=" << std::hex << *vector_[i] << " mask[i]=" << *mask_[i] << std::dec <<
96 // std::endl;
97 }
98 virtual bool getBit(unsigned bit) const
99 {
100 unsigned o = bit % (sizeof(INT) * 8);
101 unsigned i = (bit - o) / (sizeof(INT) * 8);
102 INT mask = ((INT)1) << o;
103 if (i < vector_.size())
104 {
105 return ((*vector_[i] & mask) & (*mask_[i] & mask)) != 0;
106 }
107 return false;
108 }
109 virtual unsigned width() const { return (unsigned)vector_.size() * sizeof(INT); }
110 virtual bool isActive() const
111 {
112 for (unsigned i = 0; i < vector_.size(); i++)
113 {
114 if (*vector_[i] & *mask_[i])
115 return true;
116 }
117 return false;
118 }
119 virtual void clear()
120 {
121 for (unsigned i = 0; i < vector_.size(); i++)
122 {
123 *vector_[i] = (INT)0;
124 }
125 }
126
127 private:
130};
131
132} // namespace etiss
133
134#endif
general configuration and logging
interface to set interrupt bits
virtual void clear()
sets every bit to false
virtual unsigned width() const =0
number of interrupt bits
virtual bool isActive() const
virtual bool getBit(unsigned bit) const =0
get the bit of an interrupt line
virtual void setBit(unsigned bit, bool state)=0
set the bit of an interrupt line to state (true = raised)
template implementation of an InterruptVector that uses integer variables to store interrupt bit valu...
virtual bool isActive() const
virtual void clear()
sets every bit to false
std::vector< INT * > Vector
virtual void setBit(unsigned bit, bool state)
set the bit of an interrupt line to state (true = raised)
virtual bool getBit(unsigned bit) const
get the bit of an interrupt line
MappedInterruptVector(Vector vec, Vector mask)
pass two equally long integer pointer vectors that will be used for interrupt bit vectors and masks
virtual unsigned width() const
number of interrupt bits
forwards: include/jit/*
Definition Benchmark.h:17
@ ERROR
Definition Misc.h:85
void log(Verbosity level, std::string msg)
write log message at the given level.
Definition Misc.cpp:94