00001 // $Id: ovm__sequence__builtin_8svh-source.html,v 1.1 2008/10/07 21:54:08 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 `ifndef OVM_SEQUENCE_BUILTIN_SVH 00023 `define OVM_SEQUENCE_BUILTIN_SVH 00024 00025 `include "methodology/ovm_meth_defines.svh" 00026 00027 //------------------------------------------------------------------------------ 00028 // 00029 // CLASS: ovm_random_sequence 00030 // 00031 //------------------------------------------------------------------------------ 00032 00033 class ovm_random_sequence extends ovm_sequence #(ovm_sequence_item); 00034 00035 rand protected int unsigned l_count; 00036 local int unsigned l_exhaustive_seq_kind; 00037 local int unsigned max_kind; 00038 rand local int unsigned l_kind; 00039 protected bit m_success; 00040 00041 // new 00042 // --- 00043 00044 function new(string name="ovm_random_sequence"); 00045 super.new(name); 00046 endfunction 00047 00048 00049 // body 00050 // ---- 00051 00052 task body(); 00053 pick_sequence.constraint_mode(0); 00054 if (m_sequencer.count == -1) begin 00055 assert(randomize(l_count) with { l_count > 0 && l_count < 00056 m_sequencer.max_random_count; }); 00057 m_sequencer.count = l_count; 00058 end 00059 else 00060 l_count = m_sequencer.count; 00061 max_kind = m_sequencer.sequences.size(); 00062 l_exhaustive_seq_kind = m_sequencer.get_seq_kind("ovm_exhaustive_sequence"); 00063 repeat (l_count) begin 00064 assert(randomize(l_kind) with { l_kind > l_exhaustive_seq_kind && 00065 l_kind < max_kind; }); 00066 do_sequence_kind(l_kind); 00067 end 00068 m_sequencer.m_random_count++; 00069 pick_sequence.constraint_mode(1); 00070 endtask 00071 00072 00073 //Implement data functions 00074 function void do_copy (ovm_object rhs); 00075 ovm_random_sequence seq; 00076 if(rhs==null) return; 00077 if(!$cast(seq, rhs)) return; 00078 l_count = seq.l_count; 00079 endfunction 00080 00081 function bit do_compare (ovm_object rhs, ovm_comparer comparer); 00082 ovm_random_sequence seq; 00083 do_compare = 1; 00084 if(rhs==null) return 0; 00085 if(!$cast(seq, rhs)) return 0; 00086 do_compare &= comparer.compare_field_int("l_count", l_count, seq.l_count, 00087 $bits(l_count)); 00088 endfunction 00089 00090 function void do_print (ovm_printer printer); 00091 printer.print_field("l_count", l_count, $bits(l_count)); 00092 endfunction 00093 00094 function void do_record (ovm_recorder recorder); 00095 recorder.record_field("l_count", l_count, $bits(l_count)); 00096 endfunction // void 00097 00098 function ovm_object create (string name=""); 00099 ovm_random_sequence i; i=new(name); 00100 return i; 00101 endfunction 00102 00103 virtual function string get_type_name(); 00104 return "ovm_random_sequence"; 00105 endfunction 00106 00107 // Macro for factory creation 00108 `ovm_object_registry(ovm_random_sequence, "ovm_random_sequence") 00109 00110 endclass 00111 00112 //------------------------------------------------------------------------------ 00113 // 00114 // CLASS: ovm_exhaustive_sequence 00115 // 00116 //------------------------------------------------------------------------------ 00117 00118 class ovm_exhaustive_sequence extends ovm_sequence #(ovm_sequence_item); 00119 00120 rand protected int unsigned l_count; 00121 local int unsigned l_exhaustive_seq_kind; 00122 local int unsigned max_kind; 00123 randc local bit[9:0] l_kind; 00124 protected bit m_success; 00125 00126 // new 00127 // --- 00128 00129 function new(string name="ovm_exhaustive_sequence"); 00130 super.new(name); 00131 endfunction 00132 00133 00134 // body 00135 // ---- 00136 00137 task body(); 00138 int i; 00139 00140 pick_sequence.constraint_mode(0); 00141 //$display("In exhaustive sequence body, num_sequences: %0d", m_sequencer.num_sequences()); 00142 00143 00144 //for (i = 0; i < m_sequencer.num_sequences(); i++ ) begin 00145 // $display("seq: %0d: %s", i, m_sequencer.sequences[i]); 00146 // $display("get_seq_kind[%s]: %0d", m_sequencer.sequences[i], get_seq_kind(m_sequencer.sequences[i])); 00147 //end 00148 00149 00150 l_count = m_sequencer.sequences.size() - 2; 00151 max_kind = m_sequencer.sequences.size(); 00152 l_exhaustive_seq_kind = m_sequencer.get_seq_kind("ovm_exhaustive_sequence"); 00153 repeat (l_count) begin 00154 //$display ("In repeat loop"); 00155 00156 assert(randomize(l_kind) with { l_kind > l_exhaustive_seq_kind && 00157 l_kind < max_kind; }); // l_kind is randc 00158 00159 //$display ("Chosen l_kind: %0d", l_kind); 00160 do_sequence_kind(l_kind); 00161 end 00162 m_sequencer.m_exhaustive_count++; 00163 pick_sequence.constraint_mode(1); 00164 endtask 00165 00166 00167 //Implement data functions 00168 function void do_copy (ovm_object rhs); 00169 ovm_exhaustive_sequence seq; 00170 if(rhs==null) return; 00171 if(!$cast(seq, rhs)) return; 00172 l_count = seq.l_count; 00173 endfunction 00174 00175 function bit do_compare (ovm_object rhs, ovm_comparer comparer); 00176 ovm_exhaustive_sequence seq; 00177 do_compare = 1; 00178 if(rhs==null) return 0; 00179 if(!$cast(seq, rhs)) return 0; 00180 do_compare &= comparer.compare_field_int("l_count", l_count, seq.l_count, 00181 $bits(l_count)); 00182 endfunction 00183 00184 function void do_print (ovm_printer printer); 00185 printer.print_field("l_count", l_count, $bits(l_count)); 00186 endfunction 00187 00188 function void do_record (ovm_recorder recorder); 00189 recorder.record_field("l_count", l_count, $bits(l_count)); 00190 endfunction // void 00191 00192 function ovm_object create (string name=""); 00193 ovm_exhaustive_sequence i; i=new(name); 00194 return i; 00195 endfunction 00196 00197 virtual function string get_type_name(); 00198 return "ovm_exhaustive_sequence"; 00199 endfunction 00200 00201 // Macro for factory creation 00202 `ovm_object_registry(ovm_exhaustive_sequence, "ovm_exhaustive_sequence") 00203 00204 endclass 00205 00206 //------------------------------------------------------------------------------ 00207 // 00208 // CLASS: ovm_simple_sequence 00209 // 00210 //------------------------------------------------------------------------------ 00211 00212 class ovm_simple_sequence extends ovm_sequence #(ovm_sequence_item); 00213 00214 protected rand ovm_sequence_item item; 00215 00216 // new 00217 // --- 00218 function new (string name="ovm_simple_sequence"); 00219 super.new(name); 00220 endfunction 00221 00222 // body 00223 // ---- 00224 task body(); 00225 `ovm_do(item) 00226 m_sequencer.m_simple_count++; 00227 endtask 00228 00229 function ovm_object create (string name=""); 00230 ovm_simple_sequence i; 00231 i=new(name); 00232 return i; 00233 endfunction 00234 00235 virtual function string get_type_name(); 00236 return "ovm_simple_sequence"; 00237 endfunction 00238 00239 // Macro for factory creation 00240 `ovm_object_registry(ovm_simple_sequence, "ovm_simple_sequence") 00241 00242 endclass 00243 00244 `endif // OVM_SEQUENCE_BUILTIN_SVH
![]() 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:23:30 2008 |