可以了解bus形態的操作
#include
int sc_main (int argc, char* argv[]) {
sc_bv<8> data_bus ;
sc_bv<16> addr_bus ;
sc_bit parity ;
// Assign value to sc_bv
data_bus = "00001011";
cout <<"Value of data_bus : " << data_bus << endl;
// Use range operator
addr_bus.range(7,0) = data_bus;
cout <<"Value of addr_bus : " << addr_bus << endl;
// Assign reverse to addr bus using range operator
addr_bus.range(0,7) = data_bus;
cout <<"Value of addr_bus : " << addr_bus << endl;
// Use bit select to set the value
addr_bus[10] = "1";
cout <<"Value of addr_bus : " << addr_bus << endl;
// Use reduction operator
parity = data_bus.xor_reduce();
cout <<"Value of parity : " << parity << endl;
return 1;
}
結果
SystemC 2.2.0 --- Mar 18 2011 18:40:28
Copyright (c) 1996-2006 by all Contributors
ALL RIGHTS RESERVED
Info: (I804) /IEEE_Std_1666/deprecated: sc_bit is deprecated, use bool instead
Value of data_bus : 00001011
Value of addr_bus : 0000000000001011 // addr_bus.range(7,0) = data_bus;
Value of addr_bus : 0000000011010000 // addr_bus.range(0,7) = data_bus;
Value of addr_bus : 0000010011010000 // addr_bus[10] = "1";
Value of parity : 1 // parity = data_bus.xor_reduce();
sc width Bit 的相關method可查SystemC-1666-2005 Chapter 7. Data types
沒有留言:
張貼留言