Last change
on this file since 64 was
1,
checked in by buchmann, 17 years ago
|
Initial import from CVS repository
|
File size:
1.3 KB
|
Line | |
---|
1 | #include <systemc.h> |
---|
2 | |
---|
3 | #define ASSERT(x) \ |
---|
4 | { errnum++; \ |
---|
5 | if (!(x)) \ |
---|
6 | { \ |
---|
7 | cerr << "ASSERT : " #x "\n"; \ |
---|
8 | exit (errnum); \ |
---|
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 | o1 = reg2.read(); |
---|
32 | o2 = reg1.read(); |
---|
33 | o2 = reg1.read(); |
---|
34 | o1 = reg2.read() + 1; |
---|
35 | } |
---|
36 | |
---|
37 | SC_HAS_PROCESS(test); |
---|
38 | test (sc_module_name n) : sc_module (n), |
---|
39 | clk("clk"), |
---|
40 | i1("i1"), |
---|
41 | o1("o1"), |
---|
42 | o2("o2"), |
---|
43 | reg1("reg1"), |
---|
44 | reg2("reg2") |
---|
45 | { |
---|
46 | SC_METHOD(trans); |
---|
47 | sensitive << clk.pos(); |
---|
48 | dont_initialize(); |
---|
49 | SC_METHOD(gen); |
---|
50 | sensitive << clk.neg(); |
---|
51 | dont_initialize(); |
---|
52 | }; |
---|
53 | }; |
---|
54 | |
---|
55 | int sc_main (int argc, char *argv[]) |
---|
56 | { |
---|
57 | int errnum = 0; |
---|
58 | sc_clock signal_clk("my_clock",1, 0.5); |
---|
59 | sc_signal<int> s01("s01"); |
---|
60 | sc_signal<int> s02("s02"); |
---|
61 | sc_signal<bool> s03("s03"); |
---|
62 | |
---|
63 | test test1("test1"); |
---|
64 | test1.clk (signal_clk); |
---|
65 | test1.i1 (s01); |
---|
66 | test1.o1 (s02); |
---|
67 | test1.o2 (s03); |
---|
68 | |
---|
69 | // Init & run |
---|
70 | sc_start (0); |
---|
71 | |
---|
72 | sc_start (10); |
---|
73 | |
---|
74 | return EXIT_SUCCESS; |
---|
75 | } |
---|
76 | |
---|
77 | #undef sc_inout |
---|
Note: See
TracBrowser
for help on using the repository browser.