Last change
on this file since 45 was
1,
checked in by buchmann, 17 years ago
|
Initial import from CVS repository
|
File size:
1.7 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; |
---|
38 | reg_ui33 = reg; |
---|
39 | reg_ui32 = reg; |
---|
40 | reg_ui16 = reg; |
---|
41 | reg_ui6 = reg; |
---|
42 | reg_i2 = reg; |
---|
43 | } else { |
---|
44 | reg = 0; |
---|
45 | reg_bool = 0; |
---|
46 | reg_char = 0; |
---|
47 | reg_double = 0; |
---|
48 | reg_ui64 = 0; |
---|
49 | reg_ui33 = 0; |
---|
50 | reg_ui32 = 0; |
---|
51 | reg_ui16 = 0; |
---|
52 | reg_ui6 = 0; |
---|
53 | reg_i2 = 0; |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | SC_HAS_PROCESS(test); |
---|
58 | test (sc_module_name n) : sc_module (n), |
---|
59 | clk("clk") |
---|
60 | { |
---|
61 | SC_METHOD(trans); |
---|
62 | sensitive << clk.pos(); |
---|
63 | dont_initialize(); |
---|
64 | }; |
---|
65 | }; |
---|
66 | |
---|
67 | int sc_main (int argc, char *argv[]) |
---|
68 | { |
---|
69 | sc_clock signal_clk("my_clock",1, 0.5); |
---|
70 | sc_signal<bool> resetn("resetn"); |
---|
71 | |
---|
72 | test test1("test1"); |
---|
73 | test1.clk (signal_clk); |
---|
74 | test1.resetn (resetn); |
---|
75 | |
---|
76 | // Init & run |
---|
77 | sc_start (0); |
---|
78 | |
---|
79 | resetn = false; |
---|
80 | sc_start (4); |
---|
81 | resetn = true; |
---|
82 | sc_start (100); |
---|
83 | |
---|
84 | return EXIT_SUCCESS; |
---|
85 | } |
---|
86 | |
---|
87 | #undef sc_inout |
---|
Note: See
TracBrowser
for help on using the repository browser.