Last change
on this file since 51 was
35,
checked in by buchmann, 15 years ago
|
Code cleanup.
Add --dynamiclink option to systemcass executable.
|
File size:
1.5 KB
|
Rev | Line | |
---|
[1] | 1 | #include <systemc.h> |
---|
| 2 | #include <signal.h> |
---|
| 3 | #include <iostream> |
---|
| 4 | #include <fstream> |
---|
| 5 | |
---|
| 6 | #define ASSERT(x) \ |
---|
| 7 | { \ |
---|
| 8 | if (!(x)) \ |
---|
| 9 | { \ |
---|
| 10 | cerr << "ASSERT : '" #x "' at cycle number " << sc_simulation_time () << "\n"; \ |
---|
| 11 | exit (1); \ |
---|
| 12 | } \ |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | using namespace std; |
---|
| 16 | |
---|
| 17 | struct inner_test : public sc_module |
---|
| 18 | { |
---|
| 19 | virtual void transition () |
---|
| 20 | { |
---|
[34] | 21 | cout << "This function is a virtual one.\n"; |
---|
[1] | 22 | }; |
---|
| 23 | inner_test(sc_module_name n) |
---|
| 24 | { |
---|
| 25 | }; |
---|
| 26 | }; |
---|
| 27 | |
---|
| 28 | struct test : public inner_test |
---|
| 29 | { |
---|
| 30 | sc_in<bool> clk; |
---|
| 31 | sc_in<bool> resetn; |
---|
| 32 | sc_out<int> o; |
---|
| 33 | sc_in <int> i; |
---|
| 34 | sc_signal<int> reg; |
---|
| 35 | |
---|
[35] | 36 | virtual void transition (); |
---|
[1] | 37 | void gen_moore (); |
---|
| 38 | void gen_mealy (); |
---|
| 39 | |
---|
| 40 | SC_HAS_PROCESS(test); |
---|
| 41 | test(sc_module_name n) : inner_test (n) |
---|
| 42 | { |
---|
| 43 | SC_METHOD(transition); |
---|
| 44 | sensitive << clk.pos(); |
---|
| 45 | SC_METHOD(gen_moore); |
---|
| 46 | sensitive << clk.neg(); |
---|
| 47 | SC_METHOD(gen_mealy); |
---|
| 48 | sensitive << clk.neg() << i; |
---|
| 49 | } |
---|
| 50 | }; |
---|
| 51 | |
---|
| 52 | void test::transition () |
---|
| 53 | { |
---|
| 54 | std::cout << "transition\n"; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | void test::gen_moore () |
---|
| 58 | { |
---|
| 59 | std::cout << "gen_moore\n"; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | void test::gen_mealy () |
---|
| 63 | { |
---|
| 64 | std::cout << "gen_mealy\n"; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | int sc_main (int argc, char *argv[]) |
---|
| 70 | { |
---|
| 71 | sc_clock clk("clk"); |
---|
| 72 | sc_signal<bool> resetn("resetn"); |
---|
| 73 | sc_signal<int> in ("in"); |
---|
| 74 | sc_signal<int> out("out"); |
---|
| 75 | |
---|
| 76 | test test("test"); |
---|
| 77 | test.clk (clk); |
---|
| 78 | test.resetn (resetn); |
---|
| 79 | |
---|
| 80 | test.i (in); |
---|
| 81 | test.o (out); |
---|
| 82 | |
---|
| 83 | sc_initialize (); |
---|
| 84 | |
---|
| 85 | resetn = false; |
---|
| 86 | sc_start (3); |
---|
| 87 | resetn = true; |
---|
| 88 | sc_start (10); |
---|
| 89 | |
---|
| 90 | cout << "Test OK.\n"; |
---|
[35] | 91 | return EXIT_SUCCESS; |
---|
[1] | 92 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.