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

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-2004 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.3 (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 #include "systemc/kernel/sc_kernel_ids.h"
00041 #include "systemc/kernel/sc_module.h"
00042 #include "systemc/kernel/sc_module_registry.h"
00043 #include "systemc/kernel/sc_simcontext.h"
00044 
00045 
00046 // ----------------------------------------------------------------------------
00047 //  CLASS : sc_module_registry
00048 //
00049 //  Registry for all modules.
00050 //  FOR INTERNAL USE ONLY!
00051 // ----------------------------------------------------------------------------
00052 
00053 void
00054 sc_module_registry::insert( sc_module& module_ )
00055 {
00056     if( m_simc->is_running() ) {
00057   SC_REPORT_ERROR( SC_ID_INSERT_MODULE_, "simulation running" );
00058     }
00059 
00060 #ifdef DEBUG_SYSTEMC
00061     // check if module_ is already inserted
00062     for( int i = size() - 1; i >= 0; -- i ) {
00063   if( &module_ == m_module_vec[i] ) {
00064       SC_REPORT_ERROR( SC_ID_INSERT_MODULE_, "already inserted" );
00065   }
00066     }
00067 #endif
00068 
00069     // insert
00070     m_module_vec.push_back( &module_ );
00071 }
00072 
00073 void
00074 sc_module_registry::remove( sc_module& module_ )
00075 {
00076     int i;
00077     for( i = 0; i < size(); ++ i ) {
00078   if( &module_ == m_module_vec[i] ) {
00079       break;
00080   }
00081     }
00082     if( i == size() ) {
00083   SC_REPORT_ERROR( SC_ID_REMOVE_MODULE_, 0 );
00084     }
00085 
00086     // remove
00087     m_module_vec[i] = m_module_vec[size() - 1];
00088     m_module_vec.decr_count();
00089 }
00090 
00091 
00092 // constructor
00093 
00094 sc_module_registry::sc_module_registry( sc_simcontext& simc_ )
00095 : m_simc( &simc_ )
00096 {}
00097 
00098 
00099 // destructor
00100 
00101 sc_module_registry::~sc_module_registry()
00102 {}
00103 
00104 // called when construction is done
00105 
00106 void
00107 sc_module_registry::construction_done()
00108 {
00109     for( int i = 0; i < size(); ++ i ) {
00110   m_module_vec[i]->construction_done();
00111     }
00112 }
00113 
00114 // called when elaboration is done
00115 
00116 void
00117 sc_module_registry::elaboration_done()
00118 {
00119     bool error = false;
00120     for( int i = 0; i < size(); ++ i ) {
00121   m_module_vec[i]->elaboration_done( error );
00122     }
00123 }
00124 
00125 // called before simulation begins
00126 
00127 void
00128 sc_module_registry::start_simulation()
00129 {
00130     for( int i = 0; i < size(); ++ i ) {
00131   m_module_vec[i]->start_simulation();
00132     }
00133 }
00134 
00135 // called after simulation ends
00136 
00137 void
00138 sc_module_registry::simulation_done()
00139 {
00140     for( int i = 0; i < size(); ++ i ) {
00141   m_module_vec[i]->simulation_done();
00142     }
00143 }
00144 
00145 // Taf!

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