-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtest_assign_concat_cthread.cpp
125 lines (98 loc) · 2.66 KB
/
test_assign_concat_cthread.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
124
/******************************************************************************
* Copyright (c) 2020, Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
*
*****************************************************************************/
#include "systemc.h"
using namespace sc_core;
// Record (structure/class) assignment and field concatenation in CTHREAD
class A : public sc_module {
public:
sc_in_clk clk;
sc_signal<bool> rstn;
sc_signal<int> sig;
SC_CTOR(A)
{
SC_CTHREAD(record_assign1, clk.pos());
async_reset_signal_is(rstn, false);
SC_CTHREAD(record_assign2, clk.pos());
async_reset_signal_is(rstn, false);
// #141
//SC_CTHREAD(record_assign3, clk.pos());
//async_reset_signal_is(rstn, false);
SC_CTHREAD(record_concat_reg, clk.pos());
async_reset_signal_is(rstn, false);
SC_CTHREAD(record_concat_comb, clk.pos());
async_reset_signal_is(rstn, false);
}
struct Simple {
bool a;
int b;
};
// Record assignment in declaration and binary operator
void record_assign1()
{
Simple s; // reg
s.a = true; s.b = 42;
wait();
while (true) {
Simple r = s;
r = s;
wait();
}
}
// Record assignment in declaration and binary operator
void record_assign2()
{
wait();
while (true) {
Simple s; // comb
Simple r = s;
s = r;
wait();
}
}
// Record assignment in declaration and binary operator with member record
Simple t;
void record_assign3()
{
t.a = true; t.b = 42;
Simple v = t;
wait();
while (true) {
Simple w = t;
t = v; // #141, @v is not declared, add it to Use
wait();
}
}
void record_concat_reg()
{
Simple x;
x.b = 42;
wait();
while (true) {
Simple y;
y.b = ((sc_uint<1>)x.a, (sc_uint<2>)x.b);
wait();
}
}
void record_concat_comb()
{
wait();
while (true) {
Simple z;
Simple f;
f.b = 42;
z.b = ((sc_uint<1>)f.a, (sc_uint<2>)f.b);
wait();
}
}
};
int sc_main(int argc, char *argv[]) {
sc_clock clk("clk", 1, SC_NS);
A a{"a"};
a.clk(clk);
sc_start();
return 0;
}