Last change
on this file since 4 was
1,
checked in by buchmann, 17 years ago
|
Initial import from CVS repository
|
File size:
1.2 KB
|
Line | |
---|
1 | #include <systemc.h> |
---|
2 | |
---|
3 | #define ASSERT(x) \ |
---|
4 | { \ |
---|
5 | if (!(x)) \ |
---|
6 | { \ |
---|
7 | cerr << "ASSERT : " #x "\n"; \ |
---|
8 | exit (1); \ |
---|
9 | } \ |
---|
10 | } |
---|
11 | |
---|
12 | using namespace std; |
---|
13 | |
---|
14 | struct test : sc_module { |
---|
15 | int reg; |
---|
16 | |
---|
17 | sc_in_clk clk; |
---|
18 | sc_in<bool> resetn; |
---|
19 | |
---|
20 | sc_out<int> o1; |
---|
21 | sc_inout<bool> o2; |
---|
22 | |
---|
23 | void trans () |
---|
24 | { |
---|
25 | if (resetn.read() == true) |
---|
26 | { |
---|
27 | reg = reg + 1; |
---|
28 | } else { |
---|
29 | reg = 0; |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | void gen () |
---|
34 | { |
---|
35 | o2 = 0; |
---|
36 | o1 = reg; |
---|
37 | o2 = reg & 1; |
---|
38 | } |
---|
39 | |
---|
40 | SC_HAS_PROCESS(test); |
---|
41 | test (sc_module_name n) : sc_module (n), |
---|
42 | clk("clk") |
---|
43 | { |
---|
44 | SC_METHOD(trans); |
---|
45 | sensitive << clk.pos(); |
---|
46 | dont_initialize(); |
---|
47 | SC_METHOD(gen); |
---|
48 | sensitive << clk.neg(); |
---|
49 | dont_initialize(); |
---|
50 | }; |
---|
51 | }; |
---|
52 | |
---|
53 | int sc_main (int argc, char *argv[]) |
---|
54 | { |
---|
55 | sc_clock signal_clk("my_clock",1, 0.5); |
---|
56 | sc_signal<bool> resetn("resetn"); |
---|
57 | sc_signal<int > s01("s01"); |
---|
58 | sc_signal<bool> s02("s02"); |
---|
59 | |
---|
60 | test test1("test1"); |
---|
61 | test1.clk (signal_clk); |
---|
62 | test1.resetn (resetn); |
---|
63 | test1.o1 (s01); |
---|
64 | test1.o2 (s02); |
---|
65 | |
---|
66 | // Init & run |
---|
67 | sc_start (0); |
---|
68 | |
---|
69 | resetn = false; |
---|
70 | sc_start (4); |
---|
71 | resetn = true; |
---|
72 | sc_start (100); |
---|
73 | |
---|
74 | return EXIT_SUCCESS; |
---|
75 | } |
---|
76 | |
---|
77 | #undef sc_inout |
---|
Note: See
TracBrowser
for help on using the repository browser.