⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sc_module.h

📁 system C源码 一种替代verilog的语言
💻 H
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************  The following code is derived, directly or indirectly, from the SystemC  source code Copyright (c) 1996-2006 by all Contributors.  All Rights reserved.  The contents of this file are subject to the restrictions and limitations  set forth in the SystemC Open Source License Version 2.4 (the "License");  You may not use this file except in compliance with such restrictions and  limitations. You may obtain instructions on how to receive a copy of the  License at http://www.systemc.org/. Software distributed by Contributors  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF  ANY KIND, either express or implied. See the License for the specific  language governing rights and limitations under the License. *****************************************************************************//*****************************************************************************  sc_module.h -- Base class of all hierarchical modules and channels.  Original Author: Stan Y. Liao, Synopsys, Inc.                   Martin Janssen, Synopsys, Inc. *****************************************************************************//*****************************************************************************  MODIFICATION LOG - modifiers, enter your name, affiliation, date and  changes you are making here.      Name, Affiliation, Date: Ali Dasdan, Synopsys, Inc.  Description of Modification: - Implementation of operator() and operator,                                 positional connection method.                               - Implementation of error checking in                                 operator<<'s.                               - Implementation of the function test_module_prm.                               - Implementation of set_stack_size().      Name, Affiliation, Date: Gene Bushuyev, Synopsys, Inc.  Description of Modification: - Change implementation for VC6.      Name, Affiliation, Date: Andy Godorich, Forte                               Bishnupriya Bhattacharya, Cadence Design Systems,                               25 August, 2003  Description of Modification: inherit from sc_process_host as a part of                               implementing dynamic processes *****************************************************************************/// $Log: sc_module.h,v $// Revision 1.3  2007/03/14 17:48:04  acg//  Andy Goodrich: Fixed this-> usage in process macros.//// Revision 1.2  2007/01/24 20:14:12  acg//  Andy Goodrich: improved comment about using this-> in the macros that//  access sensitive.//// Revision 1.1.1.1  2006/12/15 20:31:37  acg// SystemC 2.2//// Revision 1.7  2006/04/11 23:13:21  acg//   Andy Goodrich: Changes for reduced reset support that only includes//   sc_cthread, but has preliminary hooks for expanding to method and thread//   processes also.//// Revision 1.6  2006/03/15 17:53:34  acg//  Andy Goodrich, Forte Design//  Reordered includes to pick up <cassert> for use by sc_process_name.h//// Revision 1.5  2006/03/14 23:56:58  acg//   Andy Goodrich: This fixes a bug when an exception is thrown in//   sc_module::sc_module() for a dynamically allocated sc_module//   object. We are calling sc_module::end_module() on a module that has//   already been deleted. The scenario runs like this:////   a) the sc_module constructor is entered//   b) the exception is thrown//   c) the exception processor deletes the storage for the sc_module//   d) the stack is unrolled causing the sc_module_name instance to be deleted//   e) ~sc_module_name() calls end_module() with its pointer to the sc_module//   f) because the sc_module has been deleted its storage is corrupted,//      either by linking it to a free space chain, or by reuse of some sort//   g) the m_simc field is garbage//   h) the m_object_manager field is also garbage//   i) an exception occurs////   This does not happen for automatic sc_module instances since the//   storage for the module is not reclaimed its just part of the stack.////   I am fixing this by having the destructor for sc_module clear the//   module pointer in its sc_module_name instance. That cuts things at//   step (e) above, since the pointer will be null if the module has//   already been deleted. To make sure the module stack is okay, I call//   end-module() in ~sc_module in the case where there is an//   sc_module_name pointer lying around.//// Revision 1.4  2006/01/24 20:49:05  acg// Andy Goodrich: changes to remove the use of deprecated features within the// simulator, and to issue warning messages when deprecated features are used.//// Revision 1.3  2006/01/13 18:44:30  acg// Added $Log to record CVS changes into the source.//#ifndef SC_MODULE_H#define SC_MODULE_H#include "sysc/kernel/sc_kernel_ids.h"#include "sysc/kernel/sc_process.h"#include "sysc/kernel/sc_module_name.h"#include "sysc/kernel/sc_sensitive.h"#include "sysc/kernel/sc_time.h"#include "sysc/kernel/sc_wait.h"#include "sysc/kernel/sc_wait_cthread.h"#include "sysc/kernel/sc_process.h"#include "sysc/kernel/sc_process_handle.h"#include "sysc/utils/sc_list.h"#include "sysc/utils/sc_string.h"namespace sc_core {class sc_name_gen;template<class T> class sc_in;template<class T> class sc_signal;// ----------------------------------------------------------------------------//  STRUCT : sc_bind_proxy////  Struct for temporarily storing a pointer to an interface or port.//  Used for positional binding.// ----------------------------------------------------------------------------struct sc_bind_proxy{    sc_interface* iface;    sc_port_base* port;        sc_bind_proxy();    sc_bind_proxy( sc_interface& );    sc_bind_proxy( sc_port_base& );};extern const sc_bind_proxy SC_BIND_PROXY_NIL;// ----------------------------------------------------------------------------//  CLASS : sc_module////  Base class for all structural entities.// ----------------------------------------------------------------------------class sc_module: public sc_object, public sc_process_host{    friend class sc_module_name;    friend class sc_module_registry;    friend class sc_object;    friend class sc_port_registry;	friend class sc_process_b;    friend class sc_simcontext;public:    sc_simcontext* sc_get_curr_simcontext()	{ return simcontext(); }    // to generate unique names for objects in an MT-Safe way    const char* gen_unique_name( const char* basename_, bool preserve_first );    virtual const char* kind() const        { return "sc_module"; }protected:      // called by construction_done     virtual void before_end_of_elaboration();    void construction_done();    // called by elaboration_done (does nothing by default)    virtual void end_of_elaboration();    void elaboration_done( bool& );    // called by start_simulation (does nothing by default)    virtual void start_of_simulation();    void start_simulation();    // called by simulation_done (does nothing by default)    virtual void end_of_simulation();    void simulation_done();    void sc_module_init();    // constructor    sc_module( const char* nm );    sc_module( const std::string& nm );    sc_module( const sc_module_name& nm ); /* for those used to old style */    sc_module();public:    // destructor    virtual ~sc_module();    // positional binding methods    sc_module& operator << ( sc_interface& );    sc_module& operator << ( sc_port_base& );    sc_module& operator , ( sc_interface& interface_ )        { return operator << ( interface_ ); }    sc_module& operator , ( sc_port_base& port_ )        { return operator << ( port_ ); }    // operator() is declared at the end of the class.    const ::std::vector<sc_object*>& get_child_objects() const;protected:    void add_child_object( sc_object* );    void remove_child_object( sc_object* );    // this must be called by user-defined modules    void end_module();    // to prevent initialization for SC_METHODs and SC_THREADs    void dont_initialize();    // positional binding code - used by operator ()    void positional_bind( sc_interface& );    void positional_bind( sc_port_base& );    // set reset sensitivity for SC_CTHREADs    void reset_signal_is( const sc_in<bool>& port, bool level );    void reset_signal_is( const sc_signal_in_if<bool>& iface, bool level );    // static sensitivity for SC_THREADs and SC_CTHREADs    void wait()        { ::sc_core::wait( simcontext() ); }    // dynamic sensitivity for SC_THREADs and SC_CTHREADs    void wait( const sc_event& e )        { ::sc_core::wait( e, simcontext() ); }    void wait( sc_event_or_list& el )	{ ::sc_core::wait( el, simcontext() ); }    void wait( sc_event_and_list& el )	{ ::sc_core::wait( el, simcontext() ); }    void wait( const sc_time& t )        { ::sc_core::wait( t, simcontext() ); }    void wait( double v, sc_time_unit tu )        { ::sc_core::wait( sc_time( v, tu, simcontext() ), simcontext() ); }    void wait( const sc_time& t, const sc_event& e )        { ::sc_core::wait( t, e, simcontext() ); }    void wait( double v, sc_time_unit tu, const sc_event& e )        { ::sc_core::wait( 		sc_time( v, tu, simcontext() ), e, simcontext() ); }    void wait( const sc_time& t, sc_event_or_list& el )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -