-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtest_array_method2.cpp
124 lines (95 loc) · 2.39 KB
/
test_array_method2.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/******************************************************************************
* Copyright (c) 2020, Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
*
*****************************************************************************/
#include "sct_assert.h"
#include "systemc.h"
using namespace sc_core;
// Member(not local) record arrays
template <unsigned N>
class A : public sc_module {
public:
sc_signal<bool> dummy{"dummy"};
SC_CTOR(A)
{
SC_METHOD(rec_mod_arr1);
sensitive << dummy;
// Simple inner record works for now
SC_METHOD(rec_mod_inner0);
sensitive << dummy;
// Inner records
SC_METHOD(rec_mod_inner1);
sensitive << dummy;
SC_METHOD(rec_mod_inner2);
sensitive << dummy;
}
struct Simple {
bool a = true;
int b = 42;
};
Simple marr1[2];
Simple marr2[2][3];
sc_signal<int> t0;
void rec_mod_arr1()
{
marr1[1].a = false;
marr2[1][2].a = !marr1[1].a;
int c = marr2[1][0].b + marr1[0].b;
t0 = c;
sct_assert_const(!marr1[1].a);
sct_assert_const(marr2[1][2].a);
sct_assert_array_defined(marr2[1][2].a);
sct_assert_read(marr2[1][0].b);
}
//---------------------------------------------------------------------------
// Inner structure array
struct Inner {
bool a;
};
struct Outer {
bool b;
Inner r;
};
struct OuterArr {
bool b;
Inner r[3];
};
Outer oo;
sc_signal<int> t1;
void rec_mod_inner0()
{
oo.r.a = true;
bool b = !oo.r.a;
t1 = b;
}
Outer oarr[2];
void rec_mod_inner1()
{
oarr[0].b = false;
oarr[1].r.a = !oarr[0].b;
sct_assert_const(!oarr[0].b);
sct_assert_const(oarr[1].r.a);
sct_assert_array_defined(oarr[1].r.a);
sct_assert_read(oarr[0].b);
}
OuterArr orec;
void rec_mod_inner2()
{
orec.b = false;
orec.r[1].a = !orec.b;
sct_assert_const(orec.r[1].a);
}
};
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;
}