quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Extensions for User-Specified Types

In order to support user-specified composite types, the user needs to provide a partial template specialization of scv_extensions for the specific composite type in the test bench.

   

space.gif

Similar to the existing SystemC SC_MODULE macro, the SCV_EXTENSIONS and SCV_ENUM_EXTENSIONS macros create appropriate classes for the user-specified composite type and userspecified enumeration type.

   

space.gif

The related macros in the SystemC Verification Standard to facilitate this process are summarized in the following table:

   

space.gif

The scv_extensions Macros

Description

SCV_EXTENSIONS (type_name)

This macro is similar to SC_MODULE(). It defines the extension class for the composite type identified by type_name.

SCV_EXTENSIONS_CTOR (type_name)

This macro is similar to SC_CTOR(). It defines the constructor for the extension class of the composite type identified by type_name.

SCV_EXTENSIONS_ BASE_CLASS (base_type_name)

This macro declares base_type_name as the base class of the class to be extended. It must be instantiated within the block after SCV_EXTENSIONS_CTOR.

SCV_FIELD (field_name)

This macro declares a field identified by field_name. SCV_ENUM_EXTENSIONS(type_name) This macro is similar to SC_MODULE(). It defines the extension class for an enumeration identified by type_name.

SCV_ENUM_CTOR (type_name)

This macro is similar to SC_CTOR(). It defines the constructor for the extension class of the enumeration identified by type_name.

SCV_ENUM (enum_element_name)

This macro declares an enumeration element identified by enum_element_name.

   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example : scv_user_defined
   

space.gif


  1 #include <scv.h>
  2 
  3 struct packet_t {
  4   sc_uint<8>  addr;
  5   sc_uint<12> data;
  6 };
  7 
  8 SCV_EXTENSIONS(packet_t) {
  9   public:
 10     scv_extensions< sc_uint<8> > addr;
 11     scv_extensions< sc_uint<12> > data;
 12     SCV_EXTENSIONS_CTOR(packet_t) {
 13       SCV_FIELD(addr);
 14       SCV_FIELD(data);
 15     }
 16 };
 17 
 18 int sc_main (int argc, char* argv[]) {
 19   packet_t  pkt; 
 20   pkt.addr = rand();
 21   pkt.data = rand();
 22   int bitwidth = scv_get_extensions(pkt.addr).get_bitwidth();
 23   cout << "Width of addr is "<< bitwidth << endl;
 24   bitwidth = scv_get_extensions(pkt.data).get_bitwidth();
 25   cout << "Width of data is "<< bitwidth << endl;
 26   scv_get_extensions(pkt).print();
 27   return 0;
 28 }
You could download file scv_user_defined.cpp here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation Output : scv_user_defined
   

space.gif

 Width of addr is 8
 Width of data is 12
 {
   addr:103
   data:966
 }
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com