00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include "scv/scv_util.h"
00041
00042 #ifndef _SCV_INTROSPECTION_ONLY
00043 #include "scv/scv_config.h"
00044 #endif
00045
00046 #ifndef _SCV_INTROSPECTION_NO_SYSTEMC
00047 #include <systemc.h>
00048 #endif
00049
00050 #include "scv/scv_introspection.h"
00051
00052 #ifndef _SCV_INTROSPECTION_ONLY
00053 #include "scv/scv_debug.h"
00054 #else
00055 class scv_debug {
00056 public:
00057 enum dummy {
00058 INITIAL_DEBUG_LEVEL,
00059 INTROSPECTION
00060 };
00061 static void set_facility_level(dummy, int i = 0) {}
00062 };
00063 #define _SCV_DEFERR(code, number, string, severity, printStack) \
00064 static _scv_message_desc *code##_base = 0; \
00065 static _scv_message_desc **code;
00066 #include "scv_messages.h"
00067 #undef _SCV_DEFERR
00068 #endif
00069
00070 void _scv_constraint_wrapup(scv_extensions_if* e);
00071
00072
00073
00074
00075 #ifdef _SCV_INTROSPECTION_ONLY
00076
00077 #include <stdarg.h>
00078 struct scv_error_data
00079 {
00080 const char* error_name;
00081 const int error_number;
00082 const char* error_string;
00083 };
00084 #endif
00085
00086 static int s_introspection_debug_level = scv_debug::INITIAL_DEBUG_LEVEL;
00087
00088 int scv_extensions_if::get_debug() { return s_introspection_debug_level; }
00089 void scv_extensions_if::set_debug(int i)
00090 {
00091 if ( s_introspection_debug_level == i ) return;
00092 s_introspection_debug_level = i;
00093 scv_debug::set_facility_level(scv_debug::INTROSPECTION, i);
00094 }
00095
00096
00097
00098
00099 _scv_dynamic_data::~_scv_dynamic_data() {
00100
00101
00102
00103
00104
00105
00106
00107 }
00108
00109 void _scv_dynamic_data::execute_callbacks(scv_extensions_if * obj, scv_extensions_if::callback_reason r) {
00110 list<_scv_dynamic_data::callback_base*>::iterator i;
00111 list<_scv_dynamic_data::callback_base*>::iterator e = _callbacks.end();
00112 for (i = _callbacks.begin(); i != e; ++i) {
00113 (*i)->execute(obj,r);
00114 }
00115 }
00116
00117
00118
00119
00120
00121 const char *_scv_extension_util::get_name() const { return _name.c_str(); }
00122 const char *_scv_extension_util::kind() const { static const string s = "scv_extensions_if"; return s.c_str(); }
00123 void _scv_extension_util::print(ostream& o, int details, int indent) const {
00124 string space = "";
00125 for (int i=0; i<indent; ++i) space += " ";
00126
00127 switch (get_type()) {
00128 case BOOLEAN:
00129 if (get_bool()) {
00130 if (details == 0)
00131 o << space << "true" << endl;
00132 else
00133 o << space << get_short_name() << ":" << "true" << endl;
00134 } else {
00135 if (details == 0)
00136 o << space << "false" << endl;
00137 else
00138 o << space << get_short_name() << ":" << "false" << endl;
00139 }
00140 break;
00141 case ENUMERATION:
00142 if (details == 0)
00143 o << space << get_enum_string((int)get_integer()) << endl;
00144 else
00145 o << space << get_short_name() << ":" << get_enum_string((int)get_integer()) << endl;
00146 break;
00147 case INTEGER:
00148 #ifdef SYSTEMC_H
00149 if (get_bitwidth()>64) {
00150 sc_bv_base v(get_bitwidth());
00151 get_value(v);
00152 if (details == 0)
00153 o << space << v << endl;
00154 else
00155 o << space << get_short_name() << ":" << v << endl;
00156 return;
00157 }
00158 #endif
00159 if (details == 0)
00160 o << space << get_integer() << endl;
00161 else
00162 o << space << get_short_name() << ":" << get_integer() << endl;
00163 break;
00164 case UNSIGNED:
00165 #ifdef SYSTEMC_H
00166 if (get_bitwidth()>64) {
00167 sc_bv_base v(get_bitwidth());
00168 get_value(v);
00169 if (details == 0)
00170 o << space << v << endl;
00171 else
00172 o << space << get_short_name() << ":" << v << endl;
00173 return;
00174 }
00175 #endif
00176 if (details == 0)
00177 o << space << get_unsigned() << endl;
00178 else
00179 o << space << get_short_name() << ":" << get_unsigned() << endl;
00180 break;
00181 case FLOATING_POINT_NUMBER:
00182 if (details == 0)
00183 o << space << get_double() << endl;
00184 else
00185 o << space << get_short_name() << ":" << get_double() << endl;
00186 break;
00187 case BIT_VECTOR:
00188 #ifdef SYSTEMC_H
00189 {
00190 sc_bv_base v(get_bitwidth());
00191 get_value(v);
00192 if (details == 0)
00193 o << space << v << endl;
00194 else
00195 o << space << get_short_name() << ":" << v << endl;
00196 }
00197 #endif
00198 break;
00199 case LOGIC_VECTOR:
00200 #ifdef SYSTEMC_H
00201 {
00202 sc_lv_base v(get_bitwidth());
00203 get_value(v);
00204 if (details == 0)
00205 o << space << v << endl;
00206 else
00207 o << space << get_short_name() << ":" << v << endl;
00208 }
00209 #endif
00210 break;
00211 case FIXED_POINT_INTEGER:
00212 _scv_message::message(_scv_message::NOT_IMPLEMENTED_YET,"data introspection for fixed pointer number");
00213 break;
00214 case UNSIGNED_FIXED_POINT_INTEGER:
00215 _scv_message::message(_scv_message::NOT_IMPLEMENTED_YET,"data introspection for fixed pointer number");
00216 break;
00217 case RECORD:
00218 {
00219 int size = get_num_fields();
00220 if (get_short_name() != "")
00221 o << space << get_short_name() << " {" << endl;
00222 else
00223 o << space << "{" << endl;
00224 if (size) {
00225 for (int i=0; i<size; ++i)
00226 get_field(i)->print(o,1,indent+2);
00227 }
00228 o << space << "}" << endl;
00229 break;
00230 }
00231 case POINTER:
00232 if (details == 0)
00233 o << space << "(pointer)" << endl;
00234 else
00235 o << space << get_short_name() << ": (pointer)" << endl;
00236 break;
00237 case ARRAY:
00238 {
00239 if (get_short_name() != "")
00240 o << space << get_short_name() << " {" << endl;
00241 else
00242 o << space << "{" << endl;
00243 int size = get_array_size();
00244 for (int i=0; i<size; ++i)
00245 get_array_elt(i)->print(o,1,indent+2);
00246 o << space << "}" << endl;
00247 break;
00248 }
00249 case STRING:
00250 if (details == 0)
00251 o << space << get_string() << endl;
00252 else
00253 o << space << get_short_name() << ":" << get_string() << endl;
00254 break;
00255 default:
00256 _scv_message::message(_scv_message::INTERNAL_ERROR,"Unrecognized data introspection type.");
00257 break;
00258 }
00259 }
00260 void _scv_extension_util::show(int details, int indent) const {
00261 print(scv_out,details,indent);
00262 }
00263
00264 bool _scv_extension_util::has_valid_extensions() const { return true; }
00265 bool _scv_extension_util::is_dynamic() const { return _is_dynamic(); }
00266
00267 sc_string _scv_extension_util::get_short_name() const { return sc_string(_short_name.c_str()); }
00268 void _scv_extension_util::set_name(const char * s) { _name = s; }
00269 void _scv_extension_util::_set_name(const string& s) { _name = s; }
00270
00271 _scv_dynamic_data * _scv_extension_util::_get_dynamic_data() {
00272 if (!_is_dynamic())return 0;
00273 if (_data == (_scv_dynamic_data*) 1) _data = new _scv_dynamic_data();
00274 return _data;
00275 }
00276 _scv_dynamic_data * _scv_extension_util::get_dynamic_data() {
00277 return _get_dynamic_data();
00278 }
00279 const _scv_dynamic_data * _scv_extension_util::_get_dynamic_data() const {
00280 if (!_is_dynamic()) return 0;
00281 if (_data == (_scv_dynamic_data*) 1) _data = new _scv_dynamic_data();
00282 return _data;
00283 }
00284 void _scv_extension_util::_set_parent(_scv_extension_util * p, const string& name) {
00285 if ( ! _parent ) {
00286 _parent = p;
00287 _short_name = name;
00288 _set_name(name);
00289 }
00290 }
00291 void _scv_extension_util::_set_dynamic() {
00292 if (_data == 0) _data = (_scv_dynamic_data*) 1;
00293 }
00294
00295
00296
00297
00298
00299 void _scv_extension_util_enum::_get_enum_details(list<const char *>& names, list<int>& values) const {
00300 names = _get_names();
00301 values = _get_values();
00302 }
00303 const char * _scv_extension_util_enum::_get_enum_string(int e) const {
00304 list<const char *>& names = _get_names();
00305 list<int>& values = _get_values();
00306 list<const char *>::iterator i;
00307 list<int>::iterator j;
00308 for (i = names.begin(), j = values.begin();
00309 i != names.end();
00310 ++i, ++j) {
00311 if (*j == e) return *i;
00312 }
00313 _scv_message::message(_scv_message::INTROSPECTION_INVALID_ENUM_VALUE,get_type_name(),e);
00314 return "_error";
00315 }
00316
00317
00318
00319
00320
00321 scv_extensions_if::data_type _scv_extension_type_enum::get_type() const {
00322 return scv_extensions_if::ENUMERATION;
00323 }
00324
00325 int _scv_extension_type_enum::get_enum_size() const {
00326 return _get_enum_size();
00327 }
00328 void _scv_extension_type_enum::get_enum_details(list<const char *>& names, list<int>& values) const {
00329 _get_enum_details(names,values);
00330 }
00331 const char * _scv_extension_type_enum::get_enum_string(int e) const {
00332 return _get_enum_string(e);
00333 }
00334
00335 int _scv_extension_type_enum::get_num_fields() const { return 0; }
00336 scv_extensions_if * _scv_extension_type_enum::get_field(unsigned) { return 0; }
00337 const scv_extensions_if * _scv_extension_type_enum::get_field(unsigned) const { return 0; }
00338
00339 scv_extensions_if * _scv_extension_type_enum::get_pointer() { return 0; }
00340 const scv_extensions_if * _scv_extension_type_enum::get_pointer() const { return 0; }
00341
00342 int _scv_extension_type_enum::get_array_size() const { return 0; }
00343 scv_extensions_if * _scv_extension_type_enum::get_array_elt(int) { return 0; }
00344 const scv_extensions_if * _scv_extension_type_enum::get_array_elt(int) const { return 0; }
00345
00346
00347
00348
00349
00350 #ifdef SYSTEMC_H
00351 #define _SCV_DEFAULT_RW_SYSC(class_name,obj) \
00352 void class_name::assign(const sc_bv_base& v) { _SCV_RW_ERROR(assign,sc_bv_base,obj); } \
00353 void class_name::get_value(sc_bv_base& v) const { _SCV_RW_ERROR(get_value,sc_bv_base,obj); } \
00354 void class_name::assign(const sc_lv_base& v) { _SCV_RW_ERROR(assign,sc_lv_base,obj); } \
00355 void class_name::get_value(sc_lv_base& v) const { _SCV_RW_ERROR(get_value,sc_lv_base,obj); }
00356 #else
00357 #define _SCV_DEFAULT_RW_SYSC(class_name,obj)
00358 #endif
00359
00360 void _scv_extension_rw_enum::assign(bool v) { *_get_instance() = v; trigger_value_change_cb(); }
00361 void _scv_extension_rw_enum::assign(char v) { *_get_instance() = v; trigger_value_change_cb(); }
00362 void _scv_extension_rw_enum::assign(unsigned char v) { *_get_instance() = v; trigger_value_change_cb(); }
00363 void _scv_extension_rw_enum::assign(short v) { *_get_instance() = v; trigger_value_change_cb(); }
00364 void _scv_extension_rw_enum::assign(unsigned short v) { *_get_instance() = v; trigger_value_change_cb(); }
00365 void _scv_extension_rw_enum::assign(int v) { *_get_instance() = v; trigger_value_change_cb(); }
00366 void _scv_extension_rw_enum::assign(unsigned v) { *_get_instance() = v; trigger_value_change_cb(); }
00367 void _scv_extension_rw_enum::assign(long v) { *_get_instance() = v; trigger_value_change_cb(); }
00368 void _scv_extension_rw_enum::assign(unsigned long v) { *_get_instance() = v; trigger_value_change_cb(); }
00369 void _scv_extension_rw_enum::assign(long long v) { *_get_instance() = (int) v; trigger_value_change_cb(); }
00370 void _scv_extension_rw_enum::assign(unsigned long long v) { *_get_instance() = (int) v; trigger_value_change_cb(); }
00371 void _scv_extension_rw_enum::assign(float) { _SCV_RW_ERROR(assign,float,enum); }
00372 void _scv_extension_rw_enum::assign(double) { _SCV_RW_ERROR(assign,double,enum); }
00373 void _scv_extension_rw_enum::assign(const string& s) { assert(s.c_str()); }
00374 void _scv_extension_rw_enum::assign(const sc_string& s) { assert(s.c_str()); }
00375 void _scv_extension_rw_enum::assign(const char * s) {
00376 list<int>& values = _get_values();
00377 list<const char *>& names = _get_names();
00378 list<int>::iterator i = values.begin();
00379 list<const char *>::iterator j = names.begin();
00380 while (j != names.end() && 0!=strcmp(*j,s)) {
00381 ++i; ++j;
00382 }
00383 if (j != names.end()) assign(*j);
00384 else _scv_message::message(_scv_message::INTROSPECTION_INVALID_ENUM_STRING,s);
00385 trigger_value_change_cb();
00386 }
00387 bool _scv_extension_rw_enum::get_bool() const { _SCV_RW_ERROR(get_bool,bool,obj); return false; }
00388 long long _scv_extension_rw_enum::get_integer() const { return *_get_instance(); }
00389 unsigned long long _scv_extension_rw_enum::get_unsigned() const { _SCV_RW_ERROR(get_unsigned,unsigned,obj); return 0; }
00390 double _scv_extension_rw_enum::get_double() const { _SCV_RW_ERROR(get_double,double,obj); return 0; }
00391 sc_string _scv_extension_rw_enum::get_string() const { return get_enum_string((int)get_integer()); }
00392
00393 _SCV_DEFAULT_RW_SYSC(_scv_extension_rw_enum,enum)
00394
00395
00396
00397
00398
00399
00400 void _scv_extension_rand_enum::next() { uninitialize(); initialize(); }
00401 void _scv_extension_rand_enum::disable_randomization() {
00402 assert(_is_dynamic());
00403 _get_dynamic_data()->disable_randomization_ = true;
00404 _get_dynamic_data()->undefined_ = false;
00405 }
00406 void _scv_extension_rand_enum::enable_randomization() {
00407 assert(_is_dynamic());
00408 _get_dynamic_data()->disable_randomization_ = false;
00409 uninitialize();
00410 }
00411 bool _scv_extension_rand_enum::is_randomization_enabled() {
00412 if (!_is_dynamic()) return false;
00413 if (_has_dynamic_data()) return !_get_dynamic_data()->disable_randomization_;
00414 return true;
00415 }
00416 void _scv_extension_rand_enum::set_random(scv_shared_ptr<scv_random> r) {
00417 _SCV_CHECK_DYNAMIC(set_random,return);
00418 get_constraint_data()->set_random(r);
00419 }
00420 scv_shared_ptr<scv_random> _scv_extension_rand_enum::get_random(void){
00421 #ifndef _SCV_INTROSPECTION_ONLY
00422 _SCV_CHECK_DYNAMIC(get_random,return scv_shared_ptr<scv_random>());
00423 return get_constraint_data()->get_random(this);
00424 #else
00425 return scv_shared_ptr<scv_random>();
00426 #endif
00427 }
00428 scv_expression _scv_extension_rand_enum::form_expression() const {
00429 _scv_message::message(_scv_message::INTROSPECTION_INVALID_EXPRESSION,"enum",get_name());
00430 return scv_expression();
00431 }
00432 void _scv_extension_rand_enum::use_constraint(scv_smart_ptr_if& s) {
00433 use_constraint(s.get_extensions_ptr());
00434 }
00435 void _scv_extension_rand_enum::use_constraint(scv_extensions_if* e) {
00436 _scv_use_constraint(this, e);
00437 }
00438 #ifndef _SCV_INTROSPECTION_ONLY
00439 void _scv_extension_rand_enum::reset_distribution() {
00440 _reset_bag_distribution();
00441 _reset_keep_only_distribution();
00442 }
00443 #endif
00444 void _scv_extension_rand_enum::uninitialize() {
00445 if (_get_dynamic_data()->disable_randomization_ == true) return ;
00446 _get_dynamic_data()->undefined_ = true;
00447 #ifndef _SCV_INTROSPECTION_ONLY
00448 if (get_constraint_data()->get_mode() == _scv_constraint_data::EXTENSION) {
00449 get_constraint_data()->get_extension()->uninitialize();
00450 }
00451 #endif
00452 }
00453 void _scv_extension_rand_enum::initialize() const {
00454 if (_is_dynamic() && _get_dynamic_data()->undefined_) {
00455 const_cast<_scv_extension_rand_enum*>(this)->generate_value_();
00456 const_cast<_scv_extension_rand_enum*>(this)->_get_dynamic_data()->undefined_ = false;
00457 }
00458 }
00459 bool _scv_extension_rand_enum::is_initialized() const {
00460 return !(_get_dynamic_data()->undefined_);
00461 }
00462 void _scv_extension_rand_enum::updated() {
00463 _get_dynamic_data()->undefined_ = false;
00464 }
00465 void _scv_extension_rand_enum::set_constraint(scv_constraint_base* c) {
00466 #ifndef _SCV_INTROSPECTION_ONLY
00467 get_constraint_data()->set_constraint(c);
00468 #endif
00469 }
00470
00471 #ifndef _SCV_INTROSPECTION_ONLY
00472 extern void _scv_set_constraint(scv_extensions_if* s, bool mode);
00473 #else
00474 void _scv_set_constraint(scv_extensions_if* s, bool mode) {}
00475 #endif
00476
00477 void _scv_extension_rand_enum::set_constraint(bool mode) {
00478 _scv_set_constraint(this, mode);
00479 }
00480
00481 void _scv_extension_rand_enum::set_extension(scv_extensions_if* e) {
00482 #ifndef _SCV_INTROSPECTION_ONLY
00483 get_constraint_data()->set_extension(e);
00484 get_constraint_data()->set_mode(_scv_constraint_data::EXTENSION);
00485 #endif
00486 }
00487
00488 _scv_constraint_data * _scv_extension_rand_enum::get_constraint_data() {
00489 if (!_get_dynamic_data()->cdata_) {
00490 _get_dynamic_data()->cdata_ = new _scv_constraint_data;
00491 }
00492 return _get_dynamic_data()->cdata_;
00493 }
00494
00495 void _scv_extension_rand_enum::get_generator(void) {
00496 #ifndef _SCV_INTROSPECTION_ONLY
00497 if (get_constraint_data()->get_gen_type() == _scv_constraint_data::EMPTY) {
00498 _scv_constraint_range_generator_unsigned * gen =
00499 get_constraint_data()->get_unsigned_generator(this);
00500 if (gen) scv_out << "";
00501 get_constraint_data()->set_mode(_scv_constraint_data::NO_CONSTRAINT);
00502 }
00503 return;
00504 #endif
00505 }
00506
00507 void _scv_extension_rand_enum::_reset_keep_only_distribution() {
00508 #ifndef _SCV_INTROSPECTION_ONLY
00509 get_constraint_data()->reset_distribution(this);
00510 #endif
00511 }
00512
00513 #ifndef _SCV_INTROSPECTION_ONLY
00514 void _scv_extension_rand_enum::set_value_mode(_scv_constraint_data::gen_mode m) {
00515 get_constraint_data()->set_mode(m);
00516 }
00517 template <typename T>
00518 bool check_mode(scv_extensions_if::mode_t t,
00519 scv_extensions_if* e, const string& name,
00520 _scv_distribution<T> * dist);
00521 #endif
00522
00523
00524
00525
00526
00527
00528 scv_extensions_if::callback_h _scv_extension_callbacks_enum::_register_cb(callback_base * c) {
00529 return s_add_callback(_get_dynamic_data(),c);
00530 }
00531 void _scv_extension_callbacks_enum::remove_cb(callback_h id) {
00532 return s_remove_callback(_get_dynamic_data(),id);
00533 }
00534
00535
00536 #define _SCV_EXT_TYPE_FC_COMMON_I(type_id) \
00537 int _scv_extension_type_ ## type_id::get_enum_size() const { return 0; } \
00538 void _scv_extension_type_ ## type_id::get_enum_details(list<const char *>&, list<int>&) const {} \
00539 const char *_scv_extension_type_ ## type_id::get_enum_string(int) const { return "_error"; } \
00540 \
00541 int _scv_extension_type_ ## type_id::get_num_fields() const { return 0; } \
00542 scv_extensions_if *_scv_extension_type_ ## type_id::get_field(unsigned) { return 0; } \
00543 const scv_extensions_if *_scv_extension_type_ ## type_id::get_field(unsigned) const { return 0; } \
00544 \
00545 scv_extensions_if *_scv_extension_type_ ## type_id::get_pointer() { return 0; } \
00546 const scv_extensions_if *_scv_extension_type_ ## type_id::get_pointer() const { return 0; } \
00547 \
00548 int _scv_extension_type_ ## type_id::get_array_size() const { return 0; } \
00549 scv_extensions_if *_scv_extension_type_ ## type_id::get_array_elt(int) { return 0; } \
00550 const scv_extensions_if *_scv_extension_type_ ## type_id::get_array_elt(int) const { return 0; } \
00551 \
00552 scv_extensions_if *_scv_extension_type_ ## type_id::get_parent() { return this->_parent; } \
00553 const scv_extensions_if *_scv_extension_type_ ## type_id::get_parent() const { return this->_parent; } \
00554
00555
00556 #define _SCV_EXT_TYPE_FC_COMMON_EXT_I(basic_type,type_id,id) \
00557 _SCV_EXT_TYPE_FC_COMMON_I(type_id) \
00558 const char *_scv_extension_type_ ## type_id::get_type_name() const { \
00559 static const char *s = strdup(#basic_type); \
00560 return s; \
00561 } \
00562 scv_extension_type_if::data_type _scv_extension_type_ ## type_id::get_type() const \
00563 { return scv_extensions_if::id; } \
00564
00565
00566
00567 #define _SCV_EXT_TYPE_FC_I(basic_type,type_id,id) \
00568 _SCV_EXT_TYPE_FC_COMMON_EXT_I(basic_type,type_id,id) \
00569 int _scv_extension_type_ ## type_id::get_bitwidth() const \
00570 { return 8*sizeof(basic_type); } \
00571
00572
00573
00574 #define _SCV_EXT_TYPE_1_FC_I(basic_type,type_id,id) \
00575 _SCV_EXT_TYPE_FC_COMMON_EXT_I(basic_type,type_id,id) \
00576 int _scv_extension_type_ ## type_id::get_bitwidth() const \
00577 { return 1; } \
00578
00579
00580
00581 #define _SCV_EXT_TYPE_D_FC_I(basic_type,type_id,id) \
00582 _SCV_EXT_TYPE_FC_COMMON_EXT_I(basic_type,type_id,id) \
00583 _scv_extension_type_ ## type_id::_scv_extension_type_ ## type_id() : _bitwidth(0) {} \
00584 _scv_extension_type_ ## type_id::~_scv_extension_type_ ## type_id() {} \
00585 int _scv_extension_type_ ## type_id::get_bitwidth() const \
00586 { return this->_bitwidth; }
00587
00588
00589
00590
00591 _SCV_EXT_TYPE_1_FC_I(bool,bool,BOOLEAN);
00592
00593
00594
00595
00596 _SCV_EXT_TYPE_FC_I(char,char,INTEGER);
00597 _SCV_EXT_TYPE_FC_I(short,short,INTEGER);
00598 _SCV_EXT_TYPE_FC_I(int,int,INTEGER);
00599 _SCV_EXT_TYPE_FC_I(long,long,INTEGER);
00600 _SCV_EXT_TYPE_FC_I(long long,long_long,INTEGER);
00601 _SCV_EXT_TYPE_FC_I(unsigned char,unsigned_char,UNSIGNED);
00602 _SCV_EXT_TYPE_FC_I(unsigned short,unsigned_short,UNSIGNED);
00603 _SCV_EXT_TYPE_FC_I(unsigned int,unsigned_int,UNSIGNED);
00604 _SCV_EXT_TYPE_FC_I(unsigned long,unsigned_long,UNSIGNED);
00605 _SCV_EXT_TYPE_FC_I(unsigned long long,unsigned_long_long,UNSIGNED);
00606 _SCV_EXT_TYPE_FC_I(float,float,FLOATING_POINT_NUMBER);
00607 _SCV_EXT_TYPE_FC_I(double,double,FLOATING_POINT_NUMBER);
00608 _SCV_EXT_TYPE_FC_I(string,string,STRING);
00609
00610 #ifdef SYSTEMC_H
00611 _SCV_EXT_TYPE_FC_I(sc_string,sc_string,STRING);
00612 _SCV_EXT_TYPE_1_FC_I(sc_bit,sc_bit,BIT_VECTOR);
00613 _SCV_EXT_TYPE_1_FC_I(sc_logic,sc_logic,LOGIC_VECTOR);
00614 _SCV_EXT_TYPE_D_FC_I(sc_signed,sc_signed,INTEGER);
00615 _SCV_EXT_TYPE_D_FC_I(sc_unsigned,sc_unsigned,UNSIGNED);
00616 _SCV_EXT_TYPE_D_FC_I(sc_int_base,sc_int_base,INTEGER);
00617 _SCV_EXT_TYPE_D_FC_I(sc_uint_base,sc_uint_base,UNSIGNED);
00618 _SCV_EXT_TYPE_D_FC_I(sc_lv_base,sc_lv_base,LOGIC_VECTOR);
00619 _SCV_EXT_TYPE_D_FC_I(sc_bv_base,sc_bv_base,BIT_VECTOR);
00620 #endif
00621
00622 #undef _SCV_EXT_TYPE_FC_I
00623 #undef _SCV_EXT_TYPE_1_FC_I
00624 #undef _SCV_EXT_TYPE_D_FC_I
00625
00627
00628
00629
00630
00631
00632
00633 #define _SCV_EXT_RW_FC_BASE_I(T,type_id) \
00634 _scv_extension_rw_ ## type_id::_scv_extension_rw_ ## type_id() {} \
00635 _scv_extension_rw_ ## type_id::~_scv_extension_rw_ ## type_id() {} \
00636 \
00637 inline const T* _scv_extension_rw_ ## type_id::get_instance() const { return _instance; } \
00638 inline T* _scv_extension_rw_ ## type_id::get_instance() { return _instance; } \
00639 T* _scv_extension_rw_ ## type_id::_get_instance() const { return _instance; } \
00640 \
00641 void _scv_extension_rw_ ## type_id::_set_instance(T* p) { _instance = p; _set_instance_core_wrap(p); } \
00642 void _scv_extension_rw_ ## type_id::_set_instance_core_wrap(void*) {} \
00643 void _scv_extension_rw_ ## type_id::_set_as_field(_scv_extension_util_record * parent, T* p, \
00644 const string& name) { \
00645 if (p) _set_instance(p); \
00646 else if ( ! this->_get_parent() ) { this->_set_parent(parent,name); parent->_add_field(this); } \
00647 } \
00648 \
00649 const T& _scv_extension_rw_ ## type_id::read() { return *get_instance(); } \
00650 void _scv_extension_rw_ ## type_id::write(const T& rhs) { *_get_instance() = rhs; this->trigger_value_change_cb(); } \
00651
00652
00653
00654
00655
00656
00657 #define _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,arg_name) \
00658 void _scv_extension_rw_ ## type_id::assign(arg_name i) \
00659 { *(this->_get_instance()) = i; this->trigger_value_change_cb(); } \
00660
00661
00662 #define _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,arg_name) \
00663 void _scv_extension_rw_ ## type_id::assign(arg_name i) \
00664 { _SCV_RW_ERROR(assign,arg_name,type_name); } \
00665
00666 #define _SCV_EXT_RW_FC_GET_VALUE_I(type_name,type_id,arg_name) \
00667 void _scv_extension_rw_ ## type_id::get_value(arg_name& i) \
00668 { i = *(this->_get_instance()); } \
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679 #define _SCV_EXT_RW_FC_I(basic_type,type_id,bitwidth) \
00680 _SCV_EXT_RW_FC_BASE_I(basic_type,type_id) \
00681 _SCV_EXT_RW_FC_ASSIGNS_I(basic_type,type_id,bitwidth); \
00682
00683
00684 #ifdef SYSTEMC_H
00685 #define _SCV_EXT_RW_FC_BAD_ASSIGNS_SYSC_I(type_name,type_id) \
00686 void _scv_extension_rw_ ## type_id::assign(const sc_bv_base& v) { \
00687 _SCV_RW_ERROR(assign,sc_bv_base,type_name); \
00688 } \
00689 void _scv_extension_rw_ ## type_id::get_value(sc_bv_base& v) const { \
00690 _SCV_RW_ERROR(get_value,sc_bv_base,type_name); \
00691 } \
00692 void _scv_extension_rw_ ## type_id::assign(const sc_lv_base& v) { \
00693 _SCV_RW_ERROR(assign,sc_lv_base,type_name); \
00694 } \
00695 void _scv_extension_rw_ ## type_id::get_value(sc_lv_base& v) const { \
00696 _SCV_RW_ERROR(get_value,sc_lv_base,type_name); \
00697 } \
00698
00699 #define _SCV_EXT_RW_FC_ASSIGNS_SYSC_I(type_id,bitwidth) \
00700 void _scv_extension_rw_ ## type_id::assign(const sc_bv_base& v) { \
00701 if (this->get_bitwidth() != v.length()) \
00702 _scv_message::message(_scv_message::INTROSPECTION_SIZE_MISMATCH_FOR_WIDE_DATA, \
00703 "sc_bv_base","assign"); \
00704 static sc_int<bitwidth> tmp; \
00705 tmp = v; *(this->_get_instance()) = tmp; \
00706 this->trigger_value_change_cb(); \
00707 } \
00708 void _scv_extension_rw_ ## type_id::get_value(sc_bv_base& v) const { \
00709 if (this->get_bitwidth() != v.length()) \
00710 _scv_message::message(_scv_message::INTROSPECTION_SIZE_MISMATCH_FOR_WIDE_DATA, \
00711 "sc_bv_base","get_value"); \
00712 this->initialize(); v = *(this->_get_instance()); \
00713 } \
00714 void _scv_extension_rw_ ## type_id::assign(const sc_lv_base& v) { \
00715 if (this->get_bitwidth() != v.length()) \
00716 _scv_message::message(_scv_message::INTROSPECTION_SIZE_MISMATCH_FOR_WIDE_DATA, \
00717 "sc_lv_base","assign"); \
00718 static sc_int<bitwidth> tmp; \
00719 tmp = v; *(this->_get_instance()) = tmp; \
00720 this->trigger_value_change_cb(); \
00721 } \
00722 void _scv_extension_rw_ ## type_id::get_value(sc_lv_base& v) const { \
00723 if (this->get_bitwidth() != v.length()) \
00724 _scv_message::message(_scv_message::INTROSPECTION_SIZE_MISMATCH_FOR_WIDE_DATA, \
00725 "sc_lv_base","get_value"); \
00726 this->initialize(); v = *(this->_get_instance()); \
00727 } \
00728
00729 #else
00730 #define _SCV_EXT_RW_FC_ASSIGNS_SYSC_I(type_id,bitwidth)
00731 #define _SCV_EXT_RW_FC_BAD_ASSIGNS_SYSC_I(type_name,type_id)
00732 #endif
00733
00734
00735
00736
00737
00738 #define _SCV_EXT_RW_FC_ASSIGNS_I(type_name,type_id,bitwidth) \
00739 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,bool); \
00740 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,char); \
00741 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned char); \
00742 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,short); \
00743 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned short); \
00744 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,int); \
00745 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned int); \
00746 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,long); \
00747 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned long); \
00748 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,long long); \
00749 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned long long); \
00750 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,float); \
00751 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,double); \
00752 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const string&); \
00753 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const sc_string&); \
00754 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const char *); \
00755 bool _scv_extension_rw_ ## type_id::get_bool() const { \
00756 return *(this->_get_instance()) != 0; \
00757 } \
00758 long long _scv_extension_rw_ ## type_id::get_integer() const { \
00759 return *(this->_get_instance()); \
00760 } \
00761 unsigned long long _scv_extension_rw_ ## type_id::get_unsigned() const { \
00762 return *(this->_get_instance()); \
00763 } \
00764 double _scv_extension_rw_ ## type_id::get_double() const { \
00765 return *(this->_get_instance()); \
00766 } \
00767 sc_string _scv_extension_rw_ ## type_id::get_string() const { \
00768 assert(0); return sc_string(""); \
00769 } \
00770 _SCV_EXT_RW_FC_ASSIGNS_SYSC_I(type_id,bitwidth) \
00771
00772
00773 _SCV_EXT_RW_FC_I(bool,bool,1);
00774 _SCV_EXT_RW_FC_I(char,char,8);
00775 _SCV_EXT_RW_FC_I(unsigned char,unsigned_char,8);
00776 _SCV_EXT_RW_FC_I(short,short,16);
00777 _SCV_EXT_RW_FC_I(unsigned short,unsigned_short,16);
00778 _SCV_EXT_RW_FC_I(int,int,32);
00779 _SCV_EXT_RW_FC_I(unsigned int,unsigned_int,32);
00780 _SCV_EXT_RW_FC_I(long,long,32);
00781 _SCV_EXT_RW_FC_I(unsigned long,unsigned_long,32);
00782 _SCV_EXT_RW_FC_I(long long,long_long,64);
00783 _SCV_EXT_RW_FC_I(unsigned long long,unsigned_long_long,64);
00784
00785 #undef _SCV_EXT_RW_FC_ASSIGNS_I
00786
00787
00788
00789
00790
00791 #define _SCV_EXT_RW_FC_ASSIGNS_I(type_name,type_id,dummy) \
00792 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,bool); \
00793 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,char); \
00794 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned char); \
00795 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,short); \
00796 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned short); \
00797 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,int); \
00798 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned int); \
00799 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,long); \
00800 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned long); \
00801 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,long long); \
00802 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned long long); \
00803 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,float); \
00804 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,double); \
00805 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const string&); \
00806 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const sc_string&); \
00807 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const char *); \
00808 bool _scv_extension_rw_ ## type_id::get_bool() const { \
00809 _SCV_RW_ERROR(get_bool,bool,type_name); \
00810 return false; \
00811 } \
00812 long long _scv_extension_rw_ ## type_id::get_integer() const { \
00813 _SCV_RW_ERROR(get_integer,integer,type_name); \
00814 return 0; \
00815 } \
00816 unsigned long long _scv_extension_rw_ ## type_id::get_unsigned() const { \
00817 _SCV_RW_ERROR(get_unsigned,unsigned,type_name); \
00818 return 0; \
00819 } \
00820 double _scv_extension_rw_ ## type_id::get_double() const { \
00821 return *(this->_get_instance()); \
00822 } \
00823 sc_string _scv_extension_rw_ ## type_id::get_string() const { \
00824 assert(0); return sc_string(""); \
00825 } \
00826 _SCV_EXT_RW_FC_BAD_ASSIGNS_SYSC_I(type_name,type_id) \
00827
00828 _SCV_EXT_RW_FC_I(float,float,dummy);
00829 _SCV_EXT_RW_FC_I(double,double,dummy);
00830
00831 #undef _SCV_EXT_RW_FC_ASSIGNS_I
00832
00833
00834
00835
00836 #define _SCV_EXT_RW_FC_ASSIGNS_I(type_name,type_id,dummy) \
00837 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,bool); \
00838 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,char); \
00839 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,unsigned char); \
00840 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,short); \
00841 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,unsigned short); \
00842 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,int); \
00843 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,unsigned int); \
00844 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,long); \
00845 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,unsigned long); \
00846 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,long long); \
00847 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,unsigned long long); \
00848 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,float); \
00849 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,double); \
00850 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,const string&); \
00851 void _scv_extension_rw_ ## type_id::assign(const sc_string& i) { \
00852 *(this->_get_instance()) = i.c_str(); \
00853 this->trigger_value_change_cb(); \
00854 } \
00855 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,const char *); \
00856 bool _scv_extension_rw_ ## type_id::get_bool() const { \
00857 return *(this->_get_instance()) != ""; \
00858 } \
00859 long long _scv_extension_rw_ ## type_id::get_integer() const { \
00860 _SCV_RW_ERROR(get_integer,integer,type_name); return 0; \
00861 } \
00862 unsigned long long _scv_extension_rw_ ## type_id::get_unsigned() const { \
00863 _SCV_RW_ERROR(get_unsigned,unsigned,type_name); return 0; \
00864 } \
00865 double _scv_extension_rw_ ## type_id::get_double() const { \
00866 _SCV_RW_ERROR(get_double,double,type_name); return 0; \
00867 } \
00868 sc_string _scv_extension_rw_ ## type_id::get_string() const { \
00869 return sc_string(this->_get_instance()->c_str()); \
00870 } \
00871 _SCV_EXT_RW_FC_BAD_ASSIGNS_SYSC_I(type_name,type_id) \
00872
00873 _SCV_EXT_RW_FC_I(string,string,dummy);
00874
00875 #undef _SCV_EXT_RW_FC_ASSIGNS_I
00876
00877
00878
00879
00880
00881 #undef _SCV_EXT_RW_FC_I
00882
00883 #ifdef SYSTEMC_H
00884 #undef _SCV_EXT_RW_FC_ASSIGNS_SYSC_I
00885 #undef _SCV_EXT_RW_FC_BAD_ASSIGNS_SYSC_I
00886 #endif
00887
00888
00889
00890
00891
00892 #ifdef SYSTEMC_H
00893
00894
00895
00896
00897
00898 _SCV_EXT_RW_FC_BASE_I(sc_string,sc_string);
00899 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,bool);
00900 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,char);
00901 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,unsigned char);
00902 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,short);
00903 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,unsigned short);
00904 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,int);
00905 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,unsigned int);
00906 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,long);
00907 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,unsigned long);
00908 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,long long);
00909 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,unsigned long long);
00910 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,float);
00911 _SCV_EXT_RW_FC_BAD_ASSIGN_I(sc_string,sc_string,double);
00912 void _scv_extension_rw_sc_string::assign(const string& s) {
00913 *(this->_get_instance()) = s.c_str();
00914 this->trigger_value_change_cb();
00915 }
00916 void _scv_extension_rw_sc_string::assign(const sc_string& s) {
00917 *(this->_get_instance()) = s;
00918 this->trigger_value_change_cb();
00919 }
00920 void _scv_extension_rw_sc_string::assign(const char * s) {
00921 *(this->_get_instance()) = s;
00922 this->trigger_value_change_cb();
00923 }
00924 bool _scv_extension_rw_sc_string::get_bool() const {
00925 return *(this->_get_instance()) != "";
00926 }
00927 long long _scv_extension_rw_sc_string::get_integer() const {
00928 _SCV_RW_ERROR(get_integer,integer,sc_string); return 0;
00929 }
00930 unsigned long long _scv_extension_rw_sc_string::get_unsigned() const {
00931 _SCV_RW_ERROR(get_unsigned,unsigned,sc_string); return 0;
00932 }
00933 double _scv_extension_rw_sc_string::get_double() const {
00934 _SCV_RW_ERROR(get_double,double,sc_string); return 0;
00935 }
00936 sc_string _scv_extension_rw_sc_string::get_string() const {
00937 return *this->_get_instance();
00938 }
00939 void _scv_extension_rw_sc_string::assign(const sc_bv_base& v) {
00940 _SCV_RW_ERROR(assign,sc_bv_base,sc_string);
00941 }
00942 void _scv_extension_rw_sc_string::get_value(sc_bv_base& v) const {
00943 _SCV_RW_ERROR(get_value,sc_bv_base,sc_string);
00944 }
00945 void _scv_extension_rw_sc_string::assign(const sc_lv_base& v) {
00946 _SCV_RW_ERROR(assign,sc_lv_base,sc_string);
00947 }
00948 void _scv_extension_rw_sc_string::get_value(sc_lv_base& v) const {
00949 _SCV_RW_ERROR(get_value,sc_lv_base,sc_string);
00950 }
00951
00952
00953
00954
00955
00956
00957 #define _SCV_EXT_RW_FC_BOOL_ASSIGN_I(type_name,type_id,arg_name) \
00958 void _scv_extension_rw_ ## type_id::assign(arg_name i) { \
00959 if (i) \
00960 *this->_get_instance() = 1; \
00961 else \
00962 *this->_get_instance() = 0; \
00963 this->trigger_value_change_cb(); \
00964 }
00965
00966 #undef _SCV_EXT_RW_FC_ASSIGNS_I
00967 #define _SCV_EXT_RW_FC_ASSIGNS_I(type_name,type_id) \
00968 _SCV_EXT_RW_FC_BOOL_ASSIGN_I(type_name,type_id,bool); \
00969 _SCV_EXT_RW_FC_BOOL_ASSIGN_I(type_name,type_id,char); \
00970 _SCV_EXT_RW_FC_BOOL_ASSIGN_I(type_name,type_id,unsigned char); \
00971 _SCV_EXT_RW_FC_BOOL_ASSIGN_I(type_name,type_id,short); \
00972 _SCV_EXT_RW_FC_BOOL_ASSIGN_I(type_name,type_id,unsigned short); \
00973 _SCV_EXT_RW_FC_BOOL_ASSIGN_I(type_name,type_id,int); \
00974 _SCV_EXT_RW_FC_BOOL_ASSIGN_I(type_name,type_id,unsigned int); \
00975 _SCV_EXT_RW_FC_BOOL_ASSIGN_I(type_name,type_id,long); \
00976 _SCV_EXT_RW_FC_BOOL_ASSIGN_I(type_name,type_id,unsigned long); \
00977 _SCV_EXT_RW_FC_BOOL_ASSIGN_I(type_name,type_id,long long); \
00978 _SCV_EXT_RW_FC_BOOL_ASSIGN_I(type_name,type_id,unsigned long long); \
00979 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,float); \
00980 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,double); \
00981 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const string&); \
00982 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const sc_string&); \
00983 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const char *); \
00984 bool _scv_extension_rw_ ## type_id::get_bool() const { \
00985 return this->_get_instance()->to_bool(); \
00986 } \
00987 long long _scv_extension_rw_ ## type_id::get_integer() const { \
00988 return this->get_bool(); \
00989 } \
00990 unsigned long long _scv_extension_rw_ ## type_id::get_unsigned() const { \
00991 return this->get_bool(); \
00992 } \
00993 double _scv_extension_rw_ ## type_id::get_double() const { \
00994 return this->get_bool(); \
00995 } \
00996
00997
00998
00999
01000
01001 _SCV_EXT_RW_FC_BASE_I(sc_bit,sc_bit);
01002 _SCV_EXT_RW_FC_ASSIGNS_I(sc_bit,sc_bit);
01003 sc_string _scv_extension_rw_sc_bit::get_string() const {
01004 if (get_integer()) return sc_string("1");
01005 else return sc_string("0");
01006 }
01007 void _scv_extension_rw_sc_bit::assign(const sc_bv_base& v) {
01008 if (v.length() != 1)
01009 _scv_message::message(_scv_message::INTROSPECTION_SIZE_MISMATCH_FOR_WIDE_DATA,
01010 "sc_bv_base","assign");
01011 *(this->_get_instance()) = v.get_bit(0); this->trigger_value_change_cb();
01012 }
01013 void _scv_extension_rw_sc_bit::get_value(sc_bv_base& v) const {
01014 if (v.length() != 1)
01015 _scv_message::message(_scv_message::INTROSPECTION_SIZE_MISMATCH_FOR_WIDE_DATA,
01016 "sc_bv_base","get_value");
01017 this->initialize();
01018 if (this->_get_instance()->to_bool())
01019 v.set_bit(0,sc_dt::Log_1);
01020 else
01021 v.set_bit(0,sc_dt::Log_0);
01022 }
01023 void _scv_extension_rw_sc_bit::assign(const sc_lv_base& v) {
01024 _SCV_RW_ERROR(assign,sc_lv_base,sc_bit);
01025 }
01026 void _scv_extension_rw_sc_bit::get_value(sc_lv_base& v) const {
01027 _SCV_RW_ERROR(get_value,sc_lv_base,sc_bit);
01028 }
01029
01030
01031
01032
01033
01034
01035 _SCV_EXT_RW_FC_BASE_I(sc_logic,sc_logic);
01036 _SCV_EXT_RW_FC_ASSIGNS_I(sc_logic,sc_logic);
01037 sc_string _scv_extension_rw_sc_logic::get_string() const {
01038 return sc_string(this->_get_instance()->to_char());
01039 }
01040 void _scv_extension_rw_sc_logic::assign(const sc_bv_base& v) {
01041 _SCV_RW_ERROR(assign,sc_bv_base,sc_logic);
01042 }
01043 void _scv_extension_rw_sc_logic::get_value(sc_bv_base& v) const {
01044 _SCV_RW_ERROR(get_value,sc_lv_base,sc_logic);
01045 }
01046 void _scv_extension_rw_sc_logic::assign(const sc_lv_base& v) {
01047 if (v.length() != 1)
01048 _scv_message::message(_scv_message::INTROSPECTION_SIZE_MISMATCH_FOR_WIDE_DATA,
01049 "sc_bv_base","assign");
01050 *(this->_get_instance()) = v.get_bit(0); this->trigger_value_change_cb();
01051 }
01052 void _scv_extension_rw_sc_logic::get_value(sc_lv_base& v) const {
01053 if (v.length() != 1)
01054 _scv_message::message(_scv_message::INTROSPECTION_SIZE_MISMATCH_FOR_WIDE_DATA,
01055 "sc_bv_base","get_value");
01056 this->initialize(); v.set_bit(0,this->_get_instance()->value());
01057 }
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069 #define _SCV_EXT_RW_FC_BASE_D_I(T,type_id) \
01070 _scv_extension_rw_ ## type_id::_scv_extension_rw_ ## type_id() {} \
01071 _scv_extension_rw_ ## type_id::~_scv_extension_rw_ ## type_id() {} \
01072 \
01073 inline const T* _scv_extension_rw_ ## type_id::get_instance() const { return _instance; } \
01074 inline T* _scv_extension_rw_ ## type_id::get_instance() { return _instance; } \
01075 T* _scv_extension_rw_ ## type_id::_get_instance() const { return _instance; } \
01076 \
01077 void _scv_extension_rw_ ## type_id::_set_instance(T* p) \
01078 { _instance = p; _set_instance_core_wrap(p); _bitwidth = p ? p->length() : 0; } \
01079 void _scv_extension_rw_ ## type_id::_set_instance_core_wrap(void*) {} \
01080 void _scv_extension_rw_ ## type_id::_set_as_field(_scv_extension_util_record * parent, T* p, \
01081 const string& name) { \
01082 if (p) _set_instance(p); \
01083 else if ( ! this->_get_parent() ) { this->_set_parent(parent,name); parent->_add_field(this); } \
01084 } \
01085 \
01086 const T& _scv_extension_rw_ ## type_id::read() { return *get_instance(); } \
01087 void _scv_extension_rw_ ## type_id::write(const T& rhs) { *_get_instance() = rhs; this->trigger_value_change_cb(); } \
01088
01089 #define _SCV_EXT_RW_FC_GET_VALUE_D_I(type_name,type_id,arg_name) \
01090 void _scv_extension_rw_ ## type_id::get_value(arg_name& i) const \
01091 { i = *(this->_get_instance()); } \
01092
01093 #define _SCV_EXT_RW_FC_ASSIGNS_D(type_name,type_id) \
01094 _SCV_EXT_RW_FC_BASE_D_I(type_name,type_id); \
01095 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,bool); \
01096 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,char); \
01097 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned char); \
01098 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,short); \
01099 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned short); \
01100 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,int); \
01101 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned int); \
01102 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,long); \
01103 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned long); \
01104 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,long long); \
01105 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned long long); \
01106 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,float); \
01107 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,double); \
01108 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const string&); \
01109 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const sc_string&); \
01110 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const char *); \
01111 bool _scv_extension_rw_ ## type_id::get_bool() const \
01112 { return *(this->_get_instance()) != 0; } \
01113 long long _scv_extension_rw_ ## type_id::get_integer() const \
01114 { return this->_get_instance()->to_int64(); } \
01115 unsigned long long _scv_extension_rw_ ## type_id::get_unsigned() const \
01116 { return this->_get_instance()->to_uint64(); } \
01117 double _scv_extension_rw_ ## type_id::get_double() const \
01118 { return this->_get_instance()->to_double(); } \
01119 sc_string _scv_extension_rw_ ## type_id::get_string() const \
01120 { assert(0); return sc_string(""); } \
01121 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,const sc_bv_base&); \
01122 _SCV_EXT_RW_FC_GET_VALUE_D_I(type_name,type_id,sc_bv_base); \
01123 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,const sc_lv_base&); \
01124 _SCV_EXT_RW_FC_GET_VALUE_D_I(type_name,type_id,sc_lv_base); \
01125
01126 #define _SCV_EXT_RW_FC_ASSIGNS_V(type_name,type_id) \
01127 _SCV_EXT_RW_FC_BASE_D_I(type_name,type_id); \
01128 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,bool); \
01129 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,char); \
01130 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned char); \
01131 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,short); \
01132 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned short); \
01133 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,int); \
01134 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned int); \
01135 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,long); \
01136 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned long); \
01137 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,long long); \
01138 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,unsigned long long); \
01139 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,float); \
01140 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,double); \
01141 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const string&); \
01142 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const sc_string&); \
01143 _SCV_EXT_RW_FC_BAD_ASSIGN_I(type_name,type_id,const char *); \
01144 bool _scv_extension_rw_ ## type_id::get_bool() const \
01145 { return *(this->_get_instance()) != 0; } \
01146 long long _scv_extension_rw_ ## type_id::get_integer() const \
01147 { _SCV_RW_ERROR(get_integer,integer,type_name); return 0; } \
01148 unsigned long long _scv_extension_rw_ ## type_id::get_unsigned() const \
01149 { _SCV_RW_ERROR(get_unsigned,unsigned,type_name); return 0; } \
01150 double _scv_extension_rw_ ## type_id::get_double() const \
01151 { _SCV_RW_ERROR(get_double,double,type_name); return 0; } \
01152 sc_string _scv_extension_rw_ ## type_id::get_string() const \
01153 { assert(0); return sc_string(""); } \
01154 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,const sc_bv_base&); \
01155 _SCV_EXT_RW_FC_GET_VALUE_D_I(type_name,type_id,sc_bv_base); \
01156 _SCV_EXT_RW_FC_ASSIGN_I(type_name,type_id,const sc_lv_base&); \
01157 _SCV_EXT_RW_FC_GET_VALUE_D_I(type_name,type_id,sc_lv_base); \
01158
01159 _SCV_EXT_RW_FC_ASSIGNS_D(sc_signed,sc_signed)
01160 _SCV_EXT_RW_FC_ASSIGNS_D(sc_unsigned,sc_unsigned)
01161 _SCV_EXT_RW_FC_ASSIGNS_D(sc_int_base,sc_int_base)
01162 _SCV_EXT_RW_FC_ASSIGNS_D(sc_uint_base,sc_uint_base)
01163 _SCV_EXT_RW_FC_ASSIGNS_V(sc_lv_base,sc_lv_base)
01164 _SCV_EXT_RW_FC_ASSIGNS_V(sc_bv_base,sc_bv_base)
01165
01166
01167
01168
01169
01170
01171
01172
01173 #undef _SCV_EXT_RW_FC_BOOL_ASSIGN_I
01174 #undef _SCV_EXT_RW_FC_ASSIGNS_I
01175
01176 #undef _SCV_EXT_RW_FC_ASSIGNS_STRING_I
01177 #undef _SCV_EXT_RW_FC_ASSIGNS_SYSC_I
01178
01179 #endif
01180
01181
01182
01183
01184 #undef _SCV_EXT_RW_FC_ASSIGN_I
01185 #undef _SCV_EXT_RW_FC_BAD_ASSIGN_I
01186
01187 #undef _SCV_EXT_RW_FC_COMMON_SYSC_I
01188 #undef _SCV_EXT_RW_FC_COMMON_I
01189
01190
01192
01193
01194
01195 #define _SCV_EXT_RAND_FC_COMMON_I(T, type_id) \
01196 void _scv_extension_rand_ ## type_id::next() { uninitialize(); initialize(); } \
01197 void _scv_extension_rand_ ## type_id::initialize() const { \
01198 if (this->_is_dynamic() && this->_get_dynamic_data()->undefined_) { \
01199 const_cast<_scv_extension_rand_ ## type_id*>(this)->generate_value_(); \
01200 const_cast<_scv_extension_rand_ ## type_id*>(this)->_get_dynamic_data()->undefined_ = false; \
01201 } \
01202 }; \
01203 void _scv_extension_rand_ ## type_id::disable_randomization() { \
01204 assert(this->_is_dynamic()); \
01205 this->_get_dynamic_data()->disable_randomization_ = true; \
01206 this->_get_dynamic_data()->undefined_ = false; \
01207 } \
01208 void _scv_extension_rand_ ## type_id::enable_randomization() { \
01209 assert(this->_is_dynamic()); \
01210 this->_get_dynamic_data()->disable_randomization_ = false; \
01211 uninitialize(); \
01212 } \
01213 bool _scv_extension_rand_ ## type_id::is_randomization_enabled() { \
01214 if (!this->_is_dynamic()) return false; \
01215 if (this->_has_dynamic_data()) return !this->_get_dynamic_data()->disable_randomization_; \
01216 return true; \
01217 } \
01218 scv_expression _scv_extension_rand_ ## type_id::form_expression() const { \
01219 return scv_expression(new scv_expression_core((scv_extensions_if*)(this))); \
01220 } \
01221 void _scv_extension_rand_ ## type_id::updated() { \
01222 this->_get_dynamic_data()->undefined_ = false; \
01223 } \
01224 bool _scv_extension_rand_ ## type_id::is_initialized() const { \
01225 return !this->_get_dynamic_data()->undefined_; \
01226 } \
01227 void _scv_extension_rand_ ## type_id::set_random(scv_shared_ptr<scv_random> gen) { \
01228 get_constraint_data()->set_random(gen); \
01229 } \
01230 void _scv_extension_rand_ ## type_id::use_constraint(scv_smart_ptr_if& s) { \
01231 use_constraint(_scv_get_extension(s)); \
01232 } \
01233 void _scv_extension_rand_ ## type_id::use_constraint(scv_extensions_if* e) { \
01234 _scv_use_constraint(this, e); \
01235 return; \
01236 } \
01237 _scv_extension_rand_ ## type_id::_scv_extension_rand_ ## type_id() {}
01238
01239
01240 #ifndef _SCV_INTROSPECTION_ONLY
01241
01242 #define _SCV_EXT_RAND_FC_EXTRA1_I(T, type_id) \
01243 void _scv_extension_rand_ ## type_id::set_value_mode(_scv_constraint_data::gen_mode m) { \
01244 get_constraint_data()->set_mode(m); \
01245 if (m == _scv_constraint_data::DISTRIBUTION || \
01246 m == _scv_constraint_data::DISTRIBUTION_RANGE) { \
01247 get_constraint_data()->set_ext_mode(scv_extensions_if::DISTRIBUTION); \
01248 } \
01249 } \
01250 void _scv_extension_rand_ ## type_id::keep_only(const T& value) { \
01251 _reset_bag_distribution(); \
01252 _scv_keep_range(this, value, value, false); \
01253 } \
01254 void _scv_extension_rand_ ## type_id::keep_only(const T& lb, const T& ub) { \
01255 _reset_bag_distribution(); \
01256 _scv_keep_range(this, lb, ub, false); \
01257 } \
01258 void _scv_extension_rand_ ## type_id::keep_only(const list<T>& vlist) { \
01259 _reset_bag_distribution(); \
01260 _scv_keep_range(this, vlist); \
01261 } \
01262 void _scv_extension_rand_ ## type_id::keep_out(const T& value) { \
01263 _reset_bag_distribution(); \
01264 _scv_keep_range(this, value, value, true); \
01265 } \
01266 void _scv_extension_rand_ ## type_id::keep_out(const T& lb, const T& ub) { \
01267 _reset_bag_distribution(); \
01268 _scv_keep_range(this, lb, ub, true); \
01269 } \
01270 void _scv_extension_rand_ ## type_id::keep_out(const list<T>& vlist) { \
01271 _reset_bag_distribution(); \
01272 list<T>::const_iterator i; \
01273 for (i = vlist.begin(); i != vlist.end(); i++) { \
01274 _scv_keep_range(this, *i, *i, true); \
01275 } \
01276 } \
01277 _scv_distribution<T> * _scv_extension_rand_ ## type_id::_get_distribution() { \
01278 return (_scv_distribution<T> *) this->_get_dynamic_data()->dist_; \
01279 } \
01280 void _scv_extension_rand_ ## type_id::_set_distribution(_scv_distribution<T>* d) { \
01281 _scv_distribution<T> * dist = _get_distribution(); \
01282 _scv_constraint_data * cdata = get_constraint_data(); \
01283 if (!dist) { \
01284 this->_get_dynamic_data()->dist_ = new _scv_distribution<T>; \
01285 dist = _get_distribution(); \
01286 } else { \
01287 dist->reset_distribution(); \
01288 } \
01289 if (d->dist_) { \
01290 dist->set_mode(*d->dist_, cdata, this); \
01291 } else if (d->dist_r_) { \
01292 dist->set_mode(*d->dist_r_, cdata, this); \
01293 } else { \
01294 _scv_message::message(_scv_message::INTERNAL_ERROR, "_set_distribution(base)"); \
01295 } \
01296 } \
01297 _scv_extension_rand_ ## type_id::~_scv_extension_rand_ ## type_id() { \
01298 if (this->_has_dynamic_data() && this->_get_dynamic_data()->dist_) \
01299 delete _get_distribution(); \
01300 if (this->_has_dynamic_data() && this->_get_dynamic_data()->cdata_) { \
01301 if (this->_get_dy