-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtest_if_method.cpp
89 lines (72 loc) · 1.53 KB
/
test_if_method.cpp
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/******************************************************************************
* Copyright (c) 2020, Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
*
*****************************************************************************/
#include "sct_assert.h"
#include "systemc.h"
#include <iostream>
using namespace sc_core;
// Record simple tests
template <unsigned N>
class A : public sc_module {
public:
sc_signal<bool> dummy{"dummy"};
SC_CTOR(A)
{
SC_METHOD(record_fcall);
sensitive << dummy;
SC_METHOD(record_fcall2);
sensitive << dummy;
}
struct Simple {
bool a;
int b;
};
void seta(Simple& par){
par.a = true;
}
void seta(Simple& par, bool val){
par.a = val;
}
bool f(Simple par) {
return par.a;
}
void record_fcall()
{
Simple s1;
bool c = f(s1);
if (c) {
Simple s2;
s2.b = 42;
}
}
Simple rec;
sc_signal<int> t0;
void record_fcall2()
{
t0 = 0;
rec.a = dummy.read();
Simple s1;
seta(s1);
Simple s2;
seta(s2);
bool flag = f(s1);
if (rec.a) {
int s1 = s2.b;
t0 = s1;
}
}
};
class B_top : public sc_module {
public:
A<1> a_mod{"a_mod"};
SC_CTOR(B_top) {
}
};
int sc_main(int argc, char *argv[]) {
B_top b_mod{"b_mod"};
sc_start();
return 0;
}