-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtest_mif_simple2.cpp
61 lines (49 loc) · 1.08 KB
/
test_mif_simple2.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
/******************************************************************************
* Copyright (c) 2020, Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
*
*****************************************************************************/
#include <systemc.h>
// Simple MIF with one method process
struct mod_if: public sc_module, sc_interface
{
sc_in_clk clk;
sc_signal<bool> s;
SC_CTOR(mod_if)
{
SC_METHOD(mifProc);
sensitive << s;
}
void mifProc()
{
bool b = s;
s = !b;
}
};
struct Dut : public sc_module
{
sc_in_clk clk;
sc_signal<bool> s;
mod_if* minst;
SC_CTOR(Dut)
{
minst = new mod_if("minst");
minst->clk(clk);
SC_METHOD(topProc);
sensitive << minst->s;
}
void topProc()
{
bool b = minst->s;
s = !b;
}
};
int sc_main(int argc, char **argv)
{
Dut dut{"dut"};
sc_clock clk("clk", 1, SC_NS);
dut.clk(clk);
sc_start();
return 0;
}