Last change
on this file since 32 was
1,
checked in by buchmann, 17 years ago
|
Initial import from CVS repository
|
File size:
1.8 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 | sc_signal<bool> reg_bool; |
---|
17 | sc_signal<char> reg_char; |
---|
18 | sc_signal<double> reg_double; |
---|
19 | sc_signal<sc_biguint<64> > reg_ui64; |
---|
20 | sc_signal<sc_uint<33> > reg_ui33; |
---|
21 | sc_signal<sc_uint<32> > reg_ui32; |
---|
22 | sc_signal<sc_uint<16> > reg_ui16; |
---|
23 | sc_signal<sc_uint<6> > reg_ui6; |
---|
24 | sc_signal<sc_int<2> > reg_i2; |
---|
25 | |
---|
26 | sc_in_clk clk; |
---|
27 | sc_in<bool> resetn; |
---|
28 | |
---|
29 | void trans () |
---|
30 | { |
---|
31 | if (resetn.read() == true) |
---|
32 | { |
---|
33 | reg = reg + 1; |
---|
34 | reg_bool = reg & 1; |
---|
35 | reg_char = reg; |
---|
36 | reg_double = reg; |
---|
37 | reg_ui64 = reg-1; |
---|
38 | reg_ui64 = reg; |
---|
39 | reg_ui33 = reg; |
---|
40 | reg_ui32 = reg; |
---|
41 | reg_ui16 = reg; |
---|
42 | reg_ui6 = reg; |
---|
43 | reg_i2 = 1; |
---|
44 | reg_i2 = 0; |
---|
45 | reg_i2 = reg; |
---|
46 | } else { |
---|
47 | reg = 0; |
---|
48 | reg_bool = 0; |
---|
49 | reg_char = 0; |
---|
50 | reg_double = 0; |
---|
51 | reg_ui64 = 0; |
---|
52 | reg_ui33 = 0; |
---|
53 | reg_ui32 = 0; |
---|
54 | reg_ui16 = 0; |
---|
55 | reg_ui6 = 0; |
---|
56 | reg_i2 = 0; |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | SC_HAS_PROCESS(test); |
---|
61 | test (sc_module_name n) : sc_module (n), |
---|
62 | clk("clk") |
---|
63 | { |
---|
64 | SC_METHOD(trans); |
---|
65 | sensitive << clk.pos(); |
---|
66 | dont_initialize(); |
---|
67 | }; |
---|
68 | }; |
---|
69 | |
---|
70 | int sc_main (int argc, char *argv[]) |
---|
71 | { |
---|
72 | sc_clock signal_clk("my_clock",1, 0.5); |
---|
73 | sc_signal<bool> resetn("resetn"); |
---|
74 | |
---|
75 | test test1("test1"); |
---|
76 | test1.clk (signal_clk); |
---|
77 | test1.resetn (resetn); |
---|
78 | |
---|
79 | // Init & run |
---|
80 | sc_start (0); |
---|
81 | |
---|
82 | resetn = false; |
---|
83 | sc_start (4); |
---|
84 | resetn = true; |
---|
85 | sc_start (100); |
---|
86 | |
---|
87 | return EXIT_SUCCESS; |
---|
88 | } |
---|
89 | |
---|
90 | #undef sc_inout |
---|
Note: See
TracBrowser
for help on using the repository browser.