-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtest_glob_const.cpp
97 lines (75 loc) · 1.84 KB
/
test_glob_const.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
/******************************************************************************
* Copyright (c) 2020, Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
*
*****************************************************************************/
#include <systemc.h>
const unsigned A = 1;
const bool B = true;
namespace NS {
const unsigned C = 2;
const bool D = false;
};
const unsigned E = 3;
// Global constant and constant in name space used in MIF
struct mif : public sc_module, public sc_interface
{
sc_signal<sc_uint<4>> s;
SC_HAS_PROCESS(mif);
explicit mif(const sc_module_name& name) : sc_module(name)
{
SC_METHOD(methProc); sensitive << s;
}
sc_signal<int> t0;
void methProc() {
unsigned i = !NS::D ? A : 0;
t0 = i;
}
};
// Global constant and constant in name space used in MIF
struct mif2 : public sc_module, public sc_interface
{
sc_signal<sc_uint<4>> s;
SC_HAS_PROCESS(mif2);
explicit mif2(const sc_module_name& name) : sc_module(name)
{
SC_METHOD(methProc); sensitive << s;
}
sc_signal<int> t1;
void methProc() {
unsigned i = B ? NS::C : 0;
t1 = i;
}
};
SC_MODULE(mod)
{
mif minst{"minst"};
SC_CTOR(mod)
{}
};
SC_MODULE(Top)
{
sc_in_clk clk{"clk"};
sc_signal<bool> nrst;
sc_signal<sc_uint<4>> t;
mif2 minst{"minst"};
mod m{"m"};
SC_CTOR(Top)
{
SC_METHOD(topProc); sensitive << t;
}
sc_signal<int> t0;
void topProc() {
unsigned i = E;
t0 = i;
}
};
int sc_main(int argc, char **argv)
{
sc_clock clk {"clk", sc_time(1, SC_NS)};
Top top{"top"};
top.clk(clk);
sc_start();
return 0;
}