Verification Using SystemC Part II

Print

Using the scv_extensions_if
The abstract methods provided by scv_extensions_if can be classified into methods for static extensions and methods for dynamic extensions.

 A static extension is used for simple type information and value access or assignment. This is accomplished via the scv_get_extensions() function in the Verification Standard.

The target list of data types supported by the data introspection facility is shown in the following table.

Data Type

Partial Template Specialization

bool

class scv_extensions

char

class scv_extensions

short

class scv_extensions

int

class scv_extensions

long

class scv_extensions

long long

class scv_extensions

unsigned char

class scv_extensions

unsigned short

class scv_extensions

unsigned int

class scv_extensions

unsigned long

class scv_extensions

unsigned long long

class scv_extensions

float

class scv_extensions

double

class scv_extensions

string

class scv_extensions

pointer

class scv_extensions

array

class scv_extensions

sc_string

class scv_extensions

sc_bit

class scv_extensions

sc_logic

class scv_extensions

sc_int

template class scv_extensions< sc_int>

sc_uint

template class scv_extensions< sc_uint>

sc_bigint

template class scv_extensions< sc_bigint>

sc_biguint

template class scv_extensions< sc_biguint>

sc_bv

template class scv_extensions< sc_bv>

sc_lv

template class scv_extensions< sc_lv>

sc_fixed

template class scv_extensions

sc_ufixed

template class scv_extensions

These template specializations include appropriate operators so that they behave as if they are the underlying data objects. For example, most of them include the operators +=, -=, *=, /=, %=, ^=, etc., and the specializations for integer types include operators ++, --, =. The specializations for SystemC types include the corresponding methods in the underlying object, such as to_int64(). These operators are required to support value change callbacks, etc. Implicit conversion to the underlying data type is used whenever possible. Similar to read() and write() in a SystemC port (sc_port), these extension classes also have read() and write() to get around the implicit conversion problem. In most cases, the C++ compiler can perform the implicit conversion automatically. In the cases when the compiler cannot deduce the right conversion, read() and write() can be used. Another method called get_instance() returns a non-constant pointer to the underlying object; this method must be used in conjunction with another method trigger_value_change_cb() to make sure value change callbacks are executed correctly. Data introspection is useful only

Example : scv_extensions_if

  1 #include

  2

  3 int sc_main (int argc, char* argv[]) {

  4   // Int data type

  5   int data = 100;

  6   // Get the bitwidth of the data

  7   int bitwidth = scv_get_extensions(data).get_bitwidth();

  8   cout << "Width of data is "<< bitwidth << endl;

  9   cout << "Value in data is ";

 10   // Get the value in data and print to stdio

 11   scv_get_extensions(data).print();

 12   return 0;

 13 }

Simulation Output : scv_extensions_if
 Width of data is 32

 Value in data is 100

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

Bạn Chưa Biết Phương Thức Nào Nhanh Chóng Để Đạt Được Chúng

Hãy Để Chúng Tôi Hỗ Trợ Cho Bạn. SEMICON  

 

Last Updated ( Tuesday, 29 March 2022 00:44 )