Last change
on this file since 10 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_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 | }; |
---|
47 | }; |
---|
48 | |
---|
49 | int sc_main (int argc, char *argv[]) |
---|
50 | { |
---|
51 | sc_clock signal_clk("my_clock",1, 0.5); |
---|
52 | sc_signal<bool> resetn("resetn"); |
---|
53 | sc_signal<int > s01("s01"); |
---|
54 | sc_signal<bool> s02("s02"); |
---|
55 | |
---|
56 | test test1("test1"); |
---|
57 | test1.clk (signal_clk); |
---|
58 | test1.resetn (resetn); |
---|
59 | test1.o1 (s01); |
---|
60 | test1.o2 (s02); |
---|
61 | |
---|
62 | // Init & run |
---|
63 | sc_start (0); |
---|
64 | |
---|
65 | resetn = false; |
---|
66 | sc_start (4); |
---|
67 | resetn = true; |
---|
68 | sc_start (100); |
---|
69 | |
---|
70 | return EXIT_SUCCESS; |
---|
71 | } |
---|
72 | |
---|
73 | #undef sc_inout |
---|
Note: See
TracBrowser
for help on using the repository browser.