source: sources/test_regression/02052006/system.cpp @ 56

Last change on this file since 56 was 55, checked in by meunier, 11 years ago

Tried to clean the test_regression directory:

  • Code formatting
  • Supressed warnings
  • Made comprehensible outputs
  • Factorized Makefiles

There's still a lot to do (many tests don't pass for either good or bad reasons)

File size: 4.5 KB
Line 
1
2#include <systemc.h>
3#include <typeinfo>
4
5#include "test.h"
6
7
8// Tests deactivated (not supported in SystemCass):
9// - sc_signal applied to float values (QM)
10// Tests failing:
11// - sc_int<X> with X different from 16, 32 and 64
12
13
14using namespace std;
15
16struct test : sc_module {
17    int32_t                  reg;
18    sc_signal<bool>          reg_bool;
19    sc_signal<int>           reg_int;
20    sc_signal<unsigned int>  reg_unsigned_int;
21    sc_signal<char>          reg_char;
22#ifdef ALL_TESTS
23    sc_signal<float>         reg_float;
24    sc_signal<double>        reg_double;
25#endif
26    sc_signal<long>          reg_long;
27    sc_signal< sc_uint<32> > reg_ui32;
28    sc_signal< sc_uint<16> > reg_ui16;
29    sc_signal< sc_uint<6> >  reg_ui6;
30    sc_signal< sc_int<32> >  reg_i32;
31    sc_signal< sc_int<16> >  reg_i16;
32    sc_signal< sc_int<6> >   reg_i6;
33    sc_in<bool> clk;
34    sc_in<bool> resetn;
35
36    void trans() {
37        if (resetn.read() == true) {
38            //ASSERT(((reg & 1)) == reg_bool.read());
39            //ASSERT(((int) reg) == reg_int.read());
40            //ASSERT(((unsigned int) reg) == reg_unsigned_int.read());
41            //ASSERT(((char) reg) == reg_char.read());
42#ifdef ALL_TEST
43            //ASSERT(((float) reg) == reg_float.read());
44            //ASSERT(((double) reg) == reg_double.read());
45#endif
46            //ASSERT(((long) reg) == reg_long.read());
47            //ASSERT(((unsigned int) reg & 0xFFFFFFFF) == (unsigned int) (reg_ui32.read()));
48            //ASSERT(((unsigned int) reg & 0x0000FFFF) == (unsigned int) (reg_ui16.read()));
49            //ASSERT(((unsigned int) reg & 0x0000003F) == (unsigned int) (reg_ui6.read()));
50            //ASSERT(((signed int) (reg & 0xFFFFFFFF)) == (signed int) (reg_i32.read()));
51            //ASSERT(((signed int) (reg & 0x0000FFFF)) == (signed int) (reg_i16.read()));
52            //cout << "reg & 0x3F : " << (signed int) (reg & 0x3F) << endl;
53            //cout << "reg_i6 : " << reg_i6.read() << endl;
54            //ASSERT(((reg & 0x3F) < 32 && ((signed int) (reg & 0x3F)) == (signed int) (reg_i6.read())) || ((reg & 0x3F) >= 32 && (signed int) (reg & 0x3F) != (signed int) (reg_i6.read())));
55            cout << "reg_bool : " << reg_bool << endl;
56            cout << "reg_int : " << reg_int << endl;
57            cout << "reg_unsigned_int : " << reg_unsigned_int << endl;
58            cout << "reg_char : " << (unsigned int) reg_char << endl;
59#ifdef ALL_TESTS
60            cout << "reg_float : " << reg_float << endl;
61            cout << "reg_double : " << reg_double << endl;
62#endif
63            cout << "reg_long : " << reg_long << endl;
64            cout << "reg_ui32 : " << reg_ui32 << endl;
65            cout << "reg_ui16 : " << reg_ui16 << endl;
66            cout << "reg_ui6 : " << reg_ui6 << endl;
67            cout << "reg_i32 : " << reg_i32 << endl;
68            cout << "reg_i16 : " << reg_i16 << endl;
69            cout << "reg_i6 : " << reg_i6 << endl;
70
71            reg = reg + 1;
72            reg_bool = reg & 1;
73            reg_int = reg;
74            reg_unsigned_int = reg;
75            reg_char = reg;
76#ifdef ALL_TESTS
77            reg_float.write(reg);
78            reg_double.write(reg);
79#endif
80            reg_long = reg;
81            reg_ui32 = reg;
82            reg_ui16 = reg;
83            reg_ui6 = reg;
84            reg_i32 = reg;
85            reg_i16 = reg;
86            reg_i6  = reg;
87        }
88        else {
89            reg = 0;
90            reg_bool = 0;
91            reg_int = 0;
92            reg_unsigned_int = 0;
93            reg_char = 0;
94#ifdef ALL_TESTS
95            reg_float = 0;
96            reg_double = 0;
97#endif
98            reg_long = 0;
99            reg_ui32 = 0;
100            reg_ui16 = 0;
101            reg_ui6 = 0;
102            reg_i32 = 0;
103            reg_i16 = 0;
104            reg_i6 = 0;
105        }
106    }
107
108    SC_HAS_PROCESS(test);
109    test(sc_module_name n) : sc_module (n),
110    clk("clk") {
111        SC_METHOD(trans);
112        sensitive << clk.pos();
113        dont_initialize();
114    }
115
116};
117
118
119int sc_main (int argc, char * argv[]) {
120    sc_clock signal_clk("my_clock", sc_time(1, sc_core::SC_NS));
121    sc_signal<bool> resetn("resetn");
122
123    test test1("test1");
124    test1.clk(signal_clk);
125    test1.resetn(resetn);
126
127    // Init & run
128    sc_start(sc_time(0, sc_core::SC_NS));
129
130    resetn = false;
131    sc_start(sc_time(4, sc_core::SC_NS));
132    resetn = true;
133    sc_start(sc_time(100, sc_core::SC_NS));
134
135    return EXIT_SUCCESS;
136}
137
138#undef sc_inout
139
140/*
141# Local Variables:
142# tab-width: 4;
143# c-basic-offset: 4;
144# c-file-offsets:((innamespace . 0)(inline-open . 0));
145# indent-tabs-mode: nil;
146# End:
147#
148# vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
149*/
150
Note: See TracBrowser for help on using the repository browser.