Last change
on this file since 38 was
35,
checked in by buchmann, 15 years ago
|
Code cleanup.
Add --dynamiclink option to systemcass executable.
|
File size:
1.2 KB
|
Rev | Line | |
---|
[1] | 1 | #include <systemc.h> |
---|
| 2 | |
---|
| 3 | using namespace std; |
---|
| 4 | |
---|
| 5 | struct test : sc_module { |
---|
[35] | 6 | sc_in_clk clk; |
---|
[1] | 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); |
---|
[35] | 29 | test (sc_module_name n) : sc_module (n), |
---|
[1] | 30 | clk("clk"), |
---|
| 31 | i1("i1"), |
---|
| 32 | o1("o1"), |
---|
| 33 | o2("o2"), |
---|
| 34 | reg1("reg1"), |
---|
| 35 | reg2("reg2") |
---|
| 36 | { |
---|
[35] | 37 | SC_METHOD(trans); |
---|
| 38 | sensitive << clk.pos(); |
---|
[1] | 39 | dont_initialize(); |
---|
[35] | 40 | SC_METHOD(gen); |
---|
| 41 | sensitive << clk.neg(); |
---|
[1] | 42 | dont_initialize(); |
---|
[35] | 43 | }; |
---|
[1] | 44 | }; |
---|
| 45 | |
---|
| 46 | int sc_main (int argc, char *argv[]) |
---|
| 47 | { |
---|
[35] | 48 | sc_clock signal_clk("my_clock",1, 0.5); |
---|
[1] | 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 | |
---|
[35] | 59 | // Init & run |
---|
| 60 | sc_start (0); |
---|
[1] | 61 | |
---|
| 62 | sc_start (10); |
---|
| 63 | |
---|
[35] | 64 | return EXIT_SUCCESS; |
---|
[1] | 65 | } |
---|
| 66 | |
---|
| 67 | #undef sc_inout |
---|
Note: See
TracBrowser
for help on using the repository browser.