sc_uint
sc_uint is unsigned integer, and it is fixed precision integer of size 64 bits. The underlying operations use 64 bits, but the result size is determined at object declaration.
Operands of type sc_uint can be converted to type sc_int and vice versa by using assignment statements. When assigning an integer to an unsigned operand, the integer value in 2's complement form is interpreted as an unsigned number. When assigning an unsigned to a signed operand, the unsigned is expanded to a 64 bit unsigned number and then truncated to get the signed value.
sc_uint has rich operators as in the case of sc_int. Look at sc_int for details.
Example sc_uint
1 #include
2
3 int sc_main (int argc, char* argv[]) {
4 sc_uint<1> bit_size = 0;
5 sc_uint<4> nibble_size = 1;
6 sc_uint<8> byte_size = 2;
7 sc_uint<32> dword_size = 3;
8 //sc_int addr; sc_int can not be more then 64
9 // Perform auto increment
10 dword_size ++;
11 cout <<"Value of dword_size : " << dword_size << endl;
12 // Terse method addition
13 byte_size += nibble_size;
14 cout <<"Value of byte_size : " << byte_size << endl;
15 // Bit selection
16 bit_size = dword_size[2];
17 cout <<"Value of bit_size : " << bit_size << endl;
18 // Range selection
19 nibble_size = dword_size.range(4,1); // Can not assign out of range
20 cout <<"Value of nibble_size: " << nibble_size << endl;
21 // Concatenated
22 dword_size = (byte_size,byte_size,byte_size,byte_size);
23 cout <<"Value of dword_size : " << dword_size << endl;
24
25 return 1;
26 }
Simulator Output: sc_uint
SystemC 2.0.1 --- Oct 6 2006 19:17:37
Copyright (c) 1996-2002 by all Contributors
ALL RIGHTS RESERVED
Value of dword_size : 4
Value of byte_size : 3
Value of bit_size : 1
Value of nibble_size: 2
Value of dword_size : 50529027
sc_bigint
There are time when operands need to be larger than 64 bits. For these types of designs sc_int will not work. For these cases SystemC provides type sc_bigint (arbitrary sized signed integer). These types allow the designer to work on integers of any size, limited only by underlying system limitations. Arithmetic and other operators also use arbitrary precision when performing operations. SystemC define's MAX_NBITS in sc_constants.h to limit the max size of the bits for sc_bigint to 512.
Type sc_bigint is a 2's complement signed integer of any size. sc_bigint has rich operators as in the case of sc_int. Look at sc_int for details.
Example sc_bigint
1 #include
2
3 int sc_main (int argc, char* argv[]) {
4 sc_bigint<128> large_size ;
5 // Shift operator
6 large_size = 1000 << 1;
7 cout <<"Value of large_size : " << large_size << endl;
8
9 return 1;
10 }
Simulator Output: sc_bigint
SystemC 2.0.1 --- Oct 6 2006 19:17:37
Copyright (c) 1996-2002 by all Contributors
ALL RIGHTS RESERVED
Value of large_size : 2000
sc_biguint
sc_biguint is same as sc_bigint, only difference is sc_biguint is unsigned. These types allow the designer to work on integers of any size, limited only by underlying system limitations. Arithmetic and other operators also use arbitrary precision when performing operations. SystemC define's MAX_NBITS in sc_constants.h to limit the max size of the bits for sc_biguint to 512.
sc_biguint has rich operators as in the case of sc_int. Look at sc_int for details.
Example sc_biguint
1 #include
2
3 int sc_main (int argc, char* argv[]) {
4 sc_biguint<128> a = 30000;
5 sc_biguint<128> b = 20000;
6 sc_biguint<256> c = 0;
7 // multiplication operator
8 c = a * b;
9 cout <<"Value of c : " << c << endl;
10
11 return 1;
12 }
Simulator Output: sc_biguint
SystemC 2.0.1 --- Oct 6 2006 19:17:37
Copyright (c) 1996-2002 by all Contributors
ALL RIGHTS RESERVED
Value of c : 600000000
Bạn Có Đam Mê Với Vi Mạch hay Nhúng - Bạn Muốn Trau Dồi Thêm Kĩ Năng
Mong Muốn Có Thêm Cơ Hội Trong Công Việc
Và Trở Thành Một Người Có Giá Trị Hơn