Last change
on this file since 40 was
34,
checked in by buchmann, 15 years ago
|
Remove an unused regression test.
Update some other tests.
Add a TODO section into README file.
Disable some debugging compiler options for common users.
|
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 | sc_signal<int> reg; |
---|
16 | |
---|
17 | sc_in_clk clk; |
---|
18 | sc_in<bool> resetn; |
---|
19 | |
---|
20 | sc_out<int> o1; |
---|
21 | sc_out<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 | o1 = reg; |
---|
36 | o2 = reg & 1; |
---|
37 | } |
---|
38 | |
---|
39 | SC_HAS_PROCESS(test); |
---|
40 | test (sc_module_name n) : sc_module (n), |
---|
41 | clk("clk") |
---|
42 | { |
---|
43 | SC_METHOD(trans); |
---|
44 | sensitive << clk.pos(); |
---|
45 | dont_initialize(); |
---|
46 | SC_METHOD(gen); |
---|
47 | sensitive << clk.neg(); |
---|
48 | dont_initialize(); |
---|
49 | }; |
---|
50 | }; |
---|
51 | |
---|
52 | int sc_main (int argc, char *argv[]) |
---|
53 | { |
---|
54 | sc_clock signal_clk("my_clock",1, 0.5); |
---|
55 | sc_signal<bool> resetn("resetn"); |
---|
56 | sc_signal<int > s01("s01"); |
---|
57 | sc_signal<bool> s02("s02"); |
---|
58 | |
---|
59 | test test1("test1"); |
---|
60 | test1.clk (signal_clk); |
---|
61 | test1.resetn (resetn); |
---|
62 | test1.o1 (s01); |
---|
63 | test1.o2 (s02); |
---|
64 | |
---|
65 | // Init & run |
---|
66 | sc_start (0); |
---|
67 | |
---|
68 | resetn = false; |
---|
69 | sc_start (4); |
---|
70 | resetn = true; |
---|
71 | sc_start (100); |
---|
72 | |
---|
73 | return EXIT_SUCCESS; |
---|
74 | } |
---|
75 | |
---|
76 | #undef sc_inout |
---|
Note: See
TracBrowser
for help on using the repository browser.