另外可參考
http://www.fpgastudy.com/a/course/SystemC/707.html
#include "systemc.h"
int sc_main (int argc, char* argv[]) {
sc_int<1> bit_size = 0;
sc_int<4> nibble_size = 1;
sc_int<8> byte_size = 2;
sc_int<32> dword_size = 3;
//sc_int<128> addr; sc_int can not be more then 64
// Perform auto increment
dword_size ++;
cout <<"Value of dword_size : " << dword_size << endl;
dword_size(5,4) = dword_size(3,2);
cout <<"Value of dword_size : " << dword_size << endl;
// Terse method addition
byte_size += nibble_size;
cout <<"Value of byte_size : " << byte_size << endl;
// Bit selection
bit_size = dword_size[2]; //此處應該為1 可是結果為 -1 ???
cout <<"Value of bit_size : " << bit_size << endl;
// Range selection
nibble_size = dword_size.range(4,1); // Can not assign out of range
cout <<"Value of nibble_size: " << nibble_size << endl;
// Concatenated
dword_size = (byte_size,byte_size);
cout <<"Value of dword_size : " << dword_size << endl;
return 1;
}
Copyright (c) 1996-2006 by all Contributors
ALL RIGHTS RESERVED
Value of dword_size : 4 // 3++=4
Value of dword_size : 20 // 010100 =20
Value of byte_size : 3 //2 + 1 =3
Value of bit_size : -1 //
Value of nibble_size: 2
Value of dword_size : 771 // = 00000011_00000011
cout <<"Value of bit_size : " << bit_size << endl;
其結果都為-1
沒有留言:
張貼留言