Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages | Examples

ac_reg.cpp

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 
00003 /*  ArchC Register Library for the ArchC architecture simulators
00004     Copyright (C) 2002-2004  The ArchC Team
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Lesser General Public
00008     License as published by the Free Software Foundation; either
00009     version 2.1 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Lesser General Public License for more details.
00015 */
00016 
00017 /********************************************************/
00018 /* Register class                                       */
00019 /* Author:  Sandro Rigo                                 */
00020 /*                                                      */
00021 /*                                                      */
00022 /* The ArchC Team                                       */
00023 /* Computer Systems Laboratory (LSC)                    */
00024 /* IC-UNICAMP                                           */
00025 /* http://www.lsc.ic.unicamp.br                         */
00026 /********************************************************/
00027 
00029 
00035 /************************************************
00036  * Author: Sandro Rigo
00037  ************************************************/
00039 
00040 #include "ac_resources.H"
00041 #include "ac_reg.H"
00042 
00044 export template<class T> const T& ac_reg<T>::read( ) const  { 
00045 
00046 #ifdef AC_STATS  
00047   ac_resources::ac_sim_stats.add_access(name);
00048 #endif
00049 
00050   return Data; 
00051 }
00052 
00054 export template<class T> void ac_reg<T>::write( T datum ) { 
00055 
00056 #ifdef AC_VERBOSE
00057   changes.push_back( change_log(0, datum , sc_simulation_time()));
00058 #endif
00059   
00060   Data = datum;
00061 
00062  
00063 #ifdef AC_STATS  
00064   ac_resources::ac_sim_stats.add_access(name);
00065 #endif
00066 
00067 
00068 }
00069 
00070 #ifdef AC_DELAY
00071 
00072 export template<class T> void ac_reg<T>::write( T datum, unsigned time ) { 
00073 
00074   delays.push_back( change_log( 0, datum, (time * ac_resources::time_step) + ac_resources::time_step + sc_simulation_time()));
00075 
00076 }
00077 
00079 template<class T> void ac_reg<T>::commit_delays( double time ){
00080   log_list::iterator itor;
00081     
00082   itor = delays.begin();
00083   while( delays.size() && (itor->time <= time) ){
00084     write( itor->value );
00085     itor = delays.erase( itor);
00086   }
00087 }
00088 #endif
00089 
00090 
00091 
00092 //Mixed-Mode Arithmetic operators
00093 
00094 // //!ac_reg + Type T
00095 // template<class T>ac_reg<T> ac_reg<T>::operator+ ( ac_reg<T> r, const T d ){ 
00096 //      ac_reg<T> res=r;
00097 //      return r += d;
00098 // }
00099 
00100 //   //!ac_reg - Type T
00101 //   T operator - ( const T d ){ 
00102    
00103 //     return ( read() - d );
00104 //   }
00105 
00106 //   //!ac_reg * Type T
00107 //   T operator * ( const T d ){ 
00108     
00109 //     return( read() * d );
00110 //   }
00111 
00112 //   //!ac_reg / Type T
00113 //   T operator / ( const T d ){ 
00114     
00115 //     return ( read() / d );
00116 //   }

Generated on Thu Jun 24 08:30:05 2004 for ArchC by doxygen 1.3.4