Last change
on this file since 41 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 | sc_in_clk clk; |
---|
16 | sc_in<int> i1; |
---|
17 | sc_out<int> o1; |
---|
18 | sc_out<bool> o2; |
---|
19 | |
---|
20 | sc_signal<bool> reg1; |
---|
21 | sc_signal<int> reg2; |
---|
22 | |
---|
23 | void trans () |
---|
24 | { |
---|
25 | reg1 = i1 & 1; |
---|
26 | reg2 = i1; |
---|
27 | } |
---|
28 | |
---|
29 | void gen () |
---|
30 | { |
---|
31 | o2 = reg1.read(); |
---|
32 | o1 = reg2.read() + 1; |
---|
33 | } |
---|
34 | |
---|
35 | SC_HAS_PROCESS(test); |
---|
36 | test (sc_module_name n) : sc_module (n), |
---|
37 | clk("clk"), |
---|
38 | i1("i1"), |
---|
39 | o1("o1"), |
---|
40 | o2("o2"), |
---|
41 | reg1("reg1"), |
---|
42 | reg2("reg2") |
---|
43 | { |
---|
44 | SC_METHOD(trans); |
---|
45 | sensitive << clk.pos(); |
---|
46 | dont_initialize(); |
---|
47 | SC_METHOD(gen); |
---|
48 | sensitive << clk.neg(); |
---|
49 | dont_initialize(); |
---|
50 | }; |
---|
51 | }; |
---|
52 | |
---|
53 | int sc_main (int argc, char *argv[]) |
---|
54 | { |
---|
55 | sc_clock signal_clk("my_clock",1, 0.5); |
---|
56 | sc_signal<int> s01("s01"); |
---|
57 | sc_signal<int> s02("s02"); |
---|
58 | sc_signal<bool> s03("s03"); |
---|
59 | |
---|
60 | test test1("test1"); |
---|
61 | test1.clk (signal_clk); |
---|
62 | test1.i1 (s01); |
---|
63 | test1.o1 (s02); |
---|
64 | test1.o2 (s03); |
---|
65 | |
---|
66 | // Init & run |
---|
67 | sc_start (0); |
---|
68 | |
---|
69 | sc_start (10); |
---|
70 | |
---|
71 | return EXIT_SUCCESS; |
---|
72 | } |
---|
73 | |
---|
Note: See
TracBrowser
for help on using the repository browser.