This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
netlistFaultInjector.hpp
68 lines (57 loc) · 2.03 KB
/
netlistFaultInjector.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Copyright (C) 2022 Intel Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License, as published
* by the Free Software Foundation; either version 3 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#ifndef NETLISTFAULTINJECTOR_H_
#define NETLISTFAULTINJECTOR_H_
#include <string>
#include <vector>
#include <map>
typedef enum {
SIGNAL_TYPE_WIRE,
SIGNAL_TYPE_REG,
SIGNAL_TYPE_INPUT,
SIGNAL_TYPE_OUTPUT,
SIGNAL_TYPE_NROF
} signalType_t;
typedef struct {
signalType_t Type;
size_t Width;
size_t ElemCnt; // i.e. array elements
size_t UUID;
} signal_t;
// TODO: All this string and vector stuff causes the compilation to take forever.
typedef struct {
std::string Name;
std::vector<signal_t> FiSignal;
std::vector<std::pair<size_t, size_t>> InstanceUuids; // <index of module of this instance, uuid>
} module_t;
extern const std::vector<module_t> modules;
extern const size_t modulesTopIndex;
extern const size_t modulesTopUUID;
class NetlistFaultInjector {
public:
int Init(); // NOTE: Assumes srand was called outside
int RandomFiGet(std::vector<uint16_t> * moduleInstanceChain, uint32_t * assignmentUUID, size_t * width);
private:
std::map<size_t, size_t> FiSignalCntCache_; // <index, fi-signal cnt>
int ModuleFiBitsCnt(size_t * bits, size_t moduleIndex);
size_t FiBitCnt_ = 0;
int RandomFiGet(std::vector<uint16_t> * modInst, uint32_t * assignNr, size_t * width, size_t moduleIndex, uint16_t moduleUUID);
};
#endif /* NETLISTFAULTINJECTOR_H_ */