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

scv_constraint_range.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_constraint_range.h
00022 
00023   Original Authors (Cadence Design Systems, Inc):
00024   Norris Ip, Dean Shea, John Rose, Jasvinder Singh, William Paulsen,
00025   John Pierce, Rachida Kebichi, Ted Elkind, David Bailey, Samir Agrawal
00026   2002-09-23
00027 
00028  *****************************************************************************/
00029 
00030 /*****************************************************************************
00031 
00032   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00033   changes you are making here.
00034 
00035       Name, Affiliation, Date:
00036   Description of Modification:
00037 
00038  *****************************************************************************/
00039 
00040 #ifndef SCV_CONSTRAINT_RANGE_H
00041 #define SCV_CONSTRAINT_RANGE_H
00042 
00043 // *************************************************************************
00044 // Implementation for Value Generation using _scv_constraint_range
00045 // *************************************************************************
00046 
00047 #include "scv_config.h"
00048 
00049 #include <string>
00050 
00051 #ifdef SCV_USE_IOSTREAM_H
00052 # include <iostream.h>
00053 #else
00054 # include <iostream>
00055 #endif
00056 
00057 // *************************************************************************
00058 // Simple Constraint Facility Implementation
00059 // *************************************************************************
00060 
00061 #include <list>
00062 #include <math.h> // floor
00063 
00064 
00065 
00066 //*****************************
00067 // _scv_interval
00068 //
00069 // * a private class for implementation of _scv_constraint_range
00070 // * it provides manipulation of intervals, like checking
00071 //   whether two intervals overlap one another.
00072 // * it can be used with "int" intervals, "unsigned" intervals,
00073 //   and "double" intervals.
00074 //
00075 // * assumption:
00076 //     - int/unsigned is Discrete and the upperbound is inclusive.
00077 //     - double is not Discrete and the upperbound is exclusive.
00078 // * size() returns 0 when empty or overflow (i.e. full)
00079 // * the implementation needs to check overflow/underflow whenever
00080 //   a bound is incremented or decremented for discrete types. 
00081 //*****************************
00082 
00083 #define _SCV_INTERVAL_FC_D(TypeId, EltT, SizeT, Discrete)  \
00084 class _scv_interval_ ## TypeId {  \
00085 public:  \
00086   bool _empty;  \
00087   EltT _lowerbound;  \
00088   EltT _upperbound;  \
00089   mutable SizeT _tmp;  \
00090 public:  \
00091   _scv_interval_ ## TypeId()  \
00092     : _empty(true),  \
00093       _lowerbound(0),  \
00094       _upperbound(0),  \
00095       _tmp(0)  \
00096   {}  \
00097   _scv_interval_ ## TypeId(const EltT& lb, const EltT& ub)  \
00098     : _empty(false),  \
00099       _lowerbound(lb),  \
00100       _upperbound(ub),  \
00101       _tmp(lb)  \
00102   {  \
00103     if (ub<lb || (ub==lb && !Discrete))  \
00104       _empty = true;  \
00105   }  \
00106   _scv_interval_ ## TypeId(const _scv_interval_ ## TypeId& rhs)  \
00107     : _empty(rhs._empty),  \
00108       _lowerbound(rhs._lowerbound),  \
00109       _upperbound(rhs._upperbound),  \
00110       _tmp(rhs._tmp)  \
00111   {}  \
00112   ~_scv_interval_ ## TypeId() {}  \
00113   \
00114 public:  \
00115   _scv_interval_ ## TypeId& operator=(const _scv_interval_ ## TypeId& rhs);  \
00116   friend bool operator==(const _scv_interval_ ## TypeId& a,  \
00117        const _scv_interval_ ## TypeId& b);  \
00118   friend bool operator<(const _scv_interval_ ## TypeId& a,  \
00119        const _scv_interval_ ## TypeId& b);  \
00120   void print(ostream& os) const;  \
00121   friend ostream& operator<<(ostream& os, const _scv_interval_ ## TypeId& a);  \
00122   \
00123 public: /* basic access */  \
00124   bool empty() const { return _empty; }  \
00125   bool overflow() const { return !empty() && size() == 0; }  \
00126   SizeT size() const;  \
00127   EltT lowerbound() const { return _lowerbound; };  \
00128   EltT upperbound() const { return _upperbound; };  \
00129   \
00130 public:  \
00131   int position(const EltT& v) const;  \
00132   bool contain(const _scv_interval_ ## TypeId& i) const;  \
00133   friend bool overlap(const _scv_interval_ ## TypeId& a,  \
00134           const _scv_interval_ ## TypeId& b);  \
00135   void intersect(const _scv_interval_ ## TypeId& rhs);  \
00136   bool subtractable(const _scv_interval_ ## TypeId& rhs) const;  \
00137   void subtract(const _scv_interval_ ## TypeId& rhs);  \
00138   friend bool mergeable(const _scv_interval_ ## TypeId& a,  \
00139       const _scv_interval_ ## TypeId& b);  \
00140   void merge(const _scv_interval_ ## TypeId& rhs);  \
00141   \
00142 public: /* others */  \
00143   friend bool operator!=(const _scv_interval_ ## TypeId& a, const _scv_interval_ ## TypeId& b)  \
00144     { return !(a==b); }  \
00145   friend bool operator>(const _scv_interval_ ## TypeId& a, const _scv_interval_ ## TypeId& b)  \
00146     { return b<a; }  \
00147   friend bool operator>=(const _scv_interval_ ## TypeId& a, const _scv_interval_ ## TypeId& b)   \
00148     { return a>b || a==b; }  \
00149   friend bool operator<=(const _scv_interval_ ## TypeId& a, const _scv_interval_ ## TypeId& b)   \
00150     { return a<b || a==b; }  \
00151 };  \
00152 
00153 
00154 _SCV_INTERVAL_FC_D(int,int,unsigned,true);
00155 _SCV_INTERVAL_FC_D(unsigned,unsigned,unsigned,true);
00156 _SCV_INTERVAL_FC_D(double,double,double,false);
00157 
00158 _SCV_INTERVAL_FC_D(long_long,long long,unsigned long long,true);
00159 _SCV_INTERVAL_FC_D(unsigned_long_long,unsigned long long,unsigned long long,true);
00160 
00161 _SCV_INTERVAL_FC_D(sc_unsigned,sc_unsigned ,sc_unsigned,true);
00162 _SCV_INTERVAL_FC_D(sc_signed ,sc_signed ,sc_unsigned,true);
00163 
00164 
00165 
00166 // ****************************************
00167 // _scv_constraint_range class
00168 //
00169 // * _explicits is only used when 'Discrete' is false.
00170 // * _explicits and _intervals are sorted in assending order.
00171 // * get*() returns 0 with appropriate bits when empty. 
00172 // ****************************************
00173 
00174 #define _SCV_CONSTRAINT_RANGE_FC_D(TypeId, EltT, SizeT, Discrete, FlexRandomT)  \
00175 class _scv_constraint_range_ ## TypeId {  \
00176 public: /* main routines */  \
00177     /* return 0 of appropriate type when empty */  \
00178   EltT getLowerBound() const { return _intervals.front().lowerbound(); }  \
00179   EltT getUpperBound() const { return _intervals.back().upperbound(); }  \
00180   EltT getRandomValue(scv_shared_ptr<scv_random> random) const;  \
00181   EltT getScanValue(const EltT& base, const SizeT& increment) const;  \
00182   \
00183 public: /* constructor */  \
00184   _scv_constraint_range_ ## TypeId(); /* empty constraint */  \
00185   _scv_constraint_range_ ## TypeId(const EltT& sampleElt); /* empty constraint */  \
00186   _scv_constraint_range_ ## TypeId(const EltT& lb, const EltT& ub); /* simple interval */  \
00187   _scv_constraint_range_ ## TypeId(const _scv_constraint_range_ ## TypeId& rhs); /* copy */  \
00188   ~_scv_constraint_range_ ## TypeId() {}  \
00189   \
00190 public: /* constructions */  \
00191   _scv_constraint_range_ ## TypeId& operator=(const _scv_constraint_range_ ## TypeId& rhs);  \
00192   static _scv_constraint_range_ ## TypeId merge(const _scv_constraint_range_ ## TypeId& a,  \
00193              const _scv_constraint_range_ ## TypeId& b);  \
00194   void keepOnly(const EltT& lb, const EltT& ub);  \
00195   void keepOnly(const EltT& v);  \
00196   void keepOnly(const list<EltT>& l);  \
00197   void keepOut(const EltT& lb, const EltT& ub);  \
00198   void keepOut(const EltT& v); /* illegal if 'Discrete' is false. */  \
00199   void keepOut(const list<EltT>& l);  \
00200   \
00201 public:  \
00202   bool isEmpty() const { return _mode == EMPTY; }  \
00203   bool isUnconstrainted() const {   \
00204     return !isEmpty() && _explicits.empty() && getSize() == 0;  \
00205   }  \
00206   bool satisfy(const EltT& v) const;  \
00207   friend bool operator==(const _scv_constraint_range_ ## TypeId& a,  \
00208        const _scv_constraint_range_ ## TypeId& b) {  \
00209     return a._mode == b._mode && a._intervals == b._intervals  \
00210       && a._explicits == b._explicits;  \
00211   }  \
00212   friend bool operator!=(const _scv_constraint_range_ ## TypeId& a,  \
00213        const _scv_constraint_range_ ## TypeId& b) {  \
00214     return ! (a==b);  \
00215   }  \
00216   friend ostream& operator<<(ostream& os, const _scv_constraint_range_ ## TypeId& a);  \
00217   \
00218 public:  \
00219   void setNameP(const string & s) { _nameP = s; }  \
00220   const string & getNameP() const { return _nameP; }  \
00221   \
00222 private:  \
00223   enum {  \
00224     EMPTY,  \
00225     INTERVAL_LIST  \
00226   } _mode;  \
00227   string _nameP;  \
00228   \
00229   list<_scv_interval_ ## TypeId > _intervals;  \
00230   list<EltT> _explicits; /* only for 'Discrete' == false */  \
00231   FlexRandomT _flexRandom;  \
00232   EltT _tmpUb, _tmpLb; /* variable to make sure lsb/msb are save as signal */  \
00233   \
00234 private:  \
00235   mutable bool _sizeValid;  \
00236   mutable SizeT _size;  \
00237   SizeT getSize() const;  \
00238   void setSize() const;  \
00239   \
00240 private:  \
00241   void checkExplicits();  \
00242   void checkIntervals();  \
00243   \
00244   void emptyMessage();  \
00245 };  \
00246 
00247 
00248 
00249 
00250 // ****************************************
00251 // non-template class definitions for simple constraints
00252 // ****************************************
00253 class _scv_random_unsigned {
00254 public:
00255   _scv_random_unsigned() {}
00256   _scv_random_unsigned(int) {}
00257   _scv_random_unsigned(const _scv_random_unsigned&) {}
00258   ~_scv_random_unsigned() {}
00259   unsigned int mod(unsigned int data, unsigned int n) const {
00260     return data % n;
00261   }
00262   unsigned int floor(unsigned int data) const {
00263     assert(0); return 0;
00264   }
00265   unsigned int next(scv_shared_ptr<scv_random> random) const {
00266     return random->next();
00267   } 
00268   unsigned int next(scv_shared_ptr<scv_random> random, unsigned int size) const {
00269     return random->next() % size;
00270   } 
00271 };
00272 
00273 class _scv_random_double {
00274 public:
00275   _scv_random_double() {}
00276   _scv_random_double(int) {}
00277   _scv_random_double(const _scv_random_double&) {}
00278   _scv_random_double(double) {}
00279   ~_scv_random_double() {}
00280   double mod(double data, double n) const {
00281     double count1 = data / n;
00282     if (count1 - ::floor(count1) < 0.1) return 0;
00283     else return 1;
00284   }
00285   double floor(double data) const {
00286     return ::floor(data);
00287   }
00288   double next(scv_shared_ptr<scv_random> random) const {
00289     double i = random->next();
00290     double max = 0xFFFFFFFF;
00291     return (i / max);
00292   }
00293   double next(scv_shared_ptr<scv_random> random, double size) const {
00294     double i = random->next();
00295     double max = 0xFFFFFFFF;
00296     return (i / max) * size;
00297   }
00298 };
00299 
00300 class _scv_random_unsigned_ll {
00301 public:
00302   _scv_random_unsigned_ll() {}
00303   _scv_random_unsigned_ll(int) {}
00304   _scv_random_unsigned_ll(const _scv_random_unsigned_ll&) {}
00305   ~_scv_random_unsigned_ll() {}
00306   unsigned long long mod(unsigned long long data, unsigned long long n) const {
00307     return data % n;
00308   }
00309   unsigned long long floor(unsigned long long data) const {
00310     assert(0); return 0;
00311   }
00312   unsigned long long next(scv_shared_ptr<scv_random> random) const {
00313     unsigned long long temp = random->next();
00314     temp = temp << 32;
00315     temp = temp | random->next();
00316     return temp;
00317   } 
00318   unsigned long long next(scv_shared_ptr<scv_random> random, unsigned long long size) const {
00319     unsigned long long temp = random->next();
00320     temp = temp << 32;
00321     temp = temp | random->next();
00322     return temp % size;
00323   } 
00324 };
00325 
00326 class _scv_random_unsigned_big {
00327   int _numBits;
00328   int _numBlocks;
00329   int _remainderSize;
00330   mutable sc_signed* _temp;
00331 public:
00332   _scv_random_unsigned_big() 
00333     : _numBits(1), _numBlocks(0), _remainderSize(2), _temp(NULL) {}
00334   _scv_random_unsigned_big(const sc_unsigned& sample) 
00335     : _numBits(sample.length()),
00336       _numBlocks(sample.length()/32),
00337       _remainderSize(sample.length()%32) {
00338      _temp = new sc_signed(sample.length());
00339    }
00340   _scv_random_unsigned_big(const _scv_random_unsigned_big& rhs) 
00341     : _numBits(rhs._numBits),
00342       _numBlocks(rhs._numBlocks),
00343       _remainderSize(rhs._remainderSize) {
00344       _temp = new sc_signed(_numBits);
00345       *_temp = *rhs._temp;
00346   }
00347   ~_scv_random_unsigned_big() { if (_temp) delete _temp; }
00348   sc_unsigned  mod(const sc_unsigned& data, const sc_unsigned & n) const {
00349     return data % n;
00350   }
00351   unsigned int floor(const sc_unsigned& data) const {
00352     assert(0); return 0;
00353   }
00354   sc_unsigned next(scv_shared_ptr<scv_random> random) const {
00355     int i;
00356     for (i=0; i<_numBlocks; ++i) {
00357       (*_temp)(32*(i+1)-1,32*i) = (unsigned int ) random->next();
00358     }
00359     if (_remainderSize) {
00360       (*_temp)(_numBits-1, 32*_numBlocks) = ((unsigned int) random->next());
00361     }
00362     return *_temp;
00363   } 
00364   sc_unsigned  next(scv_shared_ptr<scv_random> random, const sc_unsigned& size) const {
00365     return next(random) % size;
00366   } 
00367 };
00368 
00369 
00370 
00371 _SCV_CONSTRAINT_RANGE_FC_D(int,int,unsigned,true,_scv_random_unsigned);
00372 _SCV_CONSTRAINT_RANGE_FC_D(unsigned,unsigned,unsigned,true,_scv_random_unsigned);
00373 _SCV_CONSTRAINT_RANGE_FC_D(double,double,double,false,_scv_random_double);
00374 
00375 _SCV_CONSTRAINT_RANGE_FC_D(long_long,long long,unsigned long long,true,_scv_random_unsigned_ll);
00376 _SCV_CONSTRAINT_RANGE_FC_D(unsigned_long_long,unsigned long long,unsigned long long,true,_scv_random_unsigned_ll);
00377 
00378 _SCV_CONSTRAINT_RANGE_FC_D(sc_unsigned,sc_unsigned ,sc_unsigned,true,_scv_random_unsigned_big);
00379 _SCV_CONSTRAINT_RANGE_FC_D(sc_signed ,sc_signed ,sc_unsigned,true,_scv_random_unsigned_big);
00380 
00381 
00382 
00383 class _scv_constraint_range_error {
00384 public:
00385   static void invalidScanInterval(const string& nameP) {
00386     setName(nameP);
00387     _scv_message::message(_scv_message::CONSTRAINT_INVALID_SCAN,nameP.c_str());
00388   }
00389   static void invalidDistance(const string& nameP) {
00390     setName(nameP);
00391     _scv_message::message(_scv_message::CONSTRAINT_INVALID_DISTANCE, nameP.c_str());
00392   }
00393   static void invalidDistribution(const string& nameP, const char * locationP) {
00394     setName(nameP);
00395     _scv_message::message(_scv_message::CONSTRAINT_BAD_BAG, nameP.c_str(),locationP);
00396   }
00397   static void overConstraint(const string&  nameP, const char * locationP) {
00398     setName(nameP);
00399     _scv_message::message(_scv_message::CONSTRAINT_ERROR_OVER_CONSTRAINED, nameP.c_str(),locationP);
00400   }
00401   static void emptyGenerator(const string& nameP) {
00402     setName(nameP);
00403     _scv_message::message(_scv_message::CONSTRAINT_ERROR_OVER_CONSTRAINED, nameP.c_str(),"value generation");
00404   }
00405 private:
00406   static void setName(const string& nameP) {
00407     string s = nameP; 
00408   }
00409 };
00410 
00411 // ****************************************
00412 // value generation algorithms with _scv_constraint_range 
00413 // ****************************************
00414 #define _SCV_CONSTRAINT_RANGE_GENERATOR_FC_D(TypeId, EltT, SizeT, Discrete, FlexRandomT)  \
00415 class _scv_constraint_range_generator_base_ ## TypeId {  \
00416 public: /* main interface */  \
00417   EltT randomNext() const;  \
00418   EltT distributionNext() const;  \
00419   EltT randomAvoidDuplicateNext() const;  \
00420   EltT scanNext() const;  \
00421   bool isEmpty() const { return _simpleConstraint.isEmpty(); }  \
00422   void reset() { _onGoingConstraintValid = false; _currentScanValueValid = false; }  \
00423   \
00424 public: /* constructors */  \
00425   _scv_constraint_range_generator_base_ ## TypeId(const EltT& lb, const EltT& ub,  \
00426           scv_shared_ptr<scv_random> random, const char * nameP);  \
00427   _scv_constraint_range_generator_base_ ## TypeId(const _scv_constraint_range_generator_base_ ## TypeId& rhs,  \
00428           const char * nameP);  \
00429   ~_scv_constraint_range_generator_base_ ## TypeId() {  \
00430     if (_distributionP) delete _distributionP;  \
00431     if (_scanIntervalGenP) delete _scanIntervalGenP;  \
00432   }  \
00433   \
00434 public: /* constraints */  \
00435   void setRandom(scv_shared_ptr<scv_random> random) {  \
00436     _randomP = random;  \
00437     if (_distributionP) _distributionP->setRandom(*random);  \
00438   }  \
00439   const _scv_constraint_range_ ## TypeId&  \
00440     getConstraint() const {  \
00441     return _simpleConstraint;  \
00442   }  \
00443   void setConstraint  \
00444     (const _scv_constraint_range_ ## TypeId& c) {  \
00445     _simpleConstraint = c;  \
00446     checkConstraint("setConstraint");  \
00447   }  \
00448   void keepOnly(const EltT& lb, const EltT& ub) {  \
00449     _simpleConstraint.keepOnly(lb,ub);  \
00450     checkConstraint("keepOnly");  \
00451   }  \
00452   void keepOnly(const EltT& v) {  \
00453     _simpleConstraint.keepOnly(v);  \
00454     checkConstraint("keepOnly");  \
00455   }  \
00456   void keepOnly(const list<EltT>& l) {  \
00457     _simpleConstraint.keepOnly(l);  \
00458     checkConstraint("keepOnly");  \
00459   }  \
00460   void keepOut(const EltT& lb, const EltT& ub) {  \
00461     _simpleConstraint.keepOut(lb,ub);  \
00462     checkConstraint("keepOut");  \
00463   }  \
00464   void keepOut(const EltT& v) {  \
00465     if (Discrete)  \
00466       _simpleConstraint.keepOut(v);  \
00467     else  \
00468       _simpleConstraint.keepOut(v-_duplicateDistance, v+_duplicateDistance);  \
00469     checkConstraint("keepOut");  \
00470   }  \
00471   void keepOut(const list<EltT>& l) {  \
00472     if (Discrete)  \
00473       _simpleConstraint.keepOut(l);  \
00474     else {  \
00475       for (list<EltT>::const_iterator i = l.begin(); i != l.end(); ++i)  \
00476   _simpleConstraint.keepOut(*i-_duplicateDistance, *i+_duplicateDistance);  \
00477     }  \
00478     checkConstraint("keepOut");  \
00479   }  \
00480   bool satisfyConstraints(const EltT& v) {  \
00481     return _simpleConstraint.satisfy(v);  \
00482   }  \
00483   \
00484 public:  \
00485   void print(ostream& os, const char * prefixP) const;  \
00486   friend ostream& operator<<(ostream& os, const _scv_constraint_range_generator_base_ ## TypeId& a) {  \
00487     a.print(os,NULL);  \
00488     return os;  \
00489   }  \
00490   \
00491 public:  \
00492   void setWeightDistribution(const scv_bag<EltT>& bag, bool useMarking);  \
00493   void _setWeightDistribution(const scv_bag<EltT>& bag, bool useMarking);  \
00494   void setDuplicateDistance(const SizeT& d) {   \
00495     if (d > 0)  \
00496       _duplicateDistance = d;  \
00497     else  \
00498       _scv_constraint_range_error::invalidDistance(_nameP);  \
00499   }  \
00500   void setScanInterval(const SizeT& lb, const SizeT& ub);  \
00501   \
00502 protected:  \
00503   const char * _nameP;  \
00504   _scv_constraint_range_ ## TypeId _simpleConstraint;  \
00505   mutable bool _onGoingConstraintValid;  \
00506   mutable _scv_constraint_range_ ## TypeId _onGoingConstraint;  \
00507   mutable bool _currentScanValueValid;  \
00508   mutable EltT _currentScanValue;  \
00509   scv_shared_ptr<scv_random> _randomP;  \
00510   \
00511 protected: /* mode specific */  \
00512   bool _distUseMarking;  \
00513   scv_bag<EltT> * _distributionP;  \
00514   SizeT _duplicateDistance;  \
00515   _scv_constraint_range_ ## TypeId * _scanIntervalGenP;  \
00516   bool _scanFixedIncrement;  \
00517   mutable SizeT _scanIncrement;  \
00518   \
00519 protected:  \
00520   void checkConstraint(const char * locationP);  \
00521 };  \
00522 
00523 
00524 _SCV_CONSTRAINT_RANGE_GENERATOR_FC_D(int,int,unsigned,true,_scv_random_unsigned);
00525 _SCV_CONSTRAINT_RANGE_GENERATOR_FC_D(unsigned,unsigned,unsigned,true,_scv_random_unsigned);
00526 _SCV_CONSTRAINT_RANGE_GENERATOR_FC_D(double,double,double,false,_scv_random_double);
00527 
00528 _SCV_CONSTRAINT_RANGE_GENERATOR_FC_D(long_long,long long,unsigned long long,true,_scv_random_unsigned_ll);
00529 _SCV_CONSTRAINT_RANGE_GENERATOR_FC_D(unsigned_long_long,unsigned long long,unsigned long long,true,_scv_random_unsigned_ll);
00530 
00531 _SCV_CONSTRAINT_RANGE_GENERATOR_FC_D(sc_unsigned,sc_unsigned ,sc_unsigned,true,_scv_random_unsigned_big);
00532 _SCV_CONSTRAINT_RANGE_GENERATOR_FC_D(sc_signed ,sc_signed ,sc_unsigned,true,_scv_random_unsigned_big);
00533 
00534 
00535 
00536 
00537 
00538 #define _SCV_CONSTRAINT_RANGE_GENERATOR_SIMPLE_FC_D(TypeId, EltT, SizeT, Discrete, FlexRandomT)  \
00539 class _scv_constraint_range_generator_simple_ ## TypeId : public  \
00540        _scv_constraint_range_generator_base_ ## TypeId {  \
00541 public:  \
00542   _scv_constraint_range_generator_simple_ ## TypeId(const EltT& lb, const EltT& ub,  \
00543                             scv_shared_ptr<scv_random> random, const char * nameP) : _scv_constraint_range_generator_base_ ## TypeId  \
00544   (lb, ub, random, nameP) {}  \
00545   _scv_constraint_range_generator_simple_ ## TypeId(const _scv_constraint_range_generator_simple_ ## TypeId& rhs,  \
00546                             const char * nameP) : _scv_constraint_range_generator_base_ ## TypeId(rhs) {}  \
00547   ~_scv_constraint_range_generator_simple_ ## TypeId() {}  \
00548 public:  \
00549   void keepOnly(const EltT& v) {  \
00550     this->_simpleConstraint.keepOnly(v);  \
00551     this->checkConstraint("keepOnly");  \
00552   }  \
00553   void keepOnly(const list<EltT>& l) {  \
00554     this->_simpleConstraint.keepOnly(l);  \
00555     this->checkConstraint("keepOnly");  \
00556   }  \
00557   void keepOnly(const EltT& lb, const EltT& ub) {  \
00558     this->_simpleConstraint.keepOnly(lb,ub);  \
00559     this->checkConstraint("keepOnly");  \
00560   }  \
00561   void keepOut(const EltT& lb, const EltT& ub){  \
00562     this->_simpleConstraint.keepOut(lb,ub);  \
00563     this->checkConstraint("keepOut");  \
00564   }  \
00565   void keepOut(const EltT& v) {  \
00566     if (Discrete)  \
00567       this->_simpleConstraint.keepOut(v);  \
00568     else  \
00569       this->_simpleConstraint.keepOut(v-this->_duplicateDistance, v+this->_duplicateDistance);  \
00570     this->checkConstraint("keepOut");  \
00571   }  \
00572   void keepOut(const list<EltT>& l) {  \
00573     if (Discrete)  \
00574       this->_simpleConstraint.keepOut(l);  \
00575     else {  \
00576       for (list<EltT>::const_iterator i = l.begin(); i != l.end(); ++i)  \
00577         this->_simpleConstraint.keepOut(*i-this->_duplicateDistance, *i+this->_duplicateDistance);  \
00578     }  \
00579     this->checkConstraint("keepOut");  \
00580   }  \
00581 };  \
00582 
00583 
00584 _SCV_CONSTRAINT_RANGE_GENERATOR_SIMPLE_FC_D(int,int,unsigned,true,_scv_random_unsigned);
00585 _SCV_CONSTRAINT_RANGE_GENERATOR_SIMPLE_FC_D(unsigned,unsigned,unsigned,true,_scv_random_unsigned);
00586 _SCV_CONSTRAINT_RANGE_GENERATOR_SIMPLE_FC_D(double,double,double,false,_scv_random_double);
00587 
00588 _SCV_CONSTRAINT_RANGE_GENERATOR_SIMPLE_FC_D(long_long,long long,unsigned long long,true,_scv_random_unsigned_ll);
00589 _SCV_CONSTRAINT_RANGE_GENERATOR_SIMPLE_FC_D(unsigned_long_long,unsigned long long,unsigned long long,true,_scv_random_unsigned_ll);
00590 
00591 
00592 
00593 // ****************************************
00594 // non-template class definitions for simple value generation with simple constraints
00595 // ****************************************
00596 
00597 typedef _scv_constraint_range_generator_simple_int _scv_constraint_range_generator_int;
00598 typedef _scv_constraint_range_generator_simple_unsigned _scv_constraint_range_generator_unsigned;
00599 typedef _scv_constraint_range_generator_simple_double _scv_constraint_range_generator_double;
00600 typedef _scv_constraint_range_generator_simple_long_long _scv_constraint_range_generator_int_ll;
00601 typedef _scv_constraint_range_generator_simple_unsigned_long_long _scv_constraint_range_generator_unsigned_ll;
00602 
00603 typedef _scv_constraint_range_generator_base_sc_unsigned _scv_constraint_range_generator_unsigned_big;
00604 typedef _scv_constraint_range_generator_base_sc_signed _scv_constraint_range_generator_signed_big;
00605 
00606 
00607 
00608 #endif

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