sc_module_registry.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_module_registry.cpp -- Registry for all modules.
00021                             FOR INTERNAL USE ONLY.
00022 
00023   Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21
00024 
00025  *****************************************************************************/
00026 
00027 /*****************************************************************************
00028 
00029   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00030   changes you are making here.
00031 
00032       Name, Affiliation, Date: Andy Goodrich, Forte
00033                                Bishnupriya Bhattacharya, Cadence Design Systems,
00034                                25 August, 2003
00035   Description of Modification: phase callbacks
00036 
00037  *****************************************************************************/
00038 
00039 
00040 // $Log: sc_module_registry.cpp,v $
00041 // Revision 1.1.1.1  2006/12/15 20:31:37  acg
00042 // SystemC 2.2
00043 //
00044 // Revision 1.4  2006/01/26 21:04:54  acg
00045 //  Andy Goodrich: deprecation message changes and additional messages.
00046 //
00047 // Revision 1.3  2006/01/13 18:44:30  acg
00048 // Added $Log to record CVS changes into the source.
00049 //
00050 
00051 #include "sysc/kernel/sc_kernel_ids.h"
00052 #include "sysc/kernel/sc_module.h"
00053 #include "sysc/kernel/sc_module_registry.h"
00054 #include "sysc/kernel/sc_simcontext.h"
00055 
00056 namespace sc_core {
00057 
00058 // ----------------------------------------------------------------------------
00059 //  CLASS : sc_module_registry
00060 //
00061 //  Registry for all modules.
00062 //  FOR INTERNAL USE ONLY!
00063 // ----------------------------------------------------------------------------
00064 
00065 void
00066 sc_module_registry::insert( sc_module& module_ )
00067 {
00068     if( sc_is_running() ) {
00069     SC_REPORT_ERROR( SC_ID_INSERT_MODULE_, "simulation running" );
00070     }
00071 
00072 #ifdef DEBUG_SYSTEMC
00073     // check if module_ is already inserted
00074     for( int i = size() - 1; i >= 0; -- i ) {
00075     if( &module_ == m_module_vec[i] ) {
00076         SC_REPORT_ERROR( SC_ID_INSERT_MODULE_, "already inserted" );
00077     }
00078     }
00079 #endif
00080 
00081     // insert
00082     m_module_vec.push_back( &module_ );
00083 }
00084 
00085 void
00086 sc_module_registry::remove( sc_module& module_ )
00087 {
00088     int i;
00089     for( i = 0; i < size(); ++ i ) {
00090     if( &module_ == m_module_vec[i] ) {
00091         break;
00092     }
00093     }
00094     if( i == size() ) {
00095     SC_REPORT_ERROR( SC_ID_REMOVE_MODULE_, 0 );
00096     }
00097 
00098     // remove
00099     m_module_vec[i] = m_module_vec[size() - 1];
00100     m_module_vec.resize(m_module_vec.size()-1);
00101 }
00102 
00103 
00104 // constructor
00105 
00106 sc_module_registry::sc_module_registry( sc_simcontext& simc_ )
00107 : m_simc( &simc_ )
00108 {}
00109 
00110 
00111 // destructor
00112 
00113 sc_module_registry::~sc_module_registry()
00114 {}
00115 
00116 // called when construction is done
00117 
00118 void
00119 sc_module_registry::construction_done()
00120 {
00121     for( int i = 0; i < size(); ++ i ) {
00122     m_module_vec[i]->construction_done();
00123     }
00124 }
00125 
00126 // called when elaboration is done
00127 
00128 void
00129 sc_module_registry::elaboration_done()
00130 {
00131     bool error = false;
00132     for( int i = 0; i < size(); ++ i ) {
00133     m_module_vec[i]->elaboration_done( error );
00134     }
00135 }
00136 
00137 // called before simulation begins
00138 
00139 void
00140 sc_module_registry::start_simulation()
00141 {
00142     for( int i = 0; i < size(); ++ i ) {
00143     m_module_vec[i]->start_simulation();
00144     }
00145 }
00146 
00147 // called after simulation ends
00148 
00149 void
00150 sc_module_registry::simulation_done()
00151 {
00152     for( int i = 0; i < size(); ++ i ) {
00153     m_module_vec[i]->simulation_done();
00154     }
00155 }
00156 
00157 } // namespace sc_core
00158 // Taf!

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