Last change
on this file since 64 was
1,
checked in by buchmann, 17 years ago
|
Initial import from CVS repository
|
File size:
1.4 KB
|
Line | |
---|
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 | { |
---|
21 | }; |
---|
22 | inner_test(sc_module_name n) |
---|
23 | { |
---|
24 | }; |
---|
25 | }; |
---|
26 | |
---|
27 | struct test : public inner_test |
---|
28 | { |
---|
29 | sc_in<bool> clk; |
---|
30 | sc_in<bool> resetn; |
---|
31 | sc_out<int> o; |
---|
32 | sc_in <int> i; |
---|
33 | sc_signal<int> reg; |
---|
34 | |
---|
35 | void transition (); |
---|
36 | void gen_moore (); |
---|
37 | void gen_mealy (); |
---|
38 | |
---|
39 | SC_HAS_PROCESS(test); |
---|
40 | test(sc_module_name n) : inner_test (n) |
---|
41 | { |
---|
42 | SC_METHOD(transition); |
---|
43 | sensitive << clk.pos(); |
---|
44 | SC_METHOD(gen_moore); |
---|
45 | sensitive << clk.neg(); |
---|
46 | SC_METHOD(gen_mealy); |
---|
47 | sensitive << clk.neg() << i; |
---|
48 | } |
---|
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"; |
---|
91 | return EXIT_SUCCESS; |
---|
92 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.