sc_signal.cpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003   The following code is derived, directly or indirectly, from the SystemC
00004   source code Copyright (c) 1996-2006 by all Contributors.
00005   All Rights reserved.
00006 
00007   The contents of this file are subject to the restrictions and limitations
00008   set forth in the SystemC Open Source License Version 2.4 (the "License");
00009   You may not use this file except in compliance with such restrictions and
00010   limitations. You may obtain instructions on how to receive a copy of the
00011   License at http://www.systemc.org/. Software distributed by Contributors
00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00013   ANY KIND, either express or implied. See the License for the specific
00014   language governing rights and limitations under the License.
00015 
00016  *****************************************************************************/
00017 
00018 /*****************************************************************************
00019 
00020   sc_signal.cpp -- The sc_signal<T> primitive channel class.
00021 
00022   Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21
00023 
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027 
00028   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00029   changes you are making here.
00030 
00031       Name, Affiliation, Date:
00032   Description of Modification:
00033     
00034  *****************************************************************************/
00035 
00036 /* 
00037 $Log: sc_signal.cpp,v $
00038 Revision 1.2  2007/04/02 17:24:30  acg
00039  Andy Goodrich: added check for null writer pointers in sc_signal invalid
00040  writer method.
00041 
00042 Revision 1.1.1.1  2006/12/15 20:31:35  acg
00043 SystemC 2.2
00044 
00045 Revision 1.7  2006/04/11 23:11:57  acg
00046   Andy Goodrich: Changes for reset support that only includes
00047   sc_cthread_process instances.
00048 
00049 Revision 1.6  2006/03/13 20:19:44  acg
00050  Andy Goodrich: changed sc_event instances into pointers to sc_event instances
00051  that are allocated as needed. This saves considerable storage for large
00052  numbers of signals, etc.
00053 
00054 Revision 1.5  2006/01/25 00:31:11  acg
00055  Andy Goodrich: Changed over to use a standard message id of
00056  SC_ID_IEEE_1666_DEPRECATION for all deprecation messages.
00057 
00058 Revision 1.4  2006/01/24 20:46:32  acg
00059 Andy Goodrich: changes to eliminate use of deprecated features. For instance,
00060 using notify(SC_ZERO_TIME) in place of notify_delayed().
00061 
00062 Revision 1.3  2006/01/18 21:42:26  acg
00063 Andy Goodrich: Changes for check writer support, and tightening up sc_clock
00064 port usage.
00065 
00066 Revision 1.2  2006/01/03 23:18:26  acg
00067 Changed copyright to include 2006.
00068 
00069 Revision 1.1.1.1  2005/12/19 23:16:43  acg
00070 First check in of SystemC 2.1 into its own archive.
00071 
00072 Revision 1.14  2005/09/15 23:01:51  acg
00073 Added std:: prefix to appropriate methods and types to get around
00074 issues with the Edison Front End.
00075 
00076 Revision 1.13  2005/05/08 19:04:06  acg
00077 Fix bug in concat_set(int64,off). Other changes from 2.1 examples usage.
00078 
00079 Revision 1.12  2005/04/04 00:15:51  acg
00080 Changes for directory name change to sys from systemc.
00081 Changes for sc_string going to std::string.
00082 Changes for sc_pvector going to std::vector.
00083 Changes for reference pools for bit and part selections.
00084 Changes for const sc_concatref support.
00085 
00086 Revision 1.10  2005/03/21 22:31:32  acg
00087 Changes to sc_core namespace.
00088 
00089 Revision 1.9  2004/09/27 21:02:54  acg
00090 Andy Goodrich - Forte Design Systems, Inc.
00091    - Added a $Log comment so that CVS checkin comments will appear in
00092      checked out source.
00093 
00094 */
00095 
00096 
00097 #include "sysc/communication/sc_communication_ids.h"
00098 #include "sysc/utils/sc_utils_ids.h"
00099 #include "sysc/communication/sc_signal.h"
00100 #include "sysc/datatypes/int/sc_signed.h"
00101 #include "sysc/datatypes/int/sc_unsigned.h"
00102 #include "sysc/datatypes/bit/sc_lv_base.h"
00103 #include "sysc/kernel/sc_reset.h"
00104 
00105 using sc_dt::sc_lv_base;
00106 using sc_dt::sc_signed;
00107 using sc_dt::sc_unsigned;
00108 using sc_dt::int64;
00109 using sc_dt::uint64;
00110 
00111 namespace sc_core {
00112 
00113 // to avoid code bloat in sc_signal<T>
00114 
00115 void
00116 sc_signal_invalid_writer( 
00117     sc_object* target, sc_object* first_writer, sc_object* second_writer )
00118 {
00119     char msg[BUFSIZ];
00120     const char* target_name = target->name();
00121     const char* target_kind = target->kind();
00122     const char* writer1_name = first_writer->name();
00123     const char* writer1_kind = first_writer->kind();
00124     const char* writer2_name;
00125     const char* writer2_kind;
00126     if ( second_writer )
00127     {
00128         writer2_name = second_writer->name();
00129         writer2_kind = second_writer->kind();
00130 
00131     std::sprintf( msg, "\n signal `%s' (%s)"
00132          "\n first driver `%s' (%s)"
00133          "\n second driver `%s' (%s)",
00134          target_name, target_kind, 
00135          writer1_name, writer1_kind, 
00136          writer2_name, writer2_kind );
00137     SC_REPORT_ERROR( SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, msg );
00138     }
00139 }
00140 
00141 
00142 // ----------------------------------------------------------------------------
00143 //  CLASS : sc_signal<bool>
00144 //
00145 //  Specialization of sc_signal<T> for type bool.
00146 // ----------------------------------------------------------------------------
00147 
00148 
00149 // reset support:
00150 
00151 sc_reset* sc_signal<bool>::is_reset() const
00152 {
00153     sc_reset* result_p;
00154     if ( !m_reset_p ) m_reset_p = new sc_reset( this );
00155     result_p = m_reset_p;
00156     return result_p;
00157 }
00158 
00159 // destructor
00160 
00161 sc_signal<bool>::~sc_signal()
00162 {
00163     if ( !m_change_event_p )  delete m_change_event_p;
00164     if ( !m_negedge_event_p ) delete m_negedge_event_p;
00165     if ( !m_posedge_event_p ) delete m_posedge_event_p;
00166     if ( m_reset_p )          delete m_reset_p;
00167 }
00168 
00169 
00170 // ----------------------------------------------------------------------------
00171 //  CLASS : sc_signal<sc_logic>
00172 //
00173 //  Specialization of sc_signal<T> for type sc_logic.
00174 // ----------------------------------------------------------------------------
00175 
00176 
00177 void sc_deprecated_get_data_ref()
00178 {
00179     static bool warn_get_data_ref_deprecated=true;
00180     if ( warn_get_data_ref_deprecated )
00181     {
00182         warn_get_data_ref_deprecated=false;
00183     SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,
00184         "get_data_ref() is deprecated, use read() instead" );
00185     }
00186 }
00187 
00188 void sc_deprecated_get_new_value()
00189 {
00190     static bool warn_new_value=true;
00191     if ( warn_new_value )
00192     {
00193         warn_new_value=false;
00194     SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,
00195         "sc_signal<T>::get_new_value() is deprecated");
00196     }
00197 }
00198 
00199 void sc_deprecated_trace()
00200 {
00201     static bool warn_trace_deprecated=true;
00202     if ( warn_trace_deprecated )
00203     {
00204         warn_trace_deprecated=false;
00205     SC_REPORT_INFO(SC_ID_IEEE_1666_DEPRECATION_,
00206         "sc_signal<T>::trace() is deprecated");
00207     }
00208 }
00209 
00210 } // namespace sc_core
00211 
00212 // Taf!

Generated on Wed Jan 21 15:32:06 2009 for SystemC by  doxygen 1.5.5