00001 // $Id: ovm__if__container_8svh-source.html,v 1.1 2008/10/07 21:54:44 alex.marin Exp $ 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 int OVM_UNBOUNDED_CONNECTIONS = -1; 00023 00024 // This class exists because SV does not yet allow forward typedefs to 00025 // parameterized classes (ovm_port_base) 00026 virtual class ovm_port_base_base #(type IF = ovm_report_object) extends IF; 00027 00028 pure virtual function void set_if(int i = 0); 00029 00030 endclass 00031 00032 class ovm_if_container #(type IF=int); 00033 00034 typedef ovm_if_container #(IF) this_type; 00035 00036 local int m_min_size; 00037 local int m_max_size; // bounds on the number of IFs 00038 00039 // m_if_list holds the interfaces that (should) satisfy the 00040 // connectivity requirements of this. At the end of elaboration, 00041 // the size of this list must be between m_min_size and m_max_size 00042 00043 local IF m_if_list[$]; 00044 00045 function new(int min_size = 0, int max_size = 0); 00046 m_min_size = min_size; 00047 m_max_size = max_size; 00048 endfunction 00049 00050 //-------------------------------------------------------------------- 00051 // accessor functions 00052 //-------------------------------------------------------------------- 00053 00054 // returns the actual number of interfaces held 00055 function int size(); 00056 return m_if_list.size(); 00057 endfunction 00058 00059 // the maximum number of interfaces that can be held 00060 function int max_size(); 00061 return m_max_size; 00062 endfunction 00063 00064 // the minimum permissible number of interface that must be held by 00065 // the time elaboration is finished 00066 function int min_size(); 00067 return m_min_size; 00068 endfunction 00069 00070 function bit is_unbounded(); 00071 return (m_max_size == OVM_UNBOUNDED_CONNECTIONS); 00072 endfunction 00073 00074 function void copy(this_type c); 00075 for(int i = 0; i < c.m_if_list.size(); i++) 00076 m_if_list.push_back(c.m_if_list[i]); 00077 endfunction 00078 00079 //-------------------------------------------------------------------- 00080 // add_if 00081 //-------------------------------------------------------------------- 00082 function bit add_if(IF ifc); 00083 00084 //Check for already added interface 00085 for(int i=0; i<m_if_list.size(); ++i) 00086 if(m_if_list[i] == ifc) return 1; 00087 00088 if(!is_unbounded() && (m_if_list.size() >= m_max_size)) 00089 return 0; 00090 00091 m_if_list.push_back(ifc); 00092 return 1; 00093 00094 endfunction 00095 00096 //-------------------------------------------------------------------- 00097 // add_list 00098 //-------------------------------------------------------------------- 00099 function bit add_list(this_type c); 00100 00101 bit result; 00102 int unsigned i; 00103 00104 result = 1; 00105 00106 for(i = 0; i < c.m_if_list.size(); i++) begin 00107 result &= add_if(c.lookup_indexed_if(i)); 00108 end 00109 00110 return result; 00111 00112 endfunction 00113 00114 //-------------------------------------------------------------------- 00115 // lookup_indexed_if 00116 //-------------------------------------------------------------------- 00117 function IF lookup_indexed_if( int i = 0 ); 00118 if ( i < 0 || i >= m_if_list.size() ) begin 00119 return null; 00120 end 00121 else begin 00122 return m_if_list[i]; 00123 end 00124 endfunction 00125 00126 endclass
![]() Intelligent Design Verification Project: OVM, Revision: 1.1.0 |
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.4.6 Mon Sep 29 14:20:12 2008 |