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

scv_tr.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_tr.h -- 
00022   This is the public interface for transaction recording. This API is used
00023   to create transactions from your testbench, and also to record
00024   transactions into a recording database using callbacks.
00025 
00026   Original Authors (Cadence Design Systems, Inc):
00027   Norris Ip, Dean Shea, John Rose, Jasvinder Singh, William Paulsen,
00028   John Pierce, Rachida Kebichi, Ted Elkind, David Bailey
00029   2002-09-23
00030 
00031  *****************************************************************************/
00032 
00033 /*****************************************************************************
00034 
00035   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00036   changes you are making here.
00037 
00038       Name, Affiliation, Date:
00039   Description of Modification:
00040 
00041  *****************************************************************************/
00042 
00043 /*
00044  * Author:  Bill Paulsen
00045  *
00046  * Description:
00047  *
00048  *  The scv_tr_db class allows you to open and close a transaction recording
00049  *  database object.  This object can be associated with separate facilities
00050  *  (which use callback registrations in scv_tr_db) to record transactions into
00051  *  a database.  scv_tr_db also alows you to suspend and resume transaction
00052  *  recording.
00053  * 
00054  *  The scv_tr_stream class allows you to create streams in a transaction
00055  *  object.  A stream has a hierarchical position in the elaborated design,
00056  *  and is the object on which transactions occur.
00057  *
00058  *  The scv_tr_generator template class allows you to describe the
00059  *  kinds of transactions that can occur on a stream.  The template parameters
00060  *  are classes (or structs) that specify the transaction attributes that are
00061  *  set at the beginning of a transaction, and the attributes that are set
00062  *  at the end of a transaction.  This class includes method to
00063  *  begin and to end transactions that are of this scv_tr_generator class.
00064  *  The begin_transaction() method accepts an argument that is an object
00065  *  that is of type of the first template parameter of this class.
00066  *  (The template parameter class must have a scv_extensions.)
00067  *  The values of the members of this object become the values of the
00068  *  attributes that are set at the beginning of this transaction.
00069  *  The end_transaction() method allows you to set the end-attributes 
00070  *  of this transaction.
00071  *
00072  *  The scv_tr_handle class is an object that represents a transaction.
00073  *  This object is returned from the begin_transaction() methods in the
00074  *  scv_tr_generator class.  (IE, you should not directly construct
00075  *  this class.)  This class has methods to get the begin and end times
00076  *  of the transaction, and also methods to get the scv_extensions of the
00077  *  attributes that are defined at the beginning and at the end of the
00078  *  transaction.
00079  *
00080  *
00081  *  Each class has methods that can register and remove callbacks on
00082  *  activity of that class.  For example, the scv_tr_generator class will
00083  *  give a callback when a transaction is begun, and another callback
00084  *  when it's ended.  In your registered callback function, you are passed
00085  *  a reference to the scv_tr_handle that was begun or ended.  For the
00086  *  scv_tr_stream class, you will get a callback when a scv_tr_stream is created
00087  *  and when it's deleted.
00088  *
00089  *  The callback methods can be used to implement applications that 
00090  *  record transaction activity into a recording database.  The scv_tr_text.cpp
00091  *  file contains an example that does transaction recording into a
00092  *  text file.
00093  *
00094  *
00095  * TBD:
00096  *
00097  *  Change the void* user_data_p in the callback registration functions
00098  *  to type-safe.
00099  *
00100  */
00101 
00102 #ifndef SCV_TR_H
00103 #define SCV_TR_H 
00104 
00105 // ----------------------------------------------------------------------------
00106 //
00107 // The following is the default template parameter for the
00108 // scv_tr_generator template class.  (You should not need to use
00109 // this in your code.)
00110 //
00111 struct _scv_tr_generator_default_data {
00112   int _default_field_;
00113 };
00114 SCV_EXTENSIONS(_scv_tr_generator_default_data) {
00115 public:
00116   scv_extensions<int> _default_field_;
00117   SCV_EXTENSIONS_CTOR(_scv_tr_generator_default_data) {
00118     SCV_FIELD(_default_field_);
00119   }
00120 };
00121 
00122 // ----------------------------------------------------------------------------
00123 
00124 // Call this function from your sc_main() to use transaction text recording:
00125 //
00126 extern void scv_tr_text_init();
00127 
00128 // ----------------------------------------------------------------------------
00129 
00130 class _scv_tr_db_core;
00131 class _scv_tr_stream_core;
00132 class _scv_tr_generator_core;
00133 class _scv_tr_handle_core;
00134 
00135 class scv_tr_stream;
00136 class scv_tr_generator_base;
00137 template<class T1, class T2> class scv_tr_generator;
00138 class scv_tr_handle;
00139 
00140 typedef long scv_tr_relation_handle_t;
00141 
00142 // ----------------------------------------------------------------------------
00143 // ----------------------------------------------------------------------------
00144 
00145 class scv_tr_db : public scv_object_if {
00146  public:
00147 
00148   // The scv_tr_db class provides methods to:
00149   // 
00150   //   Open a transaction recording database.
00151   //
00152   //   Set the current time in the database.
00153   //
00154   //   Suspend and resume transaction recording in the database.
00155   //
00156   //   The standard print, show, kind, and dbg methods.
00157   //
00158 
00159   // The scv_tr_db constructor opens a transaction recording database.
00160   //
00161   // recording_file_name specifies the name of a file for transaction
00162   //   recording.
00163   //
00164   // time_scale specifies the time scale that is used for the recording
00165   //   database.  When you call set_time(), which is described below,
00166   //   the values of the argument to set_time() are presumed to be
00167   //   in units of time_scale.  The default is SC_FS.
00168   //
00169   scv_tr_db(
00170         const char* recording_file_name,
00171   const sc_time_unit& = SC_FS);
00172 
00173 
00174   // The dtor closes the recording database.
00175   //
00176   virtual ~scv_tr_db();
00177 
00178 
00179   // Set and get default scv_tr_db objects.
00180   //
00181   static void set_default_db(scv_tr_db*);
00182   static scv_tr_db* get_default_db();
00183 
00184 
00185   // Callbacks:
00186   //
00187   enum callback_reason { CREATE, DELETE, SUSPEND, RESUME };
00188 
00189   typedef int callback_h;
00190 
00191   // Your callback function:
00192   //
00193   typedef void callback_function(
00194     const scv_tr_db& obj,
00195                 callback_reason reason,
00196     void* user_data_p);
00197 
00198   // Register a callback for any scv_tr_db object creation/deletion.
00199   //
00200   static callback_h register_class_cb(
00201     callback_function*,
00202                 void* user_data_p = NULL);
00203 
00204   // Remove a callback.
00205   //
00206   static void remove_callback(callback_h);
00207 
00208   // set_recording allows you to temporarily suspend and resume recording.
00209   // set_recording(true) resumes recording (this is the default).
00210   // set_recording(false) suspends recording.
00211   // get_recording() returns the current state.
00212   //
00213   void set_recording(bool) const;
00214   bool get_recording() const;
00215 
00216   void print(ostream& o, int details=0, int indent=0) const;
00217   void show(int details=0, int indent=0) const;
00218   static void set_debug(int debug);
00219   static int get_debug();
00220 
00221   const char *get_name() const;
00222   const char *kind() const { return _kind; }
00223 
00224 
00225   // Create a new relation that can be defined between two transactions.
00226   // If a relation with relation_name had previously been created, then
00227   // return the handle to that relation.
00228   //
00229   scv_tr_relation_handle_t create_relation(
00230   const char* relation_name) const;
00231 
00232   // Get the name of a relation handle.  NULL is returned if the
00233   // relation_handle does not refer to a valid relation.
00234   //
00235   const char* get_relation_name(
00236   scv_tr_relation_handle_t relation_handle) const;
00237 
00238  private:
00239   friend class scv_tr_stream;
00240   _scv_tr_db_core* _scv_tr_db_core_p;
00241   static const char *_kind;
00242 };
00243 
00244 // --------------------------------------------------------------------------
00245 
00246 class scv_tr_stream : public scv_object_if {
00247  public:
00248 
00249   // The scv_tr_stream ctor will create a stream on which transactions are
00250   // recorded at the specified scope, in the specified scv_tr_db.
00251   // 
00252   // full_stream_name is the full hierarchical path name of this stream.
00253   //   If full_stream_name already exists in this scv_tr_db, then that stream
00254   //   will be used.  If full_stream_scope_name is an invalid name, then this
00255   //   ctor will cause a fatal error.
00256   //
00257   // stream_kind is the kind of stream.  Common names are TRANSACTOR and TEST.
00258   //
00259   // scv_tr_db_p is the scv_tr_db object in which this stream is placed.  The
00260   //   default is the most recently opened database.  If this does not
00261   //   exist, then this ctor will cause a fatal error.
00262   //
00263   scv_tr_stream(
00264         const char* full_stream_name,
00265         const char* stream_kind,
00266   scv_tr_db* scv_tr_db_p = scv_tr_db::get_default_db());
00267 
00268   scv_tr_stream() { this->_scv_tr_stream_core_p = NULL; }
00269 
00270   virtual ~scv_tr_stream();
00271 
00272 
00273   // Callbacks:
00274   //
00275   enum callback_reason { CREATE, DELETE };
00276 
00277   typedef int callback_h;
00278 
00279   typedef void callback_function(
00280     const scv_tr_stream& obj,
00281     callback_reason reason,
00282                 void* user_data_p);
00283 
00284   // Register a callback for stream creation/deletion.
00285   //
00286   static callback_h register_class_cb(
00287     callback_function*,
00288                 void* user_data_p = NULL);
00289 
00290   // Remove a callback.
00291   //
00292   static void remove_callback(callback_h);
00293 
00294   void print(ostream& o, int details=0, int indent=0) const;
00295   void show(int details=0, int indent=0) const;
00296   static void set_debug(int debug);
00297   static int get_debug();
00298 
00299   const char *get_name() const;
00300   const char *kind() const { return _kind; }
00301 
00302   uint64 get_id() const;
00303 
00304   const char* get_stream_kind() const;
00305 
00306   // Return the most recently started scv_tr_handle on this scv_tr_stream,
00307   // on this process thread.  If none, then return an invalid
00308   // scv_tr_handle.  (Possibly remove this method)
00309   //
00310   scv_tr_handle get_current_transaction_handle();
00311 
00312   // Return the scv_tr_db in which this stream is defined:
00313   //
00314   const scv_tr_db* get_scv_tr_db() const;
00315 
00316  private:
00317   template<class T1, class T2> friend class scv_tr_generator;
00318   friend class scv_tr_generator_base;
00319   _scv_tr_stream_core* _scv_tr_stream_core_p;
00320   static const char *_kind;
00321 };
00322 
00323 // --------------------------------------------------------------------------
00324 
00325 class scv_tr_handle : public scv_object_if {
00326 
00327  // This is a handle object, which includes an "is_valid()" method.
00328  //
00329  // You should use the scv_tr_generator::begin_transaction()
00330  // methods to create scv_tr_handle objects.
00331  // 
00332  // You should use the scv_tr_generator::end_transaction()
00333  // methods to end transactions.
00334  // 
00335  // After ending a transaction, you will still have a handle to the
00336  // transaction, which can be used to set relations, for example.
00337  // The transaction is deleted when all references to the transaction
00338  // go out of scope.
00339 
00340  public:
00341 
00342   // Note that the is_valid() method will return false if this ctor is
00343   // used directly.
00344   //
00345   scv_tr_handle();
00346 
00347   virtual ~scv_tr_handle();
00348 
00349   // Copy assignment:
00350   //
00351   scv_tr_handle &operator=(
00352     const scv_tr_handle& other);
00353 
00354   // Copy ctor:
00355   //
00356   scv_tr_handle(
00357     const scv_tr_handle& other);
00358 
00359 
00360   // End this transaction at the current simulation time.
00361   // The values of the attributes that are normally set at the end of
00362   // transaction, will be set to "undefined".  This method is also used
00363   // when the scv_tr_generator was defined to have no begin attributes.
00364   // (ie, the default was used for the T_begin template parameter.)
00365   //
00366   void end_transaction() {
00367     this->_end_transaction(NULL, sc_time_stamp());
00368   }
00369 
00370   // End this transaction at the current simulation time, and specify the
00371   // values of the end attributes.
00372   //
00373   template<class T_end> void end_transaction(
00374         const scv_tr_handle& t,
00375         const T_end& end_attribute_values)
00376   {
00377     scv_extensions<T_end> ext = scv_get_const_extensions(end_attribute_values);
00378     this->_end_transaction(&ext, sc_time_stamp());
00379   }
00380 
00381   // End this transaction at a simulation time that is in the past, and
00382   // specify the values of the end attributes.
00383   //
00384   template<class T_end> void end_transaction(
00385         const scv_tr_handle& t,
00386         const T_end& end_attribute_values,
00387         const sc_time& end_sc_time)
00388   {
00389     scv_extensions<T_end> ext = scv_get_const_extensions(end_attribute_values);
00390     this->_end_transaction(&ext, end_sc_time);
00391   }
00392 
00393 
00394   // Use these methods to record additional attributes on a transaction.
00395   // These methods can only be called after a transaction is started,
00396   // and before it's ended:
00397   //
00398   template <class T> void record_attribute(
00399   const char* attribute_name,
00400   const T& attribute_value) {
00401     scv_extensions<T> ext = scv_get_const_extensions(attribute_value);
00402     this->_record_attribute(attribute_name, &ext);
00403   }
00404 
00405   template <class T> void record_attribute(
00406         const T& attribute_value) {
00407     scv_extensions<T> ext = scv_get_const_extensions(attribute_value);
00408     this->_record_attribute(0, &ext);
00409   }
00410 
00411 
00412   // Callbacks:
00413   //
00414   enum callback_reason { BEGIN, END, DELETE };
00415 
00416   typedef int callback_h;
00417 
00418   // Your callback function for BEGIN/END/DELETE:
00419   //
00420   typedef void callback_function(
00421     const scv_tr_handle& obj,
00422     callback_reason reason,
00423                 void* user_data_p);
00424 
00425   // Register a callback for transaction BEGIN/END/DELETE.
00426   //
00427   static callback_h register_class_cb(
00428     callback_function*,
00429     void* user_data_p = NULL);
00430 
00431 
00432   // Your callback function for when an attribute is set on this transaction,
00433   // other than at the begin or end of the transaction:
00434   //
00435   typedef void callback_record_attribute_function(
00436                 const scv_tr_handle& obj,
00437           const char* attribute_name,
00438     const scv_extensions_if* exts_p,
00439                 void* user_data_p);
00440 
00441   // Register a callback for record attribute:
00442   //
00443   static callback_h register_record_attribute_cb(
00444                 callback_record_attribute_function*,
00445                 void* user_data_p = NULL);
00446 
00447 
00448   // Your callback function for related transactions:
00449   //
00450   typedef void callback_relation_function(
00451                 const scv_tr_handle& transaction_1,
00452                 const scv_tr_handle& transaction_2,
00453                 void* user_data_p,
00454                 scv_tr_relation_handle_t relation_handle);
00455 
00456 
00457   // Register a callback for when a transaction relation occurs.
00458   //
00459   static callback_h register_relation_cb(
00460     callback_relation_function*,
00461     void* user_data_p = NULL);
00462 
00463   // Remove a callback.
00464   //
00465   static void remove_callback(callback_h);
00466 
00467 
00468   // Return true if this is a valid transaction, which was created by a
00469   // successfull call to a scv_tr_generator::begin_transaction()
00470   // method.
00471   //
00472   bool is_valid() const;
00473 
00474   // Return true if the transaction is currently open (ie, the transaction
00475   // has begun, but is not yet ended.)  Returns false otherwise.
00476   //
00477   bool is_active() const;
00478 
00479   // Return the scv_extensions_if of the begin or end attributes.
00480   //
00481   const scv_extensions_if* get_begin_exts_p() const;
00482   const scv_extensions_if* get_end_exts_p() const;
00483 
00484   // Return the scv_extensions_if of the built-in attributes.
00485   //
00486   const scv_extensions_if* get_builtin_exts_p() const;
00487 
00488   // Get the unique ID for this transaction.
00489   //
00490   uint64 get_id() const;
00491 
00492   void print(ostream& o, int details=0, int indent=0) const;
00493   void show(int details=0, int indent=0) const;
00494   static void set_debug(int debug);
00495   static int get_debug();
00496 
00497   const char *get_name() const;
00498   const char *kind() const { return _kind; }
00499 
00500 
00501   // Set a relation from this transaction to another_transaction.
00502   // The relation is: this is a "relation_name" of other_transaction.
00503   //
00504   // If successful, return true, else return false (eg, either transaction
00505   // handle was invalid).
00506   //
00507   // relation_name is the name of the relation.
00508   //
00509   // other_transaction is the other transaction that will be related.
00510   //
00511   bool add_relation(
00512   scv_tr_relation_handle_t relation_handle,
00513         const scv_tr_handle& other_transaction_handle);
00514 
00515   bool add_relation(
00516   const char* relation_name,
00517   const scv_tr_handle& other_transaction_handle) {
00518     return add_relation(
00519   get_scv_tr_stream().get_scv_tr_db()->create_relation(relation_name),
00520   other_transaction_handle);
00521   };
00522 
00523   // If a related transaction is specified at the beginning of a new
00524   // transaction, then return the other related transaction and the
00525   // relation_handle.  Return NULL is there's no related transaction.
00526   //
00527   const scv_tr_handle* get_immediate_related_transaction(
00528   scv_tr_relation_handle_t* relation_handle_p) const;
00529 
00530   // Return the begin and end time of this transaction.
00531   //
00532   const sc_time& get_begin_sc_time() const;
00533   const sc_time& get_end_sc_time() const;
00534 
00535   // Return the stream on which this transaction occurs:
00536   //
00537   const scv_tr_stream& get_scv_tr_stream() const;
00538 
00539   // Return the transaction on which this transaction occurs:
00540   //
00541   // TBD get_scv_tr_generator_base => get_tr_generator_base
00542   const scv_tr_generator_base& get_scv_tr_generator_base() const;
00543 
00544  private:
00545   _scv_tr_handle_core* _scv_tr_handle_core_p;
00546   friend class scv_tr_generator_base;
00547   template<class T1, class T2> friend class scv_tr_generator;
00548   void _end_transaction(const scv_extensions_if*,
00549     const sc_time& end_sc_time) const;
00550   static const char *_kind;
00551   void _record_attribute(const char* attribute_name, const scv_extensions_if*);
00552 };
00553 
00554 // --------------------------------------------------------------------------
00555 
00556 class scv_tr_generator_base : public scv_object_if {
00557   friend class scv_tr_stream;
00558   friend class scv_tr_handle;
00559  public:
00560 
00561   scv_tr_generator_base(
00562         const char* name,
00563         scv_tr_stream& s,
00564   const char* begin_attribute_name,
00565   const char* end_attribute_name);
00566 
00567   scv_tr_generator_base() { this->_scv_tr_generator_core_p = NULL; }
00568 
00569   virtual ~scv_tr_generator_base();
00570 
00571   // Get the names of hte begin and end attributes, as given in the
00572   // scv_tr_generator_base ctor:
00573   //
00574   const char* get_begin_attribute_name() const;
00575   const char* get_end_attribute_name() const;
00576 
00577   // Callbacks:
00578   //
00579   enum callback_reason { CREATE, DELETE };
00580 
00581   typedef int callback_h;
00582 
00583   typedef void callback_function(
00584     const scv_tr_generator_base& obj,
00585     callback_reason reason,
00586                 void* user_data_p);
00587 
00588   // Register a callback for scv_tr_generator creation/deletion.
00589   //
00590   static callback_h register_class_cb(
00591                 callback_function*,
00592                 void* user_data_p = NULL);
00593 
00594   // Remove a callback.
00595   //
00596   static void remove_callback(callback_h);
00597 
00598 
00599   // TBD: Need callbacks on specific transaction objects
00600 
00601 
00602   void print(ostream& o, int details=0, int indent=0) const;
00603   void show(int details=0, int indent=0) const;
00604   static void set_debug(int debug);
00605   static int get_debug();
00606 
00607   const char *get_name() const;
00608   const char *kind() const { return "scv_tr_generator"; }
00609 
00610   uint64 get_id() const;
00611 
00612   // Return the stream on which this transaction is defined:
00613   //
00614 
00615 // get_scv_tr_stream ==> get_tr_stream and check 
00616 
00617   const scv_tr_stream& get_scv_tr_stream() const;
00618 
00619   // Return the scv_extensions_if of the begin or end attributes.
00620   // These methods only return info about the attribute classes, and
00621   // do not contain valid values because they are not associated with
00622   // any particular transaction scv_tr_handle.
00623   //
00624   const scv_extensions_if* get_begin_exts_p() const;
00625   const scv_extensions_if* get_end_exts_p() const;
00626 
00627  private:
00628   _scv_tr_generator_core* _scv_tr_generator_core_p;
00629 
00630  public:
00631   scv_tr_handle _begin_transaction(
00632                 const scv_extensions_if*,
00633                 const sc_time&,
00634     scv_tr_relation_handle_t relation_handle,
00635                 const scv_tr_handle* other_handle_p = NULL) const;
00636 
00637   void _end_transaction(
00638                 const scv_tr_handle& t,
00639                 const scv_extensions_if*,
00640                 const sc_time& end_sc_time) const;
00641  public:
00642   // To be called only from scv_tr_generator:
00643   void _set_begin_exts_p(const scv_extensions_if*);
00644   void _set_end_exts_p(const scv_extensions_if*);
00645   void _process_callbacks();
00646 };
00647 
00648 // --------------------------------------------------------------------------
00649 
00650 template < class T_begin = _scv_tr_generator_default_data,
00651            class T_end   = _scv_tr_generator_default_data >
00652 class scv_tr_generator : public scv_tr_generator_base {
00653  public:
00654 
00655   // The scv_tr_generator class is used to define the kinds of transactions
00656   // that can be created on a stream.
00657   //
00658   // The scv_tr_generator ctor specifies the name of this scv_tr_generator,
00659   // the stream on which this scv_tr_generator is associated, and also
00660   // specifies the attributes of this scv_tr_generator that are defined at
00661   // the beginning and at the end of transactions of this scv_tr_generator.
00662   // For scalar begin and end attributes, you can explicitly give names 
00663   // to those attributes.
00664   //
00665   // If the T_begin or T_end template parameters are missing, then
00666   // this scv_tr_generatorwill record no attributes at the beginning
00667   // or at the end of transactions of this scv_tr_generator.
00668   // 
00669   // The template parameters must be scv_extensions.
00670   //
00671   // The begin_transaction() methods return scv_tr_handle objects
00672   // to transactions of this scv_tr_generator class.
00673   //
00674   // The end_transaction() methods end the transactions.
00675   // 
00676 
00677   // The scv_tr_generator ctor defines a scv_tr_generator on a stream.
00678   //
00679   // T_begin (template parameter) specifies the attributes that are
00680   //   defined at the beginning of the transaction.
00681   //
00682   // T_end (template parameter) specifies the attributes that are
00683   //   defined at the end of the transaction.
00684   //
00685   // name is the name of this scv_tr_generator.
00686   //
00687   // s is the scv_tr_stream in which this scv_tr_generator is defined.
00688   //
00689   scv_tr_generator(
00690   const char* name,
00691   scv_tr_stream& s,
00692   const char* begin_attribute_name = NULL,
00693   const char* end_attribute_name = NULL) :
00694     scv_tr_generator_base(
00695       name, s, begin_attribute_name, end_attribute_name),
00696     _begin_ext(scv_get_const_extensions(_tmp_begin_attributes)),
00697     _end_ext(scv_get_const_extensions(_tmp_end_attributes))
00698   {
00699     this->_set_begin_exts_p(&_begin_ext);
00700     this->_set_end_exts_p(&_end_ext);
00701     this->_process_callbacks();
00702   }
00703 
00704   scv_tr_generator() {}
00705 
00706   ~scv_tr_generator() {}
00707 
00708   // ------------------------------------------------------------------------
00709 
00710   // The begin_transaction methods start transactions of this
00711   // scv_tr_generator class.  The different versions of begin provide
00712   // various features.
00713   //
00714   // In all begin_transaction methods:
00715   //
00716   //   A scv_tr_handle object is returned.
00717   //
00718   //   The transaction is started on the scv_tr_stream of the scv_tr_generator
00719   //   object.
00720   //
00721 
00722 
00723   // This method starts a transaction with these characteristics:
00724   //
00725   //   The values of the attributes that are normally set at the beginning
00726   //   of the transaction will be set to "undefined".
00727   //
00728   //   This method is also used then this scv_tr_generator was defined to
00729   //   have no begin attributes.  (ie, the default was used for the T_begin
00730   //   template parameter.)
00731   // 
00732   //   The begin time of this transaction is the current simulation time.
00733   //
00734   scv_tr_handle begin_transaction()
00735   {
00736     return this->_begin_transaction(
00737   NULL,
00738   sc_time_stamp(),
00739   0);
00740   }
00741 
00742 
00743   // This method starts a transaction with these characteristics:
00744   //
00745   //   The values of the attributes that are normally set at the beginning
00746   //   of the transaction will be set to "undefined".
00747   //
00748   //   This method is also used then this scv_tr_generator was defined to
00749   //   have no begin attributes.  (ie, the default was used for the T_begin
00750   //   template parameter.)
00751   //
00752   //   The begin time of this transaction is the current simulation time.
00753   //
00754   //   The new transaction has the relation_handle or relation_name to
00755   //   other_transaction_handle.
00756   //
00757   scv_tr_handle begin_transaction(
00758   scv_tr_relation_handle_t relation_handle,
00759         const scv_tr_handle& other_transaction_handle)
00760   {
00761     return this->_begin_transaction(
00762   NULL,
00763   sc_time_stamp(),
00764   relation_handle,
00765   &other_transaction_handle);
00766   }
00767 
00768   scv_tr_handle begin_transaction(
00769   const char* relation_name,
00770         const scv_tr_handle& other_transaction_handle)
00771   {
00772     return this->_begin_transaction(
00773   NULL,
00774   sc_time_stamp(),
00775         get_scv_tr_stream().get_scv_tr_db()->create_relation(relation_name),
00776   &other_transaction_handle);
00777   }
00778 
00779 
00780   // This method starts a transaction with these characteristics:
00781   //
00782   //   The values of the begin attributes of this transaction are the
00783   //   values that are currently in the attribute_values argument.
00784   //
00785   //   The begin time of this transaction is the current simulation time.
00786   //
00787   scv_tr_handle begin_transaction(
00788   const T_begin& begin_attribute_values)
00789   {
00790     scv_extensions<T_begin> ext =
00791     scv_get_const_extensions(begin_attribute_values);
00792     return this->_begin_transaction(
00793   &ext,
00794   sc_time_stamp(),
00795   0);
00796   }
00797 
00798 
00799   // This method starts a transaction with these characteristics:
00800   //
00801   //   The values of the begin attributes of this transaction are the
00802   //   values that are currently in the attribute_values argument.
00803   //
00804   //   The begin time of this transaction is the current simulation time.
00805   //
00806   //   The new transaction has the "relation_name" to other_transaction_handle.
00807   //
00808   scv_tr_handle begin_transaction(
00809         const T_begin& begin_attribute_values,
00810         scv_tr_relation_handle_t relation_handle,
00811         const scv_tr_handle& other_transaction_handle)
00812   {
00813     scv_extensions<T_begin> ext =
00814                 scv_get_const_extensions(begin_attribute_values);
00815     return this->_begin_transaction(
00816   &ext,
00817   sc_time_stamp(),
00818   relation_handle,
00819   &other_transaction_handle);
00820   }
00821 
00822   scv_tr_handle begin_transaction(
00823         const T_begin& begin_attribute_values,
00824         const char* relation_name,
00825         const scv_tr_handle& other_transaction_handle)
00826   {
00827     scv_extensions<T_begin> ext =
00828                 scv_get_const_extensions(begin_attribute_values);
00829     return this->_begin_transaction(
00830   &ext,
00831   sc_time_stamp(),
00832         get_scv_tr_stream().get_scv_tr_db()->create_relation(relation_name),
00833   &other_transaction_handle);
00834   }
00835 
00836 
00837   // This method starts a transaction with these characteristics:
00838   //
00839   //   The values of the attributes that are normally set at the beginning
00840   //   of the transaction will be set to "undefined".
00841   //
00842   //   This method is also used then this scv_tr_generator was defined to
00843   //   have no begin attributes.  (ie, the default was used for the T_begin
00844   //   template parameter.)
00845   //
00846   //   The begin time of this transaction is specified by the begin_time
00847   //   argument.   This time must be less than or equal to the current
00848   //   simulation time.  This allows you to start a transaction in the past.
00849   //
00850   scv_tr_handle begin_transaction(
00851         const sc_time& begin_sc_time)
00852   {
00853     return this->_begin_transaction(
00854   NULL,
00855   begin_sc_time,
00856   0);
00857   }
00858 
00859 
00860   // This method starts a transaction with these characteristics:
00861   //
00862   //   The values of the attributes that are normally set at the beginning
00863   //   of the transaction will be set to "undefined".
00864   //
00865   //   This method is also used then this scv_tr_generator was defined to
00866   //   have no begin attributes.  (ie, the default was used for the T_begin
00867   //   template parameter.)
00868   //
00869   //   The begin time of this transaction is specified by the begin_time
00870   //   argument.   This time must be less than or equal to the current
00871   //   simulation time.  This allows you to start a transaction in the past.
00872   //
00873   //   The new transaction has the "relation_name" to other_transaction_handle.
00874   //
00875   scv_tr_handle begin_transaction(
00876         const sc_time& begin_sc_time,
00877         scv_tr_relation_handle_t relation_handle,
00878         const scv_tr_handle& other_transaction_handle)
00879   {
00880     return this->_begin_transaction(
00881   NULL,
00882   begin_sc_time,
00883   relation_handle,
00884   &other_transaction_handle);
00885   }
00886 
00887   scv_tr_handle begin_transaction(
00888         const sc_time& begin_sc_time,
00889         const char* relation_name,
00890         const scv_tr_handle& other_transaction_handle)
00891   {
00892     return this->_begin_transaction(
00893   NULL,
00894   begin_sc_time,
00895         get_scv_tr_stream().get_scv_tr_db()->create_relation(relation_name),
00896   &other_transaction_handle);
00897   }
00898 
00899 
00900   // This method starts a transaction with these characteristics:
00901   //
00902   //   The values of the begin attributes of this transaction are the
00903   //   values that are currently in the attribute_values argument.
00904   //
00905   //   The begin time of this transaction is specified by the begin_time
00906   //   argument.   This time must be less than or equal to the current
00907   //   simulation time.  This allows you to start a transaction in the past.
00908   //
00909   scv_tr_handle begin_transaction(
00910   const T_begin& begin_attribute_values,
00911   const sc_time& begin_sc_time)
00912   {
00913     scv_extensions<T_begin> ext =
00914                 scv_get_const_extensions(begin_attribute_values);
00915     return this->_begin_transaction(
00916   &ext,
00917   begin_sc_time,
00918   0);
00919   }
00920 
00921 
00922   // This method starts a transaction with these characteristics:
00923   //
00924   //   The values of the begin attributes of this transaction are the
00925   //   values that are currently in the attribute_values argument.
00926   //
00927   //   The begin time of this transaction is specified by the begin_time
00928   //   argument.   This time must be less than or equal to the current
00929   //   simulation time.  This allows you to start a transaction in the past.
00930   //
00931   scv_tr_handle begin_transaction(
00932         const T_begin& begin_attribute_values,
00933         const sc_time& begin_sc_time,
00934         scv_tr_relation_handle_t relation_handle,
00935         const scv_tr_handle& other_transaction_handle)
00936   {
00937     scv_extensions<T_begin> ext =
00938                 scv_get_const_extensions(begin_attribute_values);
00939     return this->_begin_transaction(
00940   &ext,
00941   begin_sc_time,
00942   relation_handle,
00943   &other_transaction_handle);
00944   }
00945 
00946   scv_tr_handle begin_transaction(
00947         const T_begin& begin_attribute_values,
00948         const sc_time& begin_sc_time,
00949         const char* relation_name,
00950         const scv_tr_handle& other_transaction_handle)
00951   {
00952     scv_extensions<T_begin> ext =
00953                 scv_get_const_extensions(begin_attribute_values);
00954     return this->_begin_transaction(
00955   &ext,
00956   begin_sc_time,
00957         get_scv_tr_stream().get_scv_tr_db()->create_relation(relation_name),
00958   &other_transaction_handle);
00959   }
00960 
00961   // ------------------------------------------------------------------------
00962 
00963   // End a transaction at the current simulation time.
00964   // The values of the attributes that are normally set at the end of
00965   // transaction, will be set to "undefined".  This method is also used
00966   // when this scv_tr_generator was defined to have no begin attributes.
00967   // (ie, the default was used for the T_begin template parameter.)
00968   //
00969   void end_transaction(
00970         const scv_tr_handle& t)
00971   {
00972     this->_end_transaction(t, NULL, sc_time_stamp());
00973   }
00974 
00975   // End a transaction at the current simulation time, and specify the
00976   // values of the end attributes.
00977   //
00978   void end_transaction(
00979         const scv_tr_handle& t,
00980   const T_end& end_attribute_values)
00981   {
00982     scv_extensions<T_end> ext = scv_get_const_extensions(end_attribute_values);
00983     this->_end_transaction(t, &ext, sc_time_stamp());
00984   }
00985 
00986   // End a transaction at a simulation time that is in the past.
00987   // The values of the attributes that are normally set at the end of
00988   // transaction, will be set to "undefined".  This method is also used
00989   // when this scv_tr_generator was defined to have no begin attributes.
00990   // (ie, the default was used for the T_begin template parameter.)
00991   //
00992   void end_transaction(
00993         const scv_tr_handle& t,
00994   const sc_time& end_sc_time)
00995   {
00996     this->_end_transaction(t, NULL, end_sc_time);
00997   }
00998 
00999   // End a transaction at a simulation time that is in the past, and
01000   // specify the values of the end attributes.
01001   //
01002   void end_transaction(
01003         const scv_tr_handle& t,
01004         const T_end& end_attribute_values,
01005   const sc_time& end_sc_time)
01006   {
01007     scv_extensions<T_end> ext = scv_get_const_extensions(end_attribute_values);
01008     this->_end_transaction(t, &ext, end_sc_time);
01009   }
01010 
01011   // ------------------------------------------------------------------------
01012 
01013  private:
01014     friend class scv_tr_handle;
01015     T_begin _tmp_begin_attributes;
01016     T_end _tmp_end_attributes;
01017     scv_extensions<T_begin> _begin_ext;
01018     scv_extensions<T_end> _end_ext;
01019 };
01020 
01021 // ----------------------------------------------------------------------------
01022 
01023 #endif  // SCV_TR_H
01024 

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