-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtest_mif_array_unkwn.cpp
106 lines (83 loc) · 2.15 KB
/
test_mif_array_unkwn.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
/******************************************************************************
* Copyright (c) 2020, Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
*
*****************************************************************************/
//
// Created by mmoiseev on 06/14/19.
//
#include <systemc.h>
// Array of modular interface pointers accessed at unknown index
struct mod_if : public sc_module, sc_interface
{
sc_signal<sc_uint<4>> s {"s"};
sc_uint<4> v;
sc_uint<4> vv;
sc_signal<int>* p;
sc_uint<4>* vp;
SC_CTOR(mod_if)
{
p = new sc_signal<int>("p");
vp = sc_new<sc_uint<4>>();
SC_METHOD(metProc);
sensitive << s;
//SC_CTHREAD(thrProc, clk.pos());
//async_reset_signal_is(rst, true);
}
void metProc() {
//v = s.read();
s = 1;
*p = 2;
*vp = 3;
}
void f() {
v = s;
}
// void thrProc() {
// v = 1;
// wait();
// while (true) {
// bool b = v++;
// wait();
// }
// }
};
SC_MODULE(Top) {
sc_in_clk clk{"clk"};
sc_signal<bool> rst;
sc_signal<int> t;
mod_if* minst[2];
SC_CTOR(Top) {
for (int i = 0; i < 2; i++) {
minst[i] = new mod_if("mod_if");
}
SC_METHOD(top_method);
sensitive << minst[0]->s << minst[1]->s << t;
}
sc_signal<int> t1;
void top_method()
{
int i = t;
minst[i]->s = 1;
minst[i]->p->write(2);
(*minst[i]->p).write(3);
*(minst[i]->p) = 4;
//*minst[i]->vp = 5; // Error reported
minst[i]->vv = 0;
for (int j = 0; j < 2; ++j) minst[j]->v = j;
t1 = minst[0]->v;
t1 = minst[i]->vv;
sc_uint<4> a = minst[i]->s;
minst[i]->s = minst[i+1]->v + a;
minst[i]->f();
}
};
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;
}