Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

_scv_randomization.h

Go to the documentation of this file.
00001 //  -*- C++ -*- <this line is for emacs to recognize it as C++ code>
00002 /*****************************************************************************
00003 
00004   The following code is derived, directly or indirectly, from the SystemC
00005   source code Copyright (c) 1996-2002 by all Contributors.
00006   All Rights reserved.
00007 
00008   The contents of this file are subject to the restrictions and limitations
00009   set forth in the SystemC Open Source License Version 2.3 (the "License");
00010   You may not use this file except in compliance with such restrictions and
00011   limitations. You may obtain instructions on how to receive a copy of the
00012   License at http://www.systemc.org/. Software distributed by Contributors
00013   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00014   ANY KIND, either express or implied. See the License for the specific
00015   language governing rights and limitations under the License.
00016 
00017  *****************************************************************************/
00018 
00019 /*****************************************************************************
00020 
00021   _scv_randomization -- The implementation for randomization to supplement
00022   extension "rand".
00023 
00024   Original Authors (Cadence Design Systems, Inc):
00025   Norris Ip, Dean Shea, John Rose, Jasvinder Singh, William Paulsen,
00026   John Pierce, Rachida Kebichi, Ted Elkind, David Bailey, Samir Agrawal
00027   2002-09-23
00028 
00029  *****************************************************************************/
00030 
00031 /*****************************************************************************
00032 
00033   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00034   changes you are making here.
00035 
00036       Name, Affiliation, Date:
00037   Description of Modification:
00038 
00039  *****************************************************************************/
00040 
00041 #include "scv/scv_shared_ptr.h"
00042 #include "scv/scv_constraint_range.h"
00043 
00044 #include <float.h>
00045 
00046 class scv_extensions_if;
00047 class scv_constraint_base;
00048 template <class T> class scv_bag;
00049 template <class T> class scv_ext_rand_base;
00050 class _scv_extension_rand_enum;
00051 extern scv_constraint_base * _scv_new_constraint(scv_constraint_base * c);
00052 extern void _scv_delete_constraint(scv_constraint_base * c);
00053 extern void _scv_assign_enum_value(scv_extensions_if* e, _scv_constraint_data* cdata_, int e1_val, int e2_val);
00054 
00055 scv_extensions_if * _scv_find_extension(scv_constraint_base * c, scv_extensions_if* e);
00056 
00058 // Create single scv_random object for composite type.
00060 #define GET_RANDOM() \
00061   static bool dummy = create_random(this); \
00062   if (0) cout << dummy << endl;
00063 
00064 inline bool create_random(scv_extensions_if* e) {
00065   e->get_random();
00066   return true;
00067 }
00068 
00069 class _scv_constraint_data {
00070 public:
00071   enum gen_mode {
00072     NO_CONSTRAINT,
00073     RANGE_CONSTRAINT,
00074     CONSTRAINT,
00075     EXTENSION,
00076     DISTRIBUTION,
00077     DISTRIBUTION_RANGE
00078   };
00079 private:
00080   scv_constraint_base* constr_;
00081   scv_extensions_if* extv_;
00082   gen_mode mode_;
00083   scv_extensions_if::mode_t ext_mode_;
00084   scv_shared_ptr<scv_random> gen_;
00085 public: // scan interval information used by _scv_constraint_manager
00086   union {
00087     int int_;
00088     unsigned int unsigned_;
00089     double double_; 
00090   } prev_val_;
00091   int lb_scan_;
00092   int ub_scan_;
00093 public:
00094   enum gen_type {IGEN, ILGEN, IBGEN, UGEN, ULGEN, UBGEN, DGEN, EMPTY};
00095 private:
00096   union {
00097     _scv_constraint_range_generator_int * igen;
00098     _scv_constraint_range_generator_int_ll * i_ll_gen;
00099     _scv_constraint_range_generator_signed_big * i_big_gen;
00100     _scv_constraint_range_generator_unsigned * ugen;
00101     _scv_constraint_range_generator_unsigned_ll * u_ll_gen;
00102     _scv_constraint_range_generator_unsigned_big * u_big_gen;
00103     _scv_constraint_range_generator_double * dgen;
00104   } _range_gen;
00105   gen_type _gen_type;
00106 public:
00107   _scv_constraint_data();
00108   _scv_constraint_data(const _scv_constraint_data& rhs); 
00109   ~_scv_constraint_data(); 
00110 public:
00111   scv_extensions_if* get_extension() {return extv_;}
00112   scv_constraint_base* get_constraint() {return constr_;}
00113   void set_generator_from(scv_extensions_if* to, scv_extensions_if* from) ;
00114   scv_shared_ptr<scv_random> get_random(scv_extensions_if* e); 
00115   gen_mode get_mode() {return mode_;}
00116   scv_extensions_if::mode_t get_ext_mode() {return ext_mode_;}
00117   void set_extension(scv_extensions_if* e) {extv_ = e;}
00118   void set_constraint(scv_constraint_base* c) {constr_ = c;}
00119   void set_random(scv_shared_ptr<scv_random> g) {gen_ = g;}
00120   void set_mode(gen_mode m) {mode_ = m;}
00121   void set_gen_type(gen_type t) {_gen_type = t;} 
00122   void reset_distribution(scv_extensions_if* s);
00123   gen_type get_gen_type() { return _gen_type; } 
00124   void set_ext_mode(scv_extensions_if::mode_t m, int lb=0, int ub=0 ); 
00125   _scv_constraint_range_generator_unsigned* get_unsigned_generator(scv_extensions_if* s); 
00126   _scv_constraint_range_generator_unsigned_ll* get_unsigned_ll_generator(scv_extensions_if* s);
00127   _scv_constraint_range_generator_int* get_int_generator(scv_extensions_if* s); 
00128   _scv_constraint_range_generator_int_ll* get_int_ll_generator(scv_extensions_if* s); 
00129   _scv_constraint_range_generator_unsigned_big* get_unsigned_big_generator(scv_extensions_if* s); 
00130   _scv_constraint_range_generator_signed_big* get_signed_big_generator(scv_extensions_if* s) ;
00131   _scv_constraint_range_generator_double* get_double_generator(scv_extensions_if* s); 
00132   bool is_complex_constraint() { return (mode_ == CONSTRAINT); } 
00133   bool is_range_constraint() { return (mode_ == RANGE_CONSTRAINT); }
00134   bool is_no_constraint() { return (mode_ == NO_CONSTRAINT); }
00135   bool is_distribution_constraint() {
00136     return (mode_ == DISTRIBUTION || mode_ == DISTRIBUTION_RANGE);
00137   }
00138   bool is_random_mode() { return (ext_mode_ == scv_extensions_if::RANDOM); }
00139   bool is_scan_mode() { return (ext_mode_ == scv_extensions_if::SCAN); }
00140   bool is_avoid_duplicate_mode() { 
00141     return (ext_mode_ == scv_extensions_if::RANDOM_AVOID_DUPLICATE); 
00142   }
00143 };
00144 
00145 void _scv_set_value(scv_extensions_if* e, _scv_constraint_data * cdata_);
00146 void _scv_set_value(scv_extensions_if* e, scv_constraint_base* c, scv_shared_ptr<scv_random> g);
00147 
00148 inline _scv_constraint_data* _get_constraint_data_enum(_scv_extension_rand_enum* data);
00149 inline void _set_mode_enum(_scv_extension_rand_enum* data, _scv_constraint_data::gen_mode m);
00150 inline scv_shared_ptr<scv_random> _get_random_enum(_scv_extension_rand_enum* data);
00151 
00152 template <typename T> 
00153 class _scv_distribution_base {
00154 public:
00155   scv_bag<T>* dist_;
00156   scv_bag<pair<T, T> >* dist_r_;
00157 public:
00158   _scv_distribution_base() : dist_(NULL), dist_r_(NULL) {}
00159   virtual ~_scv_distribution_base() {
00160     if (dist_)  delete dist_;
00161     if (dist_r_) delete dist_r_;
00162   }
00163 public:
00164   virtual scv_bag<T>* get_distribution() { return dist_; }
00165   virtual scv_bag<pair<T,T> >* get_distribution_range() { return dist_r_; }
00166   virtual void generate_value_(scv_extensions_if * data,
00167            _scv_constraint_data * cdata_) = 0; 
00168 
00169   // For all generic types except enumeration
00170   virtual void set_mode(scv_bag< pair<T,T> >& d, 
00171       _scv_constraint_data * constraint_data,
00172       scv_extensions_if * data) { 
00173     if (dist_r_) *dist_r_ = d;
00174     else {
00175       dist_r_ = new scv_bag< pair<T,T> >(d);
00176       dist_r_->setRandom(*(constraint_data->get_random(data)));
00177     }
00178     constraint_data->set_mode(_scv_constraint_data::DISTRIBUTION_RANGE);
00179     constraint_data->set_ext_mode(scv_extensions_if::DISTRIBUTION);
00180     _reset_distribution();
00181   }
00182   virtual void set_mode(scv_bag<T>& d,
00183       _scv_constraint_data * constraint_data,
00184       scv_extensions_if * data) { 
00185     if (dist_) *dist_ = d;
00186     else {
00187       dist_ = new scv_bag<T>(d);
00188       dist_->setRandom(*(constraint_data->get_random(data)));
00189     }
00190     constraint_data->set_mode(_scv_constraint_data::DISTRIBUTION);
00191     constraint_data->set_ext_mode(scv_extensions_if::DISTRIBUTION);
00192     _reset_distribution_range();
00193   }
00194 
00195   // For enumeration type
00196   virtual void set_mode(scv_bag< pair<T,T> >& d, 
00197                 _scv_extension_rand_enum * data) {
00198     if (dist_r_) *dist_r_ = d;
00199     else {
00200       dist_r_ = new scv_bag< pair<T,T> >(d);
00201       dist_r_->setRandom(*_get_random_enum(data));
00202     }
00203     _set_mode_enum(data, _scv_constraint_data::DISTRIBUTION_RANGE);
00204     _reset_distribution();
00205   }
00206   virtual void set_mode(scv_bag<T>& d,
00207                 _scv_extension_rand_enum * data) {
00208     if (dist_) *dist_ = d;
00209     else {
00210       dist_ = new scv_bag<T>(d);
00211       dist_->setRandom(*_get_random_enum(data));
00212     }
00213     _set_mode_enum(data, _scv_constraint_data::DISTRIBUTION);
00214     _reset_distribution_range();
00215   }
00216   virtual void reset_distribution() {
00217     _reset_distribution();
00218     _reset_distribution_range();
00219   }
00220   void _reset_distribution() {
00221     if (dist_) {
00222       delete dist_;
00223       dist_ = NULL;
00224     }
00225   }
00226   void _reset_distribution_range() {
00227     if (dist_r_) {
00228       delete dist_r_;
00229       dist_r_ = NULL;
00230     }
00231   }
00232 };
00233 
00235 // Forward declaration of routines required for generate_value_
00237 
00238 template <typename T> 
00239 void generate_value_distribution(scv_extensions_if *,
00240   scv_bag<T>*);
00241 template <typename T> 
00242 void generate_value_distribution_range(scv_extensions_if*,
00243   scv_bag<pair<T, T> >*, _scv_constraint_data*);
00244 void generate_value_no_constraint(scv_extensions_if*,
00245   _scv_constraint_data*);
00246 void generate_value_extension(scv_extensions_if*, 
00247   _scv_constraint_data*);
00248 void generate_value_range_constraint(scv_extensions_if*, 
00249   _scv_constraint_data*);
00250 
00252 // For all generic types <= 64 bits
00254 template<typename T>
00255 class _scv_distribution : public _scv_distribution_base<T> {
00256 public:
00257   void generate_value_(scv_extensions_if * data,
00258            _scv_constraint_data * cdata_) {
00259     switch(cdata_->get_mode()) {
00260     case _scv_constraint_data::DISTRIBUTION : {
00261       generate_value_distribution(data, this->get_distribution());
00262       break;
00263     }
00264     case _scv_constraint_data::DISTRIBUTION_RANGE : {
00265       generate_value_distribution_range(data, 
00266         this->get_distribution_range(), cdata_);
00267       break;
00268     }
00269     case _scv_constraint_data::NO_CONSTRAINT: {
00270       generate_value_no_constraint(data, cdata_); 
00271       break;
00272     }
00273     case _scv_constraint_data::RANGE_CONSTRAINT: {   
00274       generate_value_range_constraint(data, cdata_); 
00275       break;
00276     }
00277     case _scv_constraint_data::EXTENSION: 
00278     {
00279       generate_value_extension(data, cdata_);
00280       break;
00281     }
00282     case _scv_constraint_data::CONSTRAINT:
00283       _scv_set_value(data, cdata_);
00284       break;
00285     default:
00286       _scv_message::message(_scv_message::INTERNAL_ERROR, 
00287         "illegal randomization type");
00288       break;
00289     }
00290   }
00291 };
00292 
00294 // Forward declaration for solving distribution for types with
00295 // bitwidth >= 64 bits
00297 
00298 template <typename T>
00299 void generate_value_distribution_bigvalue(scv_extensions_if*, 
00300   scv_bag<T>*);
00301 template <typename T>
00302 void generate_value_distribution_range_bigvalue(scv_extensions_if*, 
00303   scv_bag<pair<T,T> >*, _scv_constraint_data*, sc_unsigned*);
00304 
00305 #define _SCV_DISTRIBUTION(typename)                        \
00306 template<int N>                                           \
00307 class _scv_distribution <typename<N> > :                   \
00308   public _scv_distribution_base<typename<N> > {            \
00309 public:                                                   \
00310   void generate_value_(scv_extensions_if * data,           \
00311            _scv_constraint_data * cdata_) {    \
00312     switch(cdata_->get_mode()) {                          \
00313     case _scv_constraint_data::DISTRIBUTION : {            \
00314       generate_value_distribution_bigvalue(data,          \
00315         this->get_distribution());                              \
00316       break;                                              \
00317     }                                                     \
00318     case _scv_constraint_data::DISTRIBUTION_RANGE : {      \
00319       sc_biguint<N> big_num;                              \
00320       generate_value_distribution_range_bigvalue(data,    \
00321         this->get_distribution_range(), cdata_, &big_num);      \
00322       break;                                              \
00323     }                                                     \
00324     case _scv_constraint_data::NO_CONSTRAINT:              \
00325     case _scv_constraint_data::CONSTRAINT: {               \
00326       _scv_set_value(data, cdata_);                        \
00327       break;                                              \
00328     }                                                     \
00329     case _scv_constraint_data::RANGE_CONSTRAINT: {         \
00330       generate_value_range_constraint(data, cdata_);      \
00331       break;                                              \
00332     }                                                     \
00333     case _scv_constraint_data::EXTENSION: {                \
00334       scv_extensions_if *e = cdata_->get_extension();      \
00335       _scv_constraint_data *cd = e->get_constraint_data(); \
00336       _scv_set_value(e, cd->get_constraint(),               \
00337         cdata_->get_random(data));                        \
00338       data->assign(e->get_unsigned());                    \
00339       break;                                              \
00340     }                                                     \
00341     default:                                              \
00342       _scv_message::message(_scv_message::INTERNAL_ERROR,     \
00343         "illegal randomization type");                    \
00344       break;                                              \
00345     }                                                     \
00346   }                                                       \
00347 };
00348 
00349 _SCV_DISTRIBUTION(sc_biguint)
00350 _SCV_DISTRIBUTION(sc_bigint)
00351 
00352 _SCV_DISTRIBUTION(sc_lv)
00353 _SCV_DISTRIBUTION(sc_bv)
00354 
00355 
00356 // Template methods to generate values  (bitwidth <= 64 bits)
00357 //   - generate_value_distribution
00358 //   - generate_value_distribution_range
00359 //
00360 // Non Template methods to obtain values (bitwidth <= 64 bits)
00361 //   - generate_vlaue_no_constraint
00362 //   - generate_value_extension
00364 template <typename T>
00365 void generate_value_distribution(scv_extensions_if * data,
00366   scv_bag<T>* dist)
00367 {
00368   switch (data->get_type()) {
00369   case scv_extensions_if::ENUMERATION: 
00370   case scv_extensions_if::INTEGER : 
00371   case scv_extensions_if::BOOLEAN: {
00372     const scv_extensions<T> e = scv_get_const_extensions(
00373                                  dist->peekRandom());
00374     if (data->get_bitwidth() <= 64) {
00375       data->assign(e.get_integer());
00376     } else {
00377       sc_bv_base val(data->get_bitwidth());
00378       e.get_value(val);
00379       data->assign(val);
00380     }
00381     break;
00382   }
00383   case scv_extensions_if::UNSIGNED :
00384   case scv_extensions_if::BIT_VECTOR :
00385   case scv_extensions_if::LOGIC_VECTOR : {
00386     const scv_extensions<T> e = scv_get_const_extensions(
00387                                  dist->peekRandom());
00388     if (data->get_bitwidth() <= 64) {
00389       data->assign(e.get_unsigned());
00390     } else {
00391       sc_bv_base val(data->get_bitwidth());
00392       e.get_value(val);
00393       data->assign(val);
00394     }
00395     break;
00396   }
00397   case scv_extensions_if::FLOATING_POINT_NUMBER: {
00398     const scv_extensions<T> e = scv_get_const_extensions(
00399                                  dist->peekRandom());
00400     data->assign(e.get_double());
00401     break;
00402   }
00403   default: 
00404     break;
00405   }
00406 }
00407 
00408 template <typename T>
00409 void generate_value_distribution_range(scv_extensions_if* data,
00410   scv_bag<pair<T, T> >* dist_range, _scv_constraint_data* cdata_)
00411 {
00412   pair<T, T> p = dist_range->peekRandom();
00413   switch(data->get_type()) {
00414     case scv_extensions_if::INTEGER : 
00415     case scv_extensions_if::BOOLEAN : {
00416       const scv_extensions<T> e1 = scv_get_const_extensions(p.first);
00417       const scv_extensions<T> e2 = scv_get_const_extensions(p.second);
00418       if (data->get_bitwidth() <= 32) {
00419         int e1_val = (int) e1.get_integer();
00420         int e2_val = (int) e2.get_integer();
00421 
00422         if (e2_val < e1_val) {
00423           _scv_message::message(_scv_message::CONSTRAINT_INVALID_RANGE, data->get_name());
00424           data->assign(e2_val);
00425         } else {
00426           int size = e2_val - e1_val + 1;
00427           int val = e1_val + (cdata_->get_random(data)->next() % size);
00428           data->assign(val);
00429         }
00430       } else if (data->get_bitwidth() <=64) {
00431         long long e1_val = e1.get_unsigned();
00432         long long e2_val = e2.get_unsigned();
00433  
00434         if (e2_val < e1_val) {
00435           _scv_message::message(_scv_message::CONSTRAINT_INVALID_RANGE, data->get_name());
00436           data->assign(e2_val);
00437         } else {
00438           unsigned long long size = e2_val - e1_val + 1;
00439           unsigned long long big_num = cdata_->get_random(data)->next();
00440           big_num = big_num << 31;
00441           big_num |= (cdata_->get_random(data)->next());
00442 
00443           long long val = e1_val + (big_num % size);
00444           data->assign(val);          
00445         }
00446       } else {
00447         static bool flag = false;
00448         if (!flag) {
00449           _scv_message::message(_scv_message::INTERNAL_ERROR, 
00450             "distribution range with bitwidth > 64 bits. This message will be printed only once.");
00451           flag = true;
00452         }
00453       }
00454       break;
00455     }
00456     case scv_extensions_if::UNSIGNED :
00457     case scv_extensions_if::BIT_VECTOR :
00458     case scv_extensions_if::LOGIC_VECTOR : {
00459       const scv_extensions<T> e1 = scv_get_const_extensions(p.first);
00460       const scv_extensions<T> e2 = scv_get_const_extensions(p.second);
00461       if (data->get_bitwidth() <= 32) {
00462         unsigned e1_val = (unsigned) e1.get_unsigned();
00463         unsigned e2_val = (unsigned) e2.get_unsigned();
00464 
00465         if (e2_val < e1_val) {
00466           _scv_message::message(_scv_message::CONSTRAINT_INVALID_RANGE, data->get_name());
00467           data->assign(e2_val);
00468         } else {
00469           unsigned size = e2_val - e1_val + 1;
00470           unsigned val = e1_val + (cdata_->get_random(data)->next() % size);
00471           data->assign(val);
00472         }
00473       } else if (data->get_bitwidth() <= 64) {
00474         unsigned long long e1_val = e1.get_unsigned();
00475         unsigned long long e2_val = e2.get_unsigned();
00476 
00477         if (e2_val < e1_val) { 
00478           _scv_message::message(_scv_message::CONSTRAINT_INVALID_RANGE, data->get_name());
00479           data->assign(e2_val);
00480         } else {
00481           unsigned long long size = e2_val - e1_val + 1;
00482           unsigned long long big_num = cdata_->get_random(data)->next();
00483           big_num = big_num << 31;
00484           big_num |= (cdata_->get_random(data)->next());
00485 
00486           unsigned long long val = e1_val + (big_num % size);
00487           data->assign(val);            
00488         }
00489       } else {
00490         static bool flag = false;
00491         if (!flag) {
00492           _scv_message::message(_scv_message::INTERNAL_ERROR, 
00493             "distribution range with bitwidth > 64 bits. This message will be printed only once");
00494           flag = true;
00495         }
00496       }
00497       break;
00498     }
00499     case scv_extensions_if::ENUMERATION: {
00500       const scv_extensions<T> e1 = scv_get_const_extensions(p.first);
00501       const scv_extensions<T> e2 = scv_get_const_extensions(p.second);
00502       int e1_val = (int) e1.get_integer();
00503       int e2_val = (int) e2.get_integer();
00504 
00505       _scv_assign_enum_value(data, cdata_, e1_val, e2_val);
00506       break;
00507     }
00508     default: 
00509       break;
00510   }
00511 }
00512 
00513 template <typename T>
00514 void generate_value_distribution_bigvalue(scv_extensions_if* data,
00515   scv_bag<T>* dist)
00516 {
00517   const T e = dist->peekRandom(); 
00518   int bitwidth = data->get_bitwidth();
00519 
00520   if (bitwidth <= 64) {
00521     if (data->is_integer()) {
00522       sc_signed val(bitwidth);
00523       val = e;
00524       data->assign(val.to_int64());
00525     } else if (data->is_unsigned() ||
00526                data->is_bit_vector() ||
00527                data->is_logic_vector()) {
00528       sc_unsigned val(bitwidth);
00529       val = e;
00530       data->assign(val.to_uint64());
00531     } else  {
00532       _scv_message::message(_scv_message::INTERNAL_ERROR, "unknown type");
00533     }
00534   } else {
00535     sc_bv_base val(bitwidth);
00536     val = e;
00537     data->assign(val);
00538   }
00539 }
00540 
00541 template <typename T>
00542 void generate_value_distribution_range_bigvalue(scv_extensions_if* data,
00543   scv_bag<pair<T, T> >* dist_range, _scv_constraint_data* cdata_, 
00544   sc_unsigned* big_num)
00545 {
00546   pair<T, T> p = dist_range->peekRandom();
00547   const T e1_v = p.first;
00548   const T e2_v = p.second;
00549   int bitwidth = data->get_bitwidth();
00550 
00551   if (bitwidth <= 32) {
00552     switch(data->get_type()) {
00553       case scv_extensions_if::INTEGER: {
00554         sc_signed e1(bitwidth);
00555         sc_signed e2(bitwidth);
00556         e1 = e1_v; e2 = e2_v;
00557         int e1_val = e1.to_int();
00558         int e2_val = e2.to_int();
00559         if (e2_val < e1_val) {
00560           _scv_message::message(_scv_message::CONSTRAINT_INVALID_RANGE, data->get_name());
00561           data->assign(e2_val);
00562         } else {
00563           unsigned size = e2_val - e1_val + 1;
00564           int val = e1_val + (cdata_->get_random(data)->next() % size);
00565           data->assign(val);
00566         }
00567         break;
00568       }
00569       case scv_extensions_if::BIT_VECTOR: 
00570       case scv_extensions_if::LOGIC_VECTOR: 
00571       case scv_extensions_if::UNSIGNED: {
00572         sc_unsigned e1(bitwidth);
00573         sc_unsigned e2(bitwidth);
00574         e1 = e1_v; e2 = e2_v;
00575         unsigned e1_val = e1.to_uint();
00576         unsigned e2_val = e2.to_uint();
00577         if (e2_val < e1_val) {
00578           _scv_message::message(_scv_message::CONSTRAINT_INVALID_RANGE, data->get_name());
00579           data->assign(e2_val);
00580         } else {
00581           unsigned size = e2_val - e1_val + 1;
00582           unsigned val = e1_val + (cdata_->get_random(data)->next() % size);
00583           data->assign(val);
00584         }
00585         break;
00586       }
00587       default:
00588         break;  
00589     }
00590   } else if (bitwidth <= 64) {
00591     switch(data->get_type()) {
00592     case scv_extensions_if::INTEGER: {
00593       sc_signed e1(bitwidth);
00594       sc_signed e2(bitwidth);
00595       e1 = e1_v; e2 = e2_v;
00596       long long e1_val = e1.to_int64();
00597       long long e2_val = e2.to_int64();
00598       if (e2_val < e1_val) {
00599         _scv_message::message(_scv_message::CONSTRAINT_INVALID_RANGE, data->get_name());
00600         data->assign(e2_val);
00601       } else {
00602         unsigned long long size = e2_val - e1_val + 1;
00603         unsigned long long bnum = cdata_->get_random(data)->next();
00604         bnum = bnum << 31;
00605         bnum |= (cdata_->get_random(data)->next());
00606         long long val = e1_val + (bnum % size);
00607         data->assign(val);    
00608       }
00609       break;
00610     }
00611     case scv_extensions_if::BIT_VECTOR: 
00612     case scv_extensions_if::LOGIC_VECTOR: 
00613     case scv_extensions_if::UNSIGNED: {
00614       sc_unsigned e1(bitwidth);
00615       sc_unsigned e2(bitwidth);
00616       e1 = e1_v; e2 = e2_v;
00617       unsigned long long e1_val = e1.to_uint64();
00618       unsigned long long e2_val = e2.to_uint64();
00619       if (e2_val < e1_val) {
00620         _scv_message::message(_scv_message::CONSTRAINT_INVALID_RANGE, data->get_name());
00621         data->assign(e2_val);
00622       } else {
00623         unsigned long long size = e2_val - e1_val + 1;
00624         unsigned long long bnum = cdata_->get_random(data)->next();
00625         bnum = bnum << 31;
00626         bnum |= (cdata_->get_random(data)->next());
00627         unsigned long long val = e1_val + (bnum % size);
00628         data->assign(val);    
00629       }
00630       break;
00631     } 
00632     default:
00633       break;
00634     }        
00635   } else {
00636     unsigned remain = bitwidth % 32;
00637   
00638     *big_num = cdata_->get_random(data)->next();
00639     for (int i=0; i < ((bitwidth/32)-1);i++) {
00640       *big_num = *big_num << 32;
00641       *big_num |= cdata_->get_random(data)->next();
00642     }
00643 
00644     *big_num = *big_num << remain;
00645     unsigned value_left = ((0x1 << remain) - 1);
00646     *big_num |= (cdata_->get_random(data)->next() & value_left);
00647   
00648     sc_bv_base bval(bitwidth);
00649 
00650     if (data->is_unsigned() ||
00651         data->is_bit_vector() ||
00652         data->is_logic_vector()) {
00653       sc_unsigned e1_tmp(bitwidth);
00654       sc_unsigned e2_tmp(bitwidth);
00655       sc_unsigned size(bitwidth);
00656       e1_tmp = e1_v; e2_tmp = e2_v;
00657       size = (e2_tmp - e1_tmp + 1);
00658       sc_unsigned val(bitwidth);
00659       val = e1_tmp + ((*big_num) % size);
00660       bval = val;
00661       data->assign(bval);
00662     } else if (data->is_integer()) {
00663       sc_signed e1_tmp(bitwidth);
00664       sc_signed e2_tmp(bitwidth);
00665       sc_signed size(bitwidth);
00666       e1_tmp = e1_v; e2_tmp = e2_v;
00667       size = (e2_tmp - e1_tmp + 1);
00668       sc_signed val(bitwidth);
00669       val = e1_tmp + ((*big_num) % size);
00670       bval = val;
00671       data->assign(bval);
00672     }
00673   }
00674 }
00675 
00676 template <typename T>
00677 bool check_mode(scv_extensions_if::mode_t t, 
00678   scv_extensions_if* e, const string& name,
00679    _scv_distribution<T> * dist)
00680 {
00681   _scv_constraint_data* cdata_ = e->get_constraint_data();
00682   if (t == scv_extensions_if::DISTRIBUTION) {
00683     if (dist->get_distribution()) {
00684       cdata_->set_mode(_scv_constraint_data::DISTRIBUTION);
00685     } else if (dist->get_distribution_range()) {
00686       cdata_->set_mode(_scv_constraint_data::DISTRIBUTION_RANGE);
00687     } else {
00688       _scv_message::message(_scv_message::INTROSPECTION_EMPTY_DISTRIBUTION, 
00689         name.c_str());
00690       return false;
00691     }
00692   } else {
00693     if (cdata_->get_extension()) { 
00694       cdata_->set_mode(_scv_constraint_data::EXTENSION);
00695     } else if (cdata_->get_gen_type() != _scv_constraint_data::EMPTY) {
00696       cdata_->set_mode(_scv_constraint_data::RANGE_CONSTRAINT);
00697     } else if (cdata_->get_constraint()) {
00698       cdata_->set_mode(_scv_constraint_data::CONSTRAINT);
00699     } else {
00700       cdata_->set_mode(_scv_constraint_data::NO_CONSTRAINT);
00701     }
00702   }
00703   return true;
00704 }
00705 
00706 inline void _scv_rand_util_get_list(scv_extensions_if* e, int lb, int ub, unsigned& mth, unsigned& nth) {
00707   list<int> ilist;
00708   list<const char *> slist; 
00709   list<int>::iterator iter;
00710   unsigned count = 0;
00711   e->get_enum_details(slist, ilist);
00712   for (iter=ilist.begin(); iter != ilist.end(); iter++) {
00713     if (*iter == lb) {
00714       nth = count;
00715     }
00716     if (*iter == ub) {
00717       mth  = count;
00718       break;
00719     }
00720     count++;
00721   }
00722   if (mth < nth) {
00723     _scv_message::message(_scv_message::CONSTRAINT_INVALID_RANGE, e->get_name());
00724     mth = nth;
00725     return;
00726   }
00727 }
00728 
00729 bool _scv_has_complex_constraint(scv_extensions_if*);
00730 
00731 #define _SCV_CHECK_DATA()                                                  \
00732   _scv_constraint_data* cd = e->get_constraint_data();                     
00733 
00734 #define _SCV_ONLY_OR_OUT(dummy_values, exclude, gen, lb, ub)               \
00735     if (!dummy_values) {                                                  \
00736       if (!exclude)                                                       \
00737         gen->keepOnly(lb, ub);                                            \
00738       else                                                                \
00739         gen->keepOut(lb, ub);                                             \
00740     }          
00741 
00742 #define _SCV_KEEP_RANGE_TYPE(_typename)                                    \
00743 template <int W>                                                          \
00744 inline void _scv_keep_range(scv_extensions_if* e, const _typename<W>& lb,          \
00745   const _typename<W>& ub, bool exclude, bool dummy_values = false) {                                 
00746 
00747 #define _SCV_KEEP_RANGE_TYPE_NO_W(_typename)                               \
00748 inline void _scv_keep_range(scv_extensions_if* e, const _typename& lb,      \
00749   const _typename& ub, bool exclude, bool dummy_values = false) {                                    
00750 
00751 #define _SCV_KEEP_RANGE_INT(_typename)                                     \
00752   _SCV_KEEP_RANGE_TYPE(_typename)                                          \
00753   _SCV_CHECK_DATA()                                                        \
00754   _scv_constraint_range_generator_unsigned_big *ugen = NULL;               \
00755   _scv_constraint_range_generator_signed_big *sgen = NULL;                 \
00756   if (e->is_integer()) {                                                  \
00757     sgen = cd->get_signed_big_generator(e);                               \
00758     _SCV_ONLY_OR_OUT(dummy_values, exclude, sgen, lb, ub)                                \
00759   } else if (e->is_unsigned()) {                                          \
00760     ugen = cd->get_unsigned_big_generator(e);                             \
00761     _SCV_ONLY_OR_OUT(dummy_values, exclude, ugen, lb, ub)                                \
00762   }                                                                       \
00763   cd->set_mode(_scv_constraint_data::RANGE_CONSTRAINT);                    \
00764 }                                                                         
00765 
00766 #define _SCV_SC_UNSIGNED_VALUE(dummy_values, W, lb, ub)                   \
00767   sc_unsigned lbv(W), ubv(W);                                             \
00768   if (dummy_values) { lbv = 0; ubv = 0; }                                 \
00769   else { lbv = lb; ubv = ub; } 
00770 
00771 #define _SCV_KEEP_RANGE_BIT(_typename)                                     \
00772   _SCV_KEEP_RANGE_TYPE(_typename)                                          \
00773   _SCV_CHECK_DATA()                                                        \
00774   _scv_constraint_range_generator_unsigned_big *ugen = NULL;               \
00775   ugen = cd->get_unsigned_big_generator(e);                               \
00776   _SCV_SC_UNSIGNED_VALUE(dummy_values, W, lb, ub)        \
00777   _SCV_ONLY_OR_OUT(dummy_values, exclude, ugen, lbv, ubv)                                \
00778   cd->set_mode(_scv_constraint_data::RANGE_CONSTRAINT);                    \
00779 }                                                                         
00780 
00781 #define _SCV_UNSIGNED_VALUE(lb, ub)                                        \
00782   unsigned lbv, ubv;                                                      \
00783   lbv = (unsigned)lb.to_bool(); ubv = (unsigned)ub.to_bool();             
00784 
00785 #define _SCV_KEEP_RANGE_LOGIC(_typename)                                   \
00786   _SCV_KEEP_RANGE_TYPE_NO_W(_typename)                                     \
00787   _SCV_CHECK_DATA()                                                        \
00788   _scv_constraint_range_generator_unsigned *ugen = NULL;                   \
00789   ugen = cd->get_unsigned_generator(e);                                   \
00790   _SCV_UNSIGNED_VALUE(lb, ub)                                              \
00791   _SCV_ONLY_OR_OUT(dummy_values, exclude, ugen, lbv, ubv)                                \
00792   cd->set_mode(_scv_constraint_data::RANGE_CONSTRAINT);                    \
00793 }                                                                         \
00794 
00795 #define _SCV_KEEP_RANGE_FLOAT(_typename)                                   \
00796   _SCV_KEEP_RANGE_TYPE_NO_W(_typename)                                     \
00797   _SCV_CHECK_DATA()                                                        \
00798   _scv_constraint_range_generator_double *dgen = NULL;                     \
00799   dgen = cd->get_double_generator(e);                                     \
00800   _SCV_ONLY_OR_OUT(dummy_values, exclude, dgen, lb, ub)                                  \
00801   cd->set_mode(_scv_constraint_data::RANGE_CONSTRAINT);                    \
00802 }                                                                         \
00803 
00804 #define _SCV_KEEP_RANGE_BASE_TYPE(_typename)                               \
00805   _SCV_KEEP_RANGE_TYPE_NO_W(_typename)                                     \
00806   _SCV_CHECK_DATA()                                                        \
00807   if (e->is_integer()) {                                                  \
00808     if (e->get_bitwidth() <= 64) {   \
00809       _scv_constraint_range_generator_int_ll * gen =  \
00810         cd->get_int_ll_generator(e); \
00811       _SCV_ONLY_OR_OUT(dummy_values, exclude, gen, lb.to_int64(), \
00812         ub.to_int64()) \
00813     } else { \
00814       _scv_message::message(_scv_message::INTERNAL_ERROR, "_scv_keep_range (sc_signed), unsupported bitwidth."); \
00815     } \
00816   } else if (e->is_unsigned()) {                                          \
00817     if (e->get_bitwidth() <= 64) { \
00818       _scv_constraint_range_generator_unsigned_ll * gen =  \
00819         cd->get_unsigned_ll_generator(e); \
00820       _SCV_ONLY_OR_OUT(dummy_values, exclude, gen, lb.to_uint64(), \
00821         ub.to_uint64()) \
00822     } else { \
00823       _scv_message::message(_scv_message::INTERNAL_ERROR, "_scv_keep_range (sc_unsigned), unsupported bitwidth."); \
00824     } \
00825   }                                                                       \
00826   cd->set_mode(_scv_constraint_data::RANGE_CONSTRAINT);                    \
00827 }                                                                         \
00828 
00829 #define _SCV_KEEP_RANGE_BASE_BIG_TYPE(_typename)                           \
00830   _SCV_KEEP_RANGE_TYPE_NO_W(_typename)                                     \
00831   _SCV_CHECK_DATA()                                                        \
00832   if (e->is_integer()) {                                                  \
00833     _scv_constraint_range_generator_signed_big *gen = NULL;               \
00834     gen = cd->get_signed_big_generator(e);                             \
00835     _SCV_ONLY_OR_OUT(dummy_values, exclude, gen, lb, ub)                 \
00836   } else if (e->is_unsigned()) {                                          \
00837     _scv_constraint_range_generator_unsigned_big *ugen = NULL;               \
00838     ugen = cd->get_unsigned_big_generator(e);                             \
00839     _SCV_ONLY_OR_OUT(dummy_values, exclude, ugen, lb, ub)                 \
00840   } \
00841   cd->set_mode(_scv_constraint_data::RANGE_CONSTRAINT);                    \
00842 }                                                                         \
00843 
00844 #define _SCV_KEEP_RANGE_BASE_LOGIC_TYPE(_typename)                       \
00845   _SCV_KEEP_RANGE_TYPE_NO_W(_typename)                                   \
00846   _SCV_CHECK_DATA()                                                      \
00847   _scv_constraint_range_generator_unsigned_big *ugen = NULL;               \
00848   ugen = cd->get_unsigned_big_generator(e);                             \
00849   _SCV_SC_UNSIGNED_VALUE(dummy_values, e->get_bitwidth(), lb, ub)       \
00850   _SCV_ONLY_OR_OUT(dummy_values, exclude, ugen, lbv, ubv)                 \
00851   cd->set_mode(_scv_constraint_data::RANGE_CONSTRAINT);                    \
00852 }                                                                  \
00853 
00854 #define _SCV_KEEP_RANGE_ERROR(_typename)                                   \
00855   _SCV_KEEP_RANGE_TYPE_NO_W(_typename)                                     \
00856   _scv_message::message(_scv_message::RANDOM_TYPE_NOT_SUPPORTED, #_typename);  \
00857 }                                                                         \
00858 
00859 _SCV_KEEP_RANGE_INT(sc_biguint)
00860 _SCV_KEEP_RANGE_INT(sc_bigint)
00861 
00862 _SCV_KEEP_RANGE_BIT(sc_bv)
00863 _SCV_KEEP_RANGE_BIT(sc_lv)
00864 
00865 _SCV_KEEP_RANGE_LOGIC(sc_bit)
00866 _SCV_KEEP_RANGE_LOGIC(sc_logic)
00867 
00868 _SCV_KEEP_RANGE_FLOAT(double)
00869 _SCV_KEEP_RANGE_FLOAT(float)
00870 
00871 _SCV_KEEP_RANGE_ERROR(string)
00872 _SCV_KEEP_RANGE_ERROR(sc_string)
00873 
00874 _SCV_KEEP_RANGE_BASE_BIG_TYPE(sc_signed)
00875 _SCV_KEEP_RANGE_BASE_BIG_TYPE(sc_unsigned)
00876 _SCV_KEEP_RANGE_BASE_TYPE(sc_int_base)
00877 _SCV_KEEP_RANGE_BASE_TYPE(sc_uint_base)
00878 _SCV_KEEP_RANGE_BASE_LOGIC_TYPE(sc_lv_base)
00879 _SCV_KEEP_RANGE_BASE_LOGIC_TYPE(sc_bv_base)
00880 
00881 template <typename T>
00882 inline void _scv_keep_range(scv_extensions_if* e, const T& lb, const T& ub, bool exclude, bool dummy_values=false) {
00883     _SCV_CHECK_DATA()
00884     switch(e->get_type()) {
00885       case scv_extensions_if::BOOLEAN:
00886       case scv_extensions_if::UNSIGNED: {
00887         if (e->get_bitwidth() <= 32) {
00888           _scv_constraint_range_generator_unsigned * gen =
00889           cd->get_unsigned_generator(e);
00890           _SCV_ONLY_OR_OUT(dummy_values, exclude, gen, (unsigned)lb, (unsigned)ub)
00891         } else if (e->get_bitwidth() <= 64) {
00892           _scv_constraint_range_generator_unsigned_ll * gen =
00893           cd->get_unsigned_ll_generator(e);
00894           _SCV_ONLY_OR_OUT(dummy_values, exclude, gen, (unsigned long long)lb, (unsigned long long)ub)
00895         } else {
00896           _scv_message::message(_scv_message::INTERNAL_ERROR, "_scv_keep_range (unsigned)");
00897         }
00898         cd->set_mode(_scv_constraint_data::RANGE_CONSTRAINT);
00899         break;
00900       }
00901       case scv_extensions_if::INTEGER: {
00902         if (e->get_bitwidth() <=32) {
00903           _scv_constraint_range_generator_int * gen =
00904           cd->get_int_generator(e);
00905           _SCV_ONLY_OR_OUT(dummy_values, exclude, gen, (int)lb, (int)ub);
00906         } else if (e->get_bitwidth() <= 64) {
00907           _scv_constraint_range_generator_int_ll * gen =
00908           cd->get_int_ll_generator(e);
00909           _SCV_ONLY_OR_OUT(dummy_values, exclude, gen, (long long)lb, (long long)ub)
00910         } else {
00911           _scv_message::message(_scv_message::INTERNAL_ERROR, "_scv_keep_range (signed)");
00912         }
00913         cd->set_mode(_scv_constraint_data::RANGE_CONSTRAINT);
00914         break;
00915       }
00916       case scv_extensions_if::ENUMERATION: {
00917          _scv_constraint_range_generator_unsigned * gen =              
00918            cd->get_unsigned_generator(e);               
00919          unsigned nth = 0;
00920          unsigned mth = 0;
00921          _scv_rand_util_get_list(e, (int)lb, (int)ub, mth, nth);       
00922          if (!exclude) {
00923            gen->keepOnly(nth, mth);                                      
00924          } else { 
00925            gen->keepOut(nth, mth);                                      
00926          }
00927          cd->set_mode(_scv_constraint_data::RANGE_CONSTRAINT); 
00928       }
00929       default:
00930         break;
00931     }
00932 }
00933 
00934 template <typename T>
00935 inline void _scv_keep_range_list_enum(scv_extensions_if* e, const list<T>& vlist, bool exclude) {  
00936   list<int> ilist;
00937   list<const char *> slist;
00938   list<int>::iterator iter;
00939   unsigned count = 0;
00940   unsigned nth = 0;
00941   e->get_enum_details(slist, ilist);
00942 
00943   _scv_constraint_range_generator_unsigned * gen =         
00944      e->get_constraint_data()->get_unsigned_generator(e); 
00945   typename list<T>::const_iterator i;                
00946   list<unsigned> tlist;
00947 
00948   for (i = vlist.begin(); i != vlist.end(); i++) { 
00949     count = 0;
00950     for (iter=ilist.begin(); iter != ilist.end(); iter++) {
00951       if (*iter == *i) {
00952         nth = count;
00953         break;
00954       }
00955       count++;
00956     }
00957     tlist.push_back((unsigned)nth);               
00958   }                          
00959   if (!exclude) {
00960     gen->keepOnly(tlist);
00961   } else {
00962     gen->keepOut(tlist);
00963   }                    
00964   e->get_constraint_data()->set_mode(_scv_constraint_data::RANGE_CONSTRAINT);
00965 }
00966 
00967 template <typename T1, typename T2>
00968 void _scv_get_list(const list<T2>& vlist, list<T1>& tlist) { 
00969   typename list<T2>::const_iterator i;                                        
00970   for (i = vlist.begin(); i != vlist.end(); i++)                             
00971     tlist.push_back(*i);                                                       
00972 }
00973 
00974 template <typename T1, typename T2>
00975 void _scv_get_base_unsigned_list(const list<T2>& vlist, list<T1>& tlist) { 
00976   typename list<T2>::const_iterator i;                                        
00977   for (i = vlist.begin(); i != vlist.end(); i++)                             
00978     tlist.push_back((*i).to_uint64()); 
00979 }
00980 
00981 template <typename T1, typename T2>
00982 void _scv_get_base_signed_list(const list<T2>& vlist, list<T1>& tlist) { 
00983   typename list<T2>::const_iterator i;                                        
00984   for (i = vlist.begin(); i != vlist.end(); i++)                             
00985     tlist.push_back((*i).to_int64()); 
00986 }
00987 
00988 template <typename T1, typename T2> 
00989 void _scv_get_list_sc(int W, const list<T2>& vlist, list<T1>& tlist ) { 
00990   typename list<T2>::const_iterator i;                                   
00991   for (i = vlist.begin(); i != vlist.end(); i++)                        
00992     tlist.push_back(*i);                                               
00993 }
00994 
00995 template <typename T1, typename T2>
00996 void _scv_get_sc_list(int W, const list<T2>& vlist, list<T1>& tlist) {
00997   typename list<T2>::const_iterator i;
00998   T1 val(W);                         
00999   for (i = vlist.begin(); i != vlist.end(); i++) { 
01000     val = *i;                                     
01001     tlist.push_back(val);                        
01002   }                                                                            
01003 }
01004 
01005 template <typename T1, typename T2> 
01006 void _scv_get_logic_list(const list<T2> &vlist, list<T1> &tlist) {
01007   typename list<T2>::const_iterator i;                       
01008   for (i = vlist.begin(); i != vlist.end(); i++)            
01009     tlist.push_back((unsigned)((*i).to_bool()));           
01010 }
01011 
01012 template <typename T>
01013 inline void _scv_keep_range(scv_extensions_if* e, const list<T>& vlist) {
01014   _scv_message::message(_scv_message::RANDOM_TYPE_NOT_SUPPORTED, e->get_type_name());
01015 }
01016 
01017 #define _SCV_KEEP_RANGE_LIST_HEADER(_typename)                                  \
01018 template <>                                                                    \
01019 inline void _scv_keep_range(scv_extensions_if* e, const list<_typename>& vlist) {       \
01020   _SCV_CHECK_DATA()                                                             \
01021 
01022 #define _SCV_KEEP_RANGE_SC_HEADER(_typename)                               \
01023 template <int W>                                                               \
01024 inline void _scv_keep_range(scv_extensions_if* e, const list<_typename<W> >& vlist) {   \
01025   _SCV_CHECK_DATA()                                                             \
01026 
01027 #define _SCV_KEEP_RANGE_SET_LIST(tlist)                                         \
01028   gen->keepOnly(tlist);                                                        \
01029   cd->set_mode(_scv_constraint_data::RANGE_CONSTRAINT);                         \
01030 
01031 #define _SCV_KEEP_RANGE_LIST_INT_TYPE(_typename)                                \
01032   _SCV_KEEP_RANGE_LIST_HEADER(_typename)                                        \
01033   _scv_constraint_range_generator_int * gen =                                   \
01034   cd->get_int_generator(e);                                                    \
01035   list<int> tlist;                                                             \
01036   _scv_get_list(vlist, tlist);                                                  \
01037   _SCV_KEEP_RANGE_SET_LIST(tlist)                                               \
01038 }
01039 
01040 #define _SCV_KEEP_RANGE_LIST_INT64_TYPE(_typename)                              \
01041   _SCV_KEEP_RANGE_LIST_HEADER(_typename)                                        \
01042   _scv_constraint_range_generator_int_ll * gen =                                \
01043   cd->get_int_ll_generator(e);                                                 \
01044   list<long long> tlist;                                                             \
01045   _scv_get_list(vlist, tlist);                                                   \
01046   _SCV_KEEP_RANGE_SET_LIST(tlist)                                               \
01047 }
01048 
01049 #define _SCV_KEEP_RANGE_LIST_SC_INT_TYPE(_typename)                             \
01050   _SCV_KEEP_RANGE_SC_HEADER(_typename)                                     \
01051   _scv_constraint_range_generator_int_ll * gen =                                \
01052   cd->get_int_ll_generator(e); \
01053   list<long long> tlist;                                              \
01054   _scv_get_list_sc(W, vlist, tlist);                              \
01055   _SCV_KEEP_RANGE_SET_LIST(tlist)                                               \
01056 }
01057 
01058 #define _SCV_KEEP_RANGE_LIST_UNSIGNED_TYPE(_typename)                           \
01059   _SCV_KEEP_RANGE_LIST_HEADER(_typename)                                        \
01060   _scv_constraint_range_generator_unsigned * gen =                              \
01061   cd->get_unsigned_generator(e);                                               \
01062   list<unsigned> tlist; \
01063   _scv_get_list(vlist, tlist)      ;                               \
01064   _SCV_KEEP_RANGE_SET_LIST(tlist)                                               \
01065 }
01066 
01067 #define _SCV_KEEP_RANGE_LIST_UNSIGNED64_TYPE(_typename)                         \
01068   _SCV_KEEP_RANGE_LIST_HEADER(_typename)                                        \
01069   _scv_constraint_range_generator_unsigned_ll * gen =                           \
01070   cd->get_unsigned_ll_generator(e);                                            \
01071   list<unsigned long long> tlist; \
01072   _scv_get_list(vlist, tlist) ;                          \
01073   _SCV_KEEP_RANGE_SET_LIST(tlist)                                               \
01074 }
01075 
01076 #define _SCV_KEEP_RANGE_LIST_SC_UINT_TYPE(_typename)                            \
01077   _SCV_KEEP_RANGE_SC_HEADER(_typename)                                     \
01078   _scv_constraint_range_generator_unsigned_ll * gen =                           \
01079   cd->get_unsigned_ll_generator(e);                                            \
01080   list<unsigned long long> tlist; \
01081   _scv_get_list_sc(W, vlist, tlist);                     \
01082   _SCV_KEEP_RANGE_SET_LIST(tlist)                \
01083 }
01084 
01085 #define _SCV_KEEP_RANGE_LIST_FLOAT_TYPE(_typename)                              \
01086   _SCV_KEEP_RANGE_LIST_HEADER(_typename)                                        \
01087   _scv_constraint_range_generator_double * gen =                                \
01088   cd->get_double_generator(e);                                                 \
01089   list<double> tlist; \
01090   _scv_get_list(vlist, tlist) ;                                      \
01091   _SCV_KEEP_RANGE_SET_LIST(tlist)                \
01092 }
01093 
01094 #define _SCV_KEEP_RANGE_LIST_SC_SIGNED_TYPE(_typename)                          \
01095   _SCV_KEEP_RANGE_SC_HEADER(_typename)                                     \
01096   _scv_constraint_range_generator_signed_big * gen =                            \
01097   cd->get_signed_big_generator(e);                                             \
01098   list<sc_signed> tlist; \
01099   _scv_get_sc_list(W, vlist, tlist);                              \
01100   _SCV_KEEP_RANGE_SET_LIST(tlist)                \
01101 }
01102 
01103 #define _SCV_KEEP_RANGE_LIST_SC_UNSIGNED_TYPE(_typename)                        \
01104   _SCV_KEEP_RANGE_SC_HEADER(_typename)                                     \
01105   _scv_constraint_range_generator_unsigned_big * gen =                          \
01106   cd->get_unsigned_big_generator(e);                                           \
01107   list<sc_unsigned> tlist; \
01108   _scv_get_sc_list(e->get_bitwidth(), vlist, tlist);                         \
01109   _SCV_KEEP_RANGE_SET_LIST(tlist)                \
01110 }
01111 
01112 #define _SCV_KEEP_RANGE_LIST_BASE_UNSIGNED_TYPE(_typename)                \
01113   _SCV_KEEP_RANGE_LIST_HEADER(_typename)                                  \
01114   _scv_constraint_range_generator_unsigned_ll * gen =                        \
01115   cd->get_unsigned_ll_generator(e);                                          \
01116   list<unsigned long long> tlist; \
01117   _scv_get_base_unsigned_list(vlist, tlist)      ;                    \
01118   _SCV_KEEP_RANGE_SET_LIST(tlist)                \
01119 }
01120 
01121 #define _SCV_KEEP_RANGE_LIST_BASE_SIGNED_TYPE(_typename)                \
01122   _SCV_KEEP_RANGE_LIST_HEADER(_typename)                                  \
01123   _scv_constraint_range_generator_int_ll * gen =                        \
01124   cd->get_int_ll_generator(e);                                          \
01125   list<long long> tlist; \
01126   _scv_get_base_signed_list(vlist, tlist)      ;                    \
01127   _SCV_KEEP_RANGE_SET_LIST(tlist)                \
01128 }
01129 
01130 #define _SCV_KEEP_RANGE_LIST_BASE_SC_SIGNED_TYPE(_typename)                        \
01131   _SCV_KEEP_RANGE_LIST_HEADER(_typename)                                     \
01132   _scv_constraint_range_generator_signed_big * gen =                          \
01133   cd->get_signed_big_generator(e);                                           \
01134   list<sc_signed> tlist; \
01135   _scv_get_sc_list(e->get_bitwidth(), vlist, tlist);                         \
01136   _SCV_KEEP_RANGE_SET_LIST(tlist)                \
01137 }
01138 
01139 #define _SCV_KEEP_RANGE_LIST_BASE_SC_UNSIGNED_TYPE(_typename)                        \
01140   _SCV_KEEP_RANGE_LIST_HEADER(_typename)                                     \
01141   _scv_constraint_range_generator_unsigned_big * gen =                          \
01142   cd->get_unsigned_big_generator(e);                                           \
01143   list<sc_unsigned> tlist; \
01144   _scv_get_sc_list(e->get_bitwidth(), vlist, tlist);                         \
01145   _SCV_KEEP_RANGE_SET_LIST(tlist)                \
01146 }
01147 
01148 #define _SCV_KEEP_RANGE_LIST_LOGIC_TYPE(_typename)                              \
01149   _SCV_KEEP_RANGE_LIST_HEADER(_typename)                                        \
01150   _scv_constraint_range_generator_unsigned * gen =                              \
01151   cd->get_unsigned_generator(e);                                               \
01152   list<unsigned> tlist; \
01153   _scv_get_logic_list(vlist, tlist);                               \
01154   _SCV_KEEP_RANGE_SET_LIST(tlist)                \
01155 }
01156 
01157 _SCV_KEEP_RANGE_LIST_INT_TYPE(char)
01158 _SCV_KEEP_RANGE_LIST_INT_TYPE(short)
01159 _SCV_KEEP_RANGE_LIST_INT_TYPE(int)
01160 _SCV_KEEP_RANGE_LIST_INT_TYPE(long)
01161 _SCV_KEEP_RANGE_LIST_INT64_TYPE(long long)
01162 _SCV_KEEP_RANGE_LIST_SC_INT_TYPE(sc_int)                 
01163 
01164 _SCV_KEEP_RANGE_LIST_UNSIGNED_TYPE(bool)
01165 _SCV_KEEP_RANGE_LIST_UNSIGNED_TYPE(unsigned char)
01166 _SCV_KEEP_RANGE_LIST_UNSIGNED_TYPE(unsigned short)
01167 _SCV_KEEP_RANGE_LIST_UNSIGNED_TYPE(unsigned int)
01168 _SCV_KEEP_RANGE_LIST_UNSIGNED_TYPE(unsigned long)
01169 _SCV_KEEP_RANGE_LIST_UNSIGNED64_TYPE(unsigned long long)
01170 _SCV_KEEP_RANGE_LIST_SC_UINT_TYPE(sc_uint)                  
01171 
01172 _SCV_KEEP_RANGE_LIST_SC_UNSIGNED_TYPE(sc_biguint)
01173 _SCV_KEEP_RANGE_LIST_SC_UNSIGNED_TYPE(sc_lv)
01174 _SCV_KEEP_RANGE_LIST_SC_UNSIGNED_TYPE(sc_bv)
01175 
01176 _SCV_KEEP_RANGE_LIST_SC_SIGNED_TYPE(sc_bigint)
01177 
01178 _SCV_KEEP_RANGE_LIST_FLOAT_TYPE(double)
01179 _SCV_KEEP_RANGE_LIST_FLOAT_TYPE(float)
01180 
01181 _SCV_KEEP_RANGE_LIST_LOGIC_TYPE(sc_logic)
01182 _SCV_KEEP_RANGE_LIST_LOGIC_TYPE(sc_bit)
01183 
01184 _SCV_KEEP_RANGE_LIST_BASE_SC_SIGNED_TYPE(sc_signed)
01185 _SCV_KEEP_RANGE_LIST_BASE_SC_UNSIGNED_TYPE(sc_unsigned)
01186 _SCV_KEEP_RANGE_LIST_BASE_SIGNED_TYPE(sc_int_base)
01187 _SCV_KEEP_RANGE_LIST_BASE_UNSIGNED_TYPE(sc_uint_base)
01188 _SCV_KEEP_RANGE_LIST_BASE_SC_UNSIGNED_TYPE(sc_lv_base)
01189 _SCV_KEEP_RANGE_LIST_BASE_SC_UNSIGNED_TYPE(sc_bv_base)
01190 

Generated on Fri Jan 14 08:28:56 2005 for SystemC2.1beta11(excludingMSLib)(IncludingSCV)\nProvidedby:www.openverificationfoundation.org by doxygen1.2.18