Last change
on this file since 43 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
|
Rev | Line | |
---|
[1] | 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 { |
---|
[34] | 15 | sc_signal<int> reg; |
---|
[1] | 16 | |
---|
| 17 | sc_in_clk clk; |
---|
| 18 | sc_in<bool> resetn; |
---|
| 19 | |
---|
| 20 | sc_out<int> o1; |
---|
[34] | 21 | sc_out<bool> o2; |
---|
[1] | 22 | |
---|
| 23 | void trans () |
---|
| 24 | { |
---|
| 25 | if (resetn.read() == true) |
---|
| 26 | { |
---|
| 27 | reg = reg + 1; |
---|
| 28 | } else { |
---|
| 29 | reg = 0; |
---|
| 30 | } |
---|
[34] | 31 | reg = 2; |
---|
[1] | 32 | } |
---|
| 33 | |
---|
| 34 | void gen () |
---|
| 35 | { |
---|
| 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.