00001 // $Id: a00298.html,v 1.1 2009/01/07 19:29:56 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 typedef class tlm_event; 00023 00024 //---------------------------------------------------------------------- 00025 // CLASS tlm_fifo 00026 //---------------------------------------------------------------------- 00027 class tlm_fifo #(type T = int) extends tlm_fifo_base #(T); 00028 00029 const static string type_name = "tlm_fifo #(T)"; 00030 00031 //-------------------------------------------------------------------- 00032 // local data 00033 //-------------------------------------------------------------------- 00034 local mailbox #( T ) m; 00035 local int m_size; 00036 protected int m_pending_blocked_gets; 00037 00038 //-------------------------------------------------------------------- 00039 // constructor (new) 00040 //-------------------------------------------------------------------- 00041 function new(string name, ovm_component parent = null, int size = 1); 00042 super.new(name, parent); 00043 00044 m = new( size ); 00045 m_size = size; 00046 endfunction 00047 00048 virtual function string get_type_name(); 00049 return type_name; 00050 endfunction 00051 00052 function int size(); 00053 return m_size; 00054 endfunction 00055 00056 virtual function int used(); 00057 return m.num(); 00058 endfunction 00059 00060 function bit is_empty(); 00061 return (m.num() == 0); 00062 endfunction 00063 00064 function bit is_full(); 00065 return (m.num() == m_size); 00066 endfunction 00067 00068 task put( input T t ); 00069 m.put( t ); 00070 put_ap.write( t ); 00071 endtask 00072 00073 task get( output T t ); 00074 m_pending_blocked_gets++; 00075 m.get( t ); 00076 m_pending_blocked_gets--; 00077 get_ap.write( t ); 00078 endtask 00079 00080 task peek( output T t ); 00081 m.peek( t ); 00082 00083 get_ap.write( t ); 00084 endtask 00085 00086 function bit try_get( output T t ); 00087 if( !m.try_get( t ) ) begin 00088 return 0; 00089 end 00090 00091 get_ap.write( t ); 00092 return 1; 00093 endfunction 00094 00095 function bit try_peek( output T t ); 00096 if( !m.try_peek( t ) ) begin 00097 return 0; 00098 end 00099 00100 get_ap.write( t ); 00101 return 1; 00102 endfunction 00103 00104 function bit try_put( input T t ); 00105 if( !m.try_put( t ) ) begin 00106 return 0; 00107 end 00108 00109 put_ap.write( t ); 00110 return 1; 00111 endfunction 00112 00113 function bit can_put(); 00114 return m_size == 0 || m.num() < m_size; 00115 endfunction 00116 00117 function bit can_get(); 00118 return m.num() > 0 && m_pending_blocked_gets == 0; 00119 endfunction 00120 00121 function bit can_peek(); 00122 return m.num() > 0; 00123 endfunction 00124 00125 function void flush(); 00126 T t; 00127 bit r; 00128 00129 r = 1; 00130 while( r ) r = try_get( t ) ; 00131 00132 if( m.num() > 0 && m_pending_blocked_gets != 0 ) begin 00133 ovm_report_error("flush failed" , 00134 "there are blocked gets preventing the flush"); 00135 end 00136 00137 endfunction 00138 00139 endclass 00140 00141 //---------------------------------------------------------------------- 00142 // CLASS tlm_analysis_fifo 00143 //---------------------------------------------------------------------- 00144 00145 // An tlm_analysis_fifo is an unbounded tlm_fifo that also implements and 00146 // exports the write interfaces. 00147 // 00148 // It is very useful in objects such as scoreboards which need to be 00149 // connected to monitors. 00150 00151 class tlm_analysis_fifo #(type T = int) extends tlm_fifo #(T); 00152 00153 ovm_analysis_imp #(T, tlm_analysis_fifo #(T)) analysis_export; 00154 00155 function new(string name , ovm_component parent = null); 00156 super.new(name, parent, 0); // analysis fifo must be unbounded 00157 00158 analysis_export = new("analysis_export", this); 00159 00160 endfunction 00161 00162 const static string type_name = "tlm_analysis_fifo #(T)"; 00163 00164 virtual function string get_type_name(); 00165 return type_name; 00166 endfunction 00167 00168 function void write(input T t); 00169 void'(this.try_put(t)); // unbounded => must succeed 00170 endfunction 00171 00172 endclass
![]() Intelligent Design Verification Project: OVM, Revision: 2.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.5 Wed Jan 7 19:27:18 2009 |