00001 // $Id: ovm_port_base.svh 3 2008-03-05 03:07:32Z seanoboyle $ 00002 //---------------------------------------------------------------------- 00003 // Copyright 2007-2008 Mentor Graphics Corporation 00004 // Copyright 2007-2008 Cadence Design Systems, Inc. 00005 // All Rights Reserved Worldwide 00006 // 00007 // Licensed under the Apache License, Version 2.0 (the 00008 // "License"); you may not use this file except in 00009 // compliance with the License. You may obtain a copy of 00010 // the License at 00011 // 00012 // http://www.apache.org/licenses/LICENSE-2.0 00013 // 00014 // Unless required by applicable law or agreed to in 00015 // writing, software distributed under the License is 00016 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 00017 // CONDITIONS OF ANY KIND, either express or implied. See 00018 // the License for the specific language governing 00019 // permissions and limitations under the License. 00020 //---------------------------------------------------------------------- 00021 00022 `const string s_removed_id = "component has been removed"; 00023 `const string s_connect_id = "connect"; 00024 00025 //---------------------------------------------------------------------- 00026 // ovm_port_base 00027 // 00028 // ovm_port_base extends but does not implement IF 00029 // 00030 // IF is typically a TLM or analysis interface. This interface will 00031 // be implemented in ovm_<IF>_port, ovm_<IF>_export, or ovm_<IF>_imp. 00032 // 00033 // Mostly ovm_port_base delegates to m_connector. 00034 // 00035 //---------------------------------------------------------------------- 00036 virtual class ovm_port_base #(type IF = ovm_object) 00037 extends ovm_port_base_base #(IF); 00038 00039 typedef ovm_connector #( IF ) connector_type; 00040 typedef ovm_port_base #( IF ) this_type; 00041 00042 connector_type m_connector; 00043 int unsigned m_if_mask; 00044 string m_if_name; 00045 protected IF m_if; 00046 ovm_if_container #(IF) m_if_container; 00047 00048 function new( string name , ovm_component parent , 00049 ovm_port_type_e port_type , 00050 int min_size = 0 , int max_size = 1 ); 00051 set_name(name); 00052 m_connector = new( name, parent, port_type, 00053 min_size, max_size ); 00054 m_connector.port_h = this; 00055 m_if_container = m_connector.get_if_container(); 00056 00057 endfunction 00058 00059 // port->port, port->export/imp, export->export/imp connections 00060 00061 //-------------------------------------------------------------------- 00062 // connect 00063 //-------------------------------------------------------------------- 00064 function void connect( this_type provider ); 00065 string s; 00066 connector_type provider_connector; 00067 00068 // Check the provider interface mask against this (requirer) mask. 00069 // The provider must provide at least the set of interface functions 00070 // that the requirer requires. It may provide more, but that's the 00071 // minimumn needed for this connection. 00072 if( (provider.m_if_mask & m_if_mask) != m_if_mask) begin 00073 $sformat(s, "cannot connect provider of %s interface to a requirer of %s interface", 00074 provider.m_if_name, m_if_name); 00075 m_connector.ovm_report_error(s_connect_id, s); 00076 return; 00077 end 00078 00079 provider_connector = provider.m_connector; 00080 00081 if( m_connector.is_removed() ) begin 00082 00083 $sformat( s , "Ignoring attempted connection from %s to %s" , 00084 m_connector.m_name , provider_connector.m_name ); 00085 00086 m_connector.ovm_report_info( s_removed_id , s ); 00087 return; 00088 end 00089 00090 if( provider_connector.is_removed() ) begin 00091 00092 $sformat( s , "Ignoring attempted connection from %s to %s" , 00093 m_connector.m_name , provider_connector.m_name ); 00094 00095 provider_connector.ovm_report_info( s_removed_id , s ); 00096 00097 return; 00098 end 00099 00100 if( !m_connector.check_types( provider_connector ) || 00101 !m_connector.check_relationship( provider_connector ) ) begin 00102 00103 $sformat( s , "Cannot connect %s to %s" , 00104 m_connector.m_name , provider_connector.m_name ); 00105 00106 m_connector.ovm_report_error( s_connection_error_id , s ); 00107 00108 // unless action assoiated with s_connection_error_id determines 00109 // otherwise, make best attempt to complete connection 00110 00111 end 00112 00113 m_connector.update_connection_lists(provider_connector); 00114 00115 endfunction 00116 00117 //-------------------------------------------------------------------- 00118 // remove 00119 //-------------------------------------------------------------------- 00120 function void remove(); 00121 m_connector.remove(); 00122 endfunction 00123 00124 //-------------------------------------------------------------------- 00125 // size 00126 //-------------------------------------------------------------------- 00127 function int size(); 00128 return m_connector.m_if_container.size(); 00129 //return m_connector.size(); 00130 endfunction 00131 00132 //-------------------------------------------------------------------- 00133 // connect_to_if 00134 // 00135 // port/export -> old style if conenction 00136 //-------------------------------------------------------------------- 00137 function void connect_to_if( input IF _if ); 00138 assert( m_connector.add_if( _if ) ); 00139 endfunction 00140 00141 //-------------------------------------------------------------------- 00142 // lookup_indexed_if 00143 // 00144 // looks up ith index 00145 //-------------------------------------------------------------------- 00146 function IF lookup_indexed_if( int i = 0 ); 00147 return m_if_container.lookup_indexed_if( i ); 00148 endfunction 00149 00150 //-------------------------------------------------------------------- 00151 // set_if 00152 //-------------------------------------------------------------------- 00153 function void set_if(int i = 0); 00154 m_if = lookup_indexed_if(i); 00155 endfunction 00156 00157 //-------------------------------------------------------------------- 00158 // debug_connected_to 00159 // 00160 // recursive debug following RHS of requires->provides 00161 // end point is an imp 00162 //-------------------------------------------------------------------- 00163 function void debug_connected_to( int level = 0 , 00164 int max_level = -1 ); 00165 00166 m_connector.debug_connected_to( level , max_level ); 00167 00168 endfunction 00169 00170 //-------------------------------------------------------------------- 00171 // debug_provided_to 00172 // 00173 // recusrive debug following LHS of requires->provides 00174 // end point is a port 00175 //-------------------------------------------------------------------- 00176 function void debug_provided_to( int level = 0 , 00177 int max_level = -1 ); 00178 00179 m_connector.debug_provided_to( level , max_level ); 00180 00181 endfunction 00182 00183 `include "compatibility/urm_port_compatibility.svh" 00184 endclass
![]() Intelligent Design Verification Project: OVM, Revision: 1.0.1 |
Copyright (c) 2008 Intelligent Design Verification. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included here: http://www.intelligentdv.com/licenses/fdl.txt |
![]() Doxygen Version: 1.5.6 Sun Sep 21 13:53:50 2008 |