1 | #include "systemc.h" |
---|
2 | #include <iostream> |
---|
3 | |
---|
4 | |
---|
5 | using namespace std; |
---|
6 | |
---|
7 | |
---|
8 | int |
---|
9 | sc_main (int argc, char ** argv) |
---|
10 | { |
---|
11 | int errnum = 0; |
---|
12 | |
---|
13 | sc_uint<32> a; |
---|
14 | sc_uint<3> b; |
---|
15 | sc_uint<2> c; |
---|
16 | sc_uint<5> d; |
---|
17 | sc_uint<8> e; |
---|
18 | sc_uint<10> f; |
---|
19 | |
---|
20 | a = 0xCFFFFFFF; |
---|
21 | b = 0x7; |
---|
22 | c = 0x3; |
---|
23 | d = 0xA0; |
---|
24 | e = 0x11; |
---|
25 | f = 0x1A0; |
---|
26 | |
---|
27 | cerr << "a = 0x" << hex << (unsigned int)a << " = " << a.to_string (SC_BIN) << "\n"; |
---|
28 | if (a.to_string (SC_BIN) != "0b011001111111111111111111111111111") |
---|
29 | exit (errnum); |
---|
30 | errnum++; |
---|
31 | |
---|
32 | cerr << "b = 0x" << hex << (unsigned int)b << " = " << b.to_string (SC_BIN) << "\n"; |
---|
33 | if (b.to_string (SC_BIN) != "0b0111") |
---|
34 | exit (errnum); |
---|
35 | errnum++; |
---|
36 | |
---|
37 | cerr << "c = 0x" << hex << (unsigned int)c << " = " << c.to_string (SC_BIN) << "\n"; |
---|
38 | if (c.to_string (SC_BIN) != "0b011") |
---|
39 | exit (errnum); |
---|
40 | errnum++; |
---|
41 | |
---|
42 | cerr << "d = 0x" << hex << (unsigned int)d << " = " << d.to_string (SC_BIN) << "\n"; |
---|
43 | if (d.to_string (SC_BIN) != "0b000000") |
---|
44 | exit (errnum); |
---|
45 | errnum++; |
---|
46 | |
---|
47 | cerr << "e = 0x" << hex << (unsigned int)e << " = " << e.to_string (SC_BIN) << "\n"; |
---|
48 | if (e.to_string (SC_BIN) != "0b000010001") |
---|
49 | exit (errnum); |
---|
50 | errnum++; |
---|
51 | |
---|
52 | cerr << "f = 0x" << hex << (unsigned int)f << " = " << f.to_string (SC_BIN) << "\n"; |
---|
53 | if (f.to_string (SC_BIN) != "0b00110100000") |
---|
54 | exit (errnum); |
---|
55 | errnum++; |
---|
56 | |
---|
57 | |
---|
58 | cerr << "b,e = 0x" << hex << (unsigned int)(b,e) << " = " << (b,e).to_string (SC_BIN) << "\n"; |
---|
59 | if ((b,e).to_string (SC_BIN) != "0b011100010001") |
---|
60 | exit (errnum); |
---|
61 | errnum++; |
---|
62 | |
---|
63 | |
---|
64 | cerr << "b,c,d,e,f = 0x" << hex << (unsigned int)(b,c,d,e,f) << " = " << (b,c,d,e,f).to_string (SC_BIN) << "\n"; |
---|
65 | if ((b,c,d,e,f).to_string (SC_BIN) != "0b01111100000000100010110100000") |
---|
66 | exit (errnum); |
---|
67 | errnum++; |
---|
68 | |
---|
69 | a = b,c,d,e,f; |
---|
70 | cerr << "a = b,c,d,e,f; a = 0x" << hex << (unsigned int) a << " = " << a.to_string (SC_BIN) << "\n"; |
---|
71 | if (a.to_string (SC_BIN) != "0b000000000000000000000000000000111") |
---|
72 | exit (errnum); |
---|
73 | errnum++; |
---|
74 | |
---|
75 | sc_uint<3> tb = b.range (2,0); |
---|
76 | cerr << "b.range (2,0) = 0x" << hex << (unsigned int) tb << " = " << tb.to_string (SC_BIN) << "\n"; |
---|
77 | if (tb.to_string (SC_BIN) != "0b0111") |
---|
78 | exit (errnum); |
---|
79 | errnum++; |
---|
80 | |
---|
81 | sc_uint<5> te = e.range (5,1); |
---|
82 | cerr << "e.range (5,1) = 0x" << hex << (unsigned int) te << " = " << te.to_string (SC_BIN) << "\n"; |
---|
83 | if (te.to_string (SC_BIN) != "0b001000") |
---|
84 | exit (errnum); |
---|
85 | errnum++; |
---|
86 | |
---|
87 | sc_uint<5> tf = f.range (9,5); |
---|
88 | cerr << "f.range (9,5) = 0x" << hex << (unsigned int) tf << " = " << tf.to_string (SC_BIN) << "\n"; |
---|
89 | if (tf.to_string (SC_BIN) != "0b001101") |
---|
90 | exit (errnum); |
---|
91 | errnum++; |
---|
92 | |
---|
93 | sc_uint<5> tf2 = f.range (8,4); |
---|
94 | a = (tf2,b,c,d,e,f); |
---|
95 | cerr << "a = f.range (7,3),b,c,d,e,f; a = 0x" << hex << (unsigned int) a << " = " << a.to_string (SC_BIN) << "\n"; |
---|
96 | if (a.to_string (SC_BIN) != "0b010101111100000000100010110100000") |
---|
97 | exit (errnum); |
---|
98 | errnum++; |
---|
99 | |
---|
100 | return 0; |
---|
101 | } |
---|
102 | |
---|