Last change
on this file since 44 was
35,
checked in by buchmann, 15 years ago
|
Code cleanup.
Add --dynamiclink option to systemcass executable.
|
File size:
1.2 KB
|
Line | |
---|
1 | #include <systemc.h> |
---|
2 | |
---|
3 | using namespace std; |
---|
4 | |
---|
5 | struct test : sc_module { |
---|
6 | sc_in_clk clk; |
---|
7 | sc_in<int> i1; |
---|
8 | sc_out<int> o1; |
---|
9 | sc_out<bool> o2; |
---|
10 | |
---|
11 | sc_signal<bool> reg1; |
---|
12 | sc_signal<int> reg2; |
---|
13 | |
---|
14 | void trans () |
---|
15 | { |
---|
16 | reg1 = i1 & 1; |
---|
17 | reg2 = i1; |
---|
18 | } |
---|
19 | |
---|
20 | void gen () |
---|
21 | { |
---|
22 | o1 = reg2.read(); |
---|
23 | o2 = reg1.read(); |
---|
24 | o2 = reg1.read(); |
---|
25 | o1 = reg2.read() + 1; |
---|
26 | } |
---|
27 | |
---|
28 | SC_HAS_PROCESS(test); |
---|
29 | test (sc_module_name n) : sc_module (n), |
---|
30 | clk("clk"), |
---|
31 | i1("i1"), |
---|
32 | o1("o1"), |
---|
33 | o2("o2"), |
---|
34 | reg1("reg1"), |
---|
35 | reg2("reg2") |
---|
36 | { |
---|
37 | SC_METHOD(trans); |
---|
38 | sensitive << clk.pos(); |
---|
39 | dont_initialize(); |
---|
40 | SC_METHOD(gen); |
---|
41 | sensitive << clk.neg(); |
---|
42 | dont_initialize(); |
---|
43 | }; |
---|
44 | }; |
---|
45 | |
---|
46 | int sc_main (int argc, char *argv[]) |
---|
47 | { |
---|
48 | sc_clock signal_clk("my_clock",1, 0.5); |
---|
49 | sc_signal<int> s01("s01"); |
---|
50 | sc_signal<int> s02("s02"); |
---|
51 | sc_signal<bool> s03("s03"); |
---|
52 | |
---|
53 | test test1("test1"); |
---|
54 | test1.clk (signal_clk); |
---|
55 | test1.i1 (s01); |
---|
56 | test1.o1 (s02); |
---|
57 | test1.o2 (s03); |
---|
58 | |
---|
59 | // Init & run |
---|
60 | sc_start (0); |
---|
61 | |
---|
62 | sc_start (10); |
---|
63 | |
---|
64 | return EXIT_SUCCESS; |
---|
65 | } |
---|
66 | |
---|
67 | #undef sc_inout |
---|
Note: See
TracBrowser
for help on using the repository browser.