/
TriggerWiringModule.h
57 lines (53 loc) · 1.75 KB
/
TriggerWiringModule.h
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
// See LICENSE for license details.
#include "bridges/synthesized_assertions.h"
#include "simif_peek_poke.h"
class TriggerWiringModule_t : public simif_peek_poke_t {
public:
std::vector<synthesized_assertions_t *> assert_endpoints;
TriggerWiringModule_t(int argc, char **argv) {
std::vector<std::string> args(argv + 1, argv + argc);
ASSERTBRIDGEMODULE_0_substruct_create;
ASSERTBRIDGEMODULE_1_substruct_create;
assert_endpoints.push_back(
new synthesized_assertions_t(this,
args,
ASSERTBRIDGEMODULE_0_substruct,
ASSERTBRIDGEMODULE_0_assert_count,
ASSERTBRIDGEMODULE_0_assert_messages));
assert_endpoints.push_back(
new synthesized_assertions_t(this,
args,
ASSERTBRIDGEMODULE_1_substruct,
ASSERTBRIDGEMODULE_1_assert_count,
ASSERTBRIDGEMODULE_1_assert_messages));
};
bool simulation_complete() {
bool is_complete = false;
for (auto &e : assert_endpoints) {
is_complete |= e->terminate();
}
return is_complete;
}
int exit_code() {
for (auto &e : assert_endpoints) {
if (e->exit_code())
return e->exit_code();
}
return 0;
}
void run() {
int assertions_thrown = 0;
for (auto ep : assert_endpoints)
ep->init();
poke(reset, 1);
step(1);
poke(reset, 0);
step(10000, false);
while (!done() && !simulation_complete()) {
for (auto ep : assert_endpoints) {
ep->tick();
}
}
expect(!exit_code(), "No assertions should be thrown");
}
};