[55] | 1 | |
---|
[1] | 2 | #include <iostream> |
---|
| 3 | |
---|
[55] | 4 | #include "systemc.h" |
---|
| 5 | #include "test.h" |
---|
[1] | 6 | |
---|
| 7 | using namespace std; |
---|
| 8 | |
---|
| 9 | |
---|
[55] | 10 | int sc_main (int argc, char ** argv) { |
---|
[1] | 11 | |
---|
[55] | 12 | sc_uint<32> a; |
---|
| 13 | sc_uint<3> b; |
---|
| 14 | sc_uint<2> c; |
---|
| 15 | sc_uint<5> d; |
---|
| 16 | sc_uint<8> e; |
---|
| 17 | sc_uint<10> f; |
---|
[1] | 18 | |
---|
[55] | 19 | a = 0xCFFFFFFF; |
---|
| 20 | b = 0x7; |
---|
| 21 | c = 0x3; |
---|
| 22 | d = 0xA0; |
---|
| 23 | e = 0x11; |
---|
| 24 | f = 0x1A0; |
---|
[1] | 25 | |
---|
[60] | 26 | // Setup number of threads open-mp to 1 with the macro threads_omp() |
---|
| 27 | threads_omp(); |
---|
| 28 | |
---|
[55] | 29 | cout << "a = 0x" << hex << (unsigned int) a << " = " << a.to_string(SC_BIN) << "\n"; |
---|
| 30 | ASSERT(a.to_string (SC_BIN) == "0b011001111111111111111111111111111"); |
---|
[1] | 31 | |
---|
[55] | 32 | cout << "b = 0x" << hex << (unsigned int) b << " = " << b.to_string(SC_BIN) << "\n"; |
---|
| 33 | ASSERT(b.to_string (SC_BIN) == "0b0111"); |
---|
[1] | 34 | |
---|
[55] | 35 | cout << "c = 0x" << hex << (unsigned int) c << " = " << c.to_string(SC_BIN) << "\n"; |
---|
| 36 | ASSERT(c.to_string (SC_BIN) == "0b011"); |
---|
[1] | 37 | |
---|
[55] | 38 | cout << "d = 0x" << hex << (unsigned int) d << " = " << d.to_string(SC_BIN) << "\n"; |
---|
| 39 | ASSERT(d.to_string (SC_BIN) == "0b000000"); |
---|
[1] | 40 | |
---|
[55] | 41 | cout << "e = 0x" << hex << (unsigned int) e << " = " << e.to_string(SC_BIN) << "\n"; |
---|
| 42 | ASSERT(e.to_string (SC_BIN) == "0b000010001"); |
---|
[1] | 43 | |
---|
[55] | 44 | cout << "f = 0x" << hex << (unsigned int) f << " = " << f.to_string(SC_BIN) << "\n"; |
---|
| 45 | ASSERT(f.to_string (SC_BIN) == "0b00110100000"); |
---|
[1] | 46 | |
---|
[55] | 47 | cout << "b,e = 0x" << hex << (unsigned int) (b,e) << " = " << (b, e).to_string(SC_BIN) << "\n"; |
---|
| 48 | ASSERT((b, e).to_string (SC_BIN) == "0b011100010001"); |
---|
[1] | 49 | |
---|
[55] | 50 | cout << "b,c,d,e,f = 0x" << hex << (unsigned int) (b, c, d, e, f) << " = " << (b, c, d, e, f).to_string (SC_BIN) << "\n"; |
---|
| 51 | ASSERT((b, c, d, e, f).to_string (SC_BIN) == "0b01111100000000100010110100000"); |
---|
[1] | 52 | |
---|
[55] | 53 | a = b,c,d,e,f; |
---|
| 54 | cout << "a = b,c,d,e,f; a = 0x" << hex << (unsigned int) a << " = " << a.to_string (SC_BIN) << "\n"; |
---|
| 55 | ASSERT(a.to_string (SC_BIN) == "0b000000000000000000000000000000111"); |
---|
[1] | 56 | |
---|
[55] | 57 | sc_uint<3> tb = b.range (2, 0); |
---|
| 58 | cout << "b.range (2,0) = 0x" << hex << (unsigned int) tb << " = " << tb.to_string (SC_BIN) << "\n"; |
---|
| 59 | ASSERT(tb.to_string (SC_BIN) == "0b0111"); |
---|
[1] | 60 | |
---|
[55] | 61 | sc_uint<5> te = e.range(5, 1); |
---|
| 62 | cout << "e.range (5,1) = 0x" << hex << (unsigned int) te << " = " << te.to_string(SC_BIN) << "\n"; |
---|
| 63 | ASSERT(te.to_string(SC_BIN) == "0b001000"); |
---|
[1] | 64 | |
---|
[55] | 65 | sc_uint<5> tf = f.range(9, 5); |
---|
| 66 | cout << "f.range (9,5) = 0x" << hex << (unsigned int) tf << " = " << tf.to_string (SC_BIN) << "\n"; |
---|
| 67 | ASSERT(tf.to_string (SC_BIN) == "0b001101"); |
---|
[1] | 68 | |
---|
[55] | 69 | sc_uint<5> tf2 = f.range(8, 4); |
---|
| 70 | a = (tf2, b, c, d, e, f); |
---|
| 71 | cout << "a = f.range (7,3),b,c,d,e,f; a = 0x" << hex << (unsigned int) a << " = " << a.to_string (SC_BIN) << "\n"; |
---|
| 72 | ASSERT(a.to_string (SC_BIN) == "0b010101111100000000100010110100000"); |
---|
| 73 | |
---|
| 74 | return 0; |
---|
[1] | 75 | } |
---|
| 76 | |
---|
[55] | 77 | |
---|
| 78 | /* |
---|
| 79 | # Local Variables: |
---|
| 80 | # tab-width: 4; |
---|
| 81 | # c-basic-offset: 4; |
---|
| 82 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 83 | # indent-tabs-mode: nil; |
---|
| 84 | # End: |
---|
| 85 | # |
---|
| 86 | # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 87 | */ |
---|
| 88 | |
---|