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

📄 sc_port.cpp

📁 system C源码 一种替代verilog的语言
💻 CPP
📖 第 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_port.cpp -- Base classes of all port classes.  Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21 *****************************************************************************//*****************************************************************************  MODIFICATION LOG - modifiers, enter your name, affiliation, date and  changes you are making here.      Name, Affiliation, Date: Andy Goodrich, Forte Design Systems                               Bishnupriya Bhattacharya, Cadence Design Systems,                               25 August, 2003  Description of Modification: phase callbacks      Name, Affiliation, Date: Andy Goodrich, Forte Design Systems	  						   12 December, 2005  Description of Modification: multiport binding policy changes     *****************************************************************************/// $Log: sc_port.cpp,v $// Revision 1.1.1.1  2006/12/15 20:31:35  acg// SystemC 2.2//// Revision 1.9  2006/02/02 20:43:09  acg//  Andy Goodrich: Added an existence linked list to sc_event_finder so that//  the dynamically allocated instances can be freed after port binding//  completes. This replaces the individual deletions in ~sc_bind_ef, as these//  caused an exception if an sc_event_finder instance was used more than//  once, due to a double freeing of the instance.//// Revision 1.7  2006/01/26 21:00:50  acg//  Andy Goodrich: conversion to use sc_event::notify(SC_ZERO_TIME) instead of//  sc_event::notify_delayed()//// Revision 1.6  2006/01/25 00:31:11  acg//  Andy Goodrich: Changed over to use a standard message id of//  SC_ID_IEEE_1666_DEPRECATION for all deprecation messages.//// Revision 1.5  2006/01/24 20:46:31  acg// Andy Goodrich: changes to eliminate use of deprecated features. For instance,// using notify(SC_ZERO_TIME) in place of notify_delayed().//// Revision 1.4  2006/01/13 20:41:59  acg// Andy Goodrich: Changes to add port registration to the things that are// checked when SC_NO_WRITE_CHECK is not defined.//// Revision 1.3  2006/01/13 18:47:42  acg// Added $Log command so that CVS comments are reproduced in the source.//#include "sysc/kernel/sc_simcontext.h"#include "sysc/kernel/sc_module.h"#include "sysc/kernel/sc_method_process.h"#include "sysc/kernel/sc_thread_process.h"#include "sysc/communication/sc_communication_ids.h"#include "sysc/utils/sc_utils_ids.h"#include "sysc/communication/sc_event_finder.h"#include "sysc/communication/sc_port.h"#include "sysc/communication/sc_signal_ifs.h"namespace sc_core {// ----------------------------------------------------------------------------//  STRUCT : sc_bind_elem// ----------------------------------------------------------------------------struct sc_bind_elem{    // constructors    sc_bind_elem();    explicit sc_bind_elem( sc_interface* interface_ );    explicit sc_bind_elem( sc_port_base* parent_ );    sc_interface* iface;    sc_port_base* parent;};// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII// constructorssc_bind_elem::sc_bind_elem(): iface( 0 ),  parent( 0 ){}sc_bind_elem::sc_bind_elem( sc_interface* interface_ ): iface( interface_ ),  parent( 0 ){}sc_bind_elem::sc_bind_elem( sc_port_base* parent_ ): iface( 0 ),  parent( parent_ ){}// ----------------------------------------------------------------------------//  STRUCT : sc_bind_ef// ----------------------------------------------------------------------------struct sc_bind_ef{    // constructor    sc_bind_ef( sc_process_b* , sc_event_finder* );    // destructor    ~sc_bind_ef();    sc_process_b* handle;    sc_event_finder* event_finder;};// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII// constructorsc_bind_ef::sc_bind_ef( sc_process_b* handle_,			sc_event_finder* event_finder_ ): handle( handle_ ),  event_finder( event_finder_ ){}// destructorsc_bind_ef::~sc_bind_ef(){}// ----------------------------------------------------------------------------//  STRUCT : sc_bind_info// ----------------------------------------------------------------------------struct sc_bind_info{    // constructor    explicit sc_bind_info( int max_size_, 	sc_port_policy policy_=SC_ONE_OR_MORE_BOUND );    // destructor    ~sc_bind_info();    int            max_size() const;    sc_port_policy policy() const;     int            size() const;    int                        m_max_size;    sc_port_policy             m_policy;    std::vector<sc_bind_elem*> vec;    bool                       has_parent;    int                        last_add;    bool                       is_leaf;    bool                       complete;    std::vector<sc_bind_ef*>   thread_vec;    std::vector<sc_bind_ef*>   method_vec;};// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII// constructorsc_bind_info::sc_bind_info( int max_size_, sc_port_policy policy_ ): m_max_size( max_size_ ),  m_policy( policy_ ),  has_parent( false ),  last_add( -1 ),  is_leaf( true ),  complete( false ){}// destructorsc_bind_info::~sc_bind_info(){    for( int i = size() - 1; i >= 0; -- i ) {	delete vec[i];    }}intsc_bind_info::max_size() const{    return m_max_size ? m_max_size : vec.size();}sc_port_policy sc_bind_info::policy() const{    return m_policy;}intsc_bind_info::size() const{    return vec.size();}// ----------------------------------------------------------------------------//  CLASS : sc_port_base////  Abstract base class for class sc_port_b.// ----------------------------------------------------------------------------// This method exists to get around a problem in VCC 6.0 where you cannot// have  a friend class that is templated. So sc_port_b<IF> calls this class// instead of sc_process_b::add_static_event.void sc_port_base::add_static_event(    sc_method_handle process_p, const sc_event& event ) const{    process_p->add_static_event( event );}void sc_port_base::add_static_event(    sc_thread_handle process_p, const sc_event& event ) const{    process_p->add_static_event( event );}// error reportingvoidsc_port_base::report_error( const char* id, const char* add_msg ) const{    char msg[BUFSIZ];    if( add_msg != 0 ) {	std::sprintf( msg, "%s: port '%s' (%s)", add_msg, name(), kind() );    } else {	std::sprintf( msg, "port '%s' (%s)", name(), kind() );    }    SC_REPORT_ERROR( id, msg );}// constructorssc_port_base::sc_port_base(     int max_size_, sc_port_policy policy ) :     sc_object( sc_gen_unique_name( "port" ) ),    m_bind_info( new sc_bind_info( max_size_, policy ) ){    simcontext()->get_port_registry()->insert( this );}sc_port_base::sc_port_base(     const char* name_, int max_size_, sc_port_policy policy ) :     sc_object( name_ ),    m_bind_info( new sc_bind_info( max_size_, policy ) ){    simcontext()->get_port_registry()->insert( this );}// destructorsc_port_base::~sc_port_base(){    simcontext()->get_port_registry()->remove( this );    if( m_bind_info != 0 ) {	delete m_bind_info;    }}// bind interface to this portvoidsc_port_base::bind( sc_interface& interface_ ){    if( m_bind_info == 0 ) {	// cannot bind an interface after elaboration	report_error( SC_ID_BIND_IF_TO_PORT_, "simulation running" );    }    m_bind_info->vec.push_back( new sc_bind_elem( &interface_ ) );        if( ! m_bind_info->has_parent ) {	// add (cache) the interface	add_interface( &interface_ );	m_bind_info->last_add ++;    }}// bind parent port to this portvoidsc_port_base::bind( this_type& parent_ ){    if( m_bind_info == 0 ) {	// cannot bind a parent port after elaboration	report_error( SC_ID_BIND_PORT_TO_PORT_, "simulation running" );    }    if( &parent_ == this ) {	report_error( SC_ID_BIND_PORT_TO_PORT_, "same port" );    }    // check if parent port is already bound to this port#if 0    for( int i = m_bind_info->size() - 1; i >= 0; -- i ) {	if( &parent_ == m_bind_info->vec[i]->parent ) {	    report_error( SC_ID_BIND_PORT_TO_PORT_, "already bound" );	}    }#endif //     m_bind_info->vec.push_back( new sc_bind_elem( &parent_ ) );    m_bind_info->has_parent = true;    parent_.m_bind_info->is_leaf = false;}// called by sc_port_registry::construction_done (null by default)void sc_port_base::before_end_of_elaboration() {}// called by elaboration_done (does nothing)voidsc_port_base::end_of_elaboration(){}// called by sc_port_registry::start_simulation (does nothing by default)void sc_port_base::start_of_simulation(){}// called by sc_port_registry::simulation_done (does nothing by default)void sc_port_base::end_of_simulation(){}// called by class sc_module for positional bindingintsc_port_base::pbind( sc_interface& interface_ ){    if( m_bind_info == 0 ) {	// cannot bind an interface after elaboration	report_error( SC_ID_BIND_IF_TO_PORT_, "simulation running" );    }    

⌨️ 快捷键说明

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