00001 // 00002 // ------------------------------------------------------------- 00003 // Copyright 2004-2008 Synopsys, Inc. 00004 // All Rights Reserved Worldwide 00005 // 00006 // Licensed under the Apache License, Version 2.0 (the 00007 // "License"); you may not use this file except in 00008 // compliance with the License. You may obtain a copy of 00009 // the License at 00010 // 00011 // http://www.apache.org/licenses/LICENSE-2.0 00012 // 00013 // Unless required by applicable law or agreed to in 00014 // writing, software distributed under the License is 00015 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 00016 // CONDITIONS OF ANY KIND, either express or implied. See 00017 // the License for the specific language governing 00018 // permissions and limitations under the License. 00019 // ------------------------------------------------------------- 00020 // 00021 00022 00023 virtual class vmm_ral_block_or_sys; 00024 static vmm_log log = new("RAL", "Block/Sys"); 00025 00026 vmm_ral::path_e default_access = vmm_ral::DEFAULT; 00027 00028 local bit locked; 00029 00030 local string name; 00031 local string typename; 00032 00033 local string domains[]; 00034 local string in_domains[]; // For each domain 00035 local int unsigned n_bytes[]; // For each domain 00036 local vmm_ral::endianness_e endian[]; // For each domain 00037 local bit [`VMM_RAL_ADDR_WIDTH-1:0] base_addr[]; // For each domain 00038 local string constr[]; // Constraint blocks 00039 00040 local vmm_ral_sys parent; 00041 protected vmm_ral_access ral_access; 00042 00043 local bit no_cover; 00044 local bit cover_on; 00045 00046 extern function new(vmm_ral_sys parent, 00047 string block_or_sys, 00048 string name, 00049 string typename, 00050 int unsigned n_bytes, 00051 vmm_ral::endianness_e endian, 00052 bit [`VMM_RAL_ADDR_WIDTH-1:0] base_addr, 00053 string domain = "", 00054 bit cover_on = 1); 00055 00056 /*local*/ extern virtual function void Xlock_modelX(); 00057 /*local*/ extern function bit Xis_lockedX(); 00058 /*local*/ extern virtual function void add_domain(int unsigned n_bytes, 00059 vmm_ral::endianness_e endian, 00060 string domain); 00061 /*local*/ extern virtual function void map_domain(string domain, 00062 string in_domain, 00063 bit [`VMM_RAL_ADDR_WIDTH-1:0] base_addr); 00064 /*local*/ extern virtual function void Xregister_ral_accessX(vmm_ral_access access); 00065 /*local*/ extern function void Xadd_constraintsX(string name); 00066 00067 extern virtual function string get_name(); 00068 extern virtual function string get_type(); 00069 extern virtual function string get_fullname(); 00070 extern function void get_domains(ref string names[]); 00071 extern virtual function vmm_ral_sys get_parent(); 00072 extern virtual function bit [`VMM_RAL_ADDR_WIDTH-1:0] get_base_addr(string domain = ""); 00073 extern virtual function int unsigned get_n_bytes(string domain = ""); 00074 extern virtual function vmm_ral::endianness_e get_endian(string domain = ""); 00075 extern virtual function vmm_ral::path_e get_default_access(); 00076 extern virtual function string get_parent_domain(string domain = ""); 00077 extern virtual function string get_external_domain(string domain = ""); 00078 00079 extern virtual function void display(string prefix = "", 00080 string domain = ""); 00081 extern virtual function string psdisplay(string prefix = "", 00082 string domain = ""); 00083 00084 extern virtual function void get_fields(ref vmm_ral_field fields[], 00085 input string domain = ""); 00086 extern virtual function vmm_ral_field get_field_by_name(string name); 00087 00088 extern virtual function void get_registers(ref vmm_ral_reg regs[], 00089 input string domain = ""); 00090 extern virtual function void get_virtual_registers(ref vmm_ral_vreg vregs[], 00091 input string domain = ""); 00092 extern virtual function vmm_ral_reg get_reg_by_name(string name); 00093 extern virtual function vmm_ral_reg get_reg_by_offset(bit [`VMM_RAL_ADDR_WIDTH-1:0] offset, 00094 string domain = ""); 00095 00096 extern virtual function void get_memories(ref vmm_ral_mem mems[], 00097 input string domain = ""); 00098 extern virtual function vmm_ral_mem get_mem_by_name(string name); 00099 extern virtual function vmm_ral_mem get_mem_by_offset(bit [`VMM_RAL_ADDR_WIDTH-1:0] offset, 00100 string domain = ""); 00101 00102 extern virtual function void get_constraints(ref string names[]); 00103 00104 extern virtual function bit set_cover(bit is_on); 00105 extern virtual function bit is_cover_on(); 00106 00107 extern virtual function void reset(string domain = "", 00108 vmm_ral::reset_e kind = vmm_ral::HARD); 00109 extern virtual function bit needs_update(); 00110 extern virtual task update(output vmm_rw::status_e status, 00111 input vmm_ral::path_e path = vmm_ral::DEFAULT); 00112 extern virtual task mirror(output vmm_rw::status_e status, 00113 input vmm_ral::check_e check = vmm_ral::QUIET, 00114 input vmm_ral::path_e path = vmm_ral::DEFAULT); 00115 00116 extern virtual task readmemh(string filename); 00117 extern virtual task writememh(string filename); 00118 00119 extern function void prepend_callback(vmm_ral_callbacks cbs); 00120 extern function void append_callback(vmm_ral_callbacks cbs); 00121 extern function void unregister_callback(vmm_ral_callbacks cbs); 00122 00123 extern protected function int get_domain_index(string domain); 00124 endclass: vmm_ral_block_or_sys 00125 00126 00127 function vmm_ral_block_or_sys::new(vmm_ral_sys parent, 00128 string block_or_sys, 00129 string name, 00130 string typename, 00131 int unsigned n_bytes, 00132 vmm_ral::endianness_e endian, 00133 bit [`VMM_RAL_ADDR_WIDTH-1:0] base_addr, 00134 string domain, 00135 bit cover_on); 00136 this.locked = 0; 00137 00138 this.name = name; 00139 this.typename = typename; 00140 begin 00141 vmm_ral_block_or_sys p = parent; 00142 if (p == this) parent = null; 00143 end 00144 this.parent = parent; 00145 00146 this.domains = new [1]; this.domains[0] = domain; 00147 this.in_domains= new [1]; this.in_domains[0]= ""; 00148 this.n_bytes = new [1]; this.n_bytes[0] = n_bytes; 00149 this.endian = new [1]; this.endian[0] = endian; 00150 this.base_addr = new [1]; this.base_addr[0] = base_addr; 00151 00152 this.cover_on = cover_on; 00153 this.no_cover = !cover_on; 00154 endfunction: new 00155 00156 function void vmm_ral_block_or_sys::Xlock_modelX(); 00157 this.locked = 1; 00158 endfunction: Xlock_modelX 00159 00160 00161 function bit vmm_ral_block_or_sys::Xis_lockedX(); 00162 Xis_lockedX = this.locked; 00163 endfunction: Xis_lockedX 00164 00165 00166 function void vmm_ral_block_or_sys::add_domain(int unsigned n_bytes, 00167 vmm_ral::endianness_e endian, 00168 string domain); 00169 int n; 00170 00171 if (this.locked) begin 00172 `vmm_error(this.log, "Cannot add domain to locked model"); 00173 return; 00174 end 00175 00176 n = this.domains.size(); 00177 this.domains = new [n+1] (this.domains); this.domains[n] = domain; 00178 this.in_domains= new [n+1] (this.in_domains);this.in_domains[n]= ""; 00179 this.n_bytes = new [n+1] (this.n_bytes); this.n_bytes[n] = n_bytes; 00180 this.endian = new [n+1] (this.endian); this.endian[n] = endian; 00181 this.base_addr = new [n+1] (this.base_addr); this.base_addr[n] = 0; 00182 endfunction: add_domain 00183 00184 00185 function void vmm_ral_block_or_sys::map_domain(string domain, 00186 string in_domain, 00187 bit [`VMM_RAL_ADDR_WIDTH-1:0] base_addr); 00188 int n; 00189 00190 n = this.get_domain_index(domain); 00191 if (n < 0) return; 00192 00193 if (this.in_domains[n] != "") begin 00194 `vmm_error(this.log, $psprintf("Domain \"%s\" already mapped in domain \"%s\" @'h%h in %s", 00195 domain, in_domains[n], base_addr[n], 00196 this.get_fullname())); 00197 return; 00198 end 00199 00200 this.in_domains[n] = in_domain; 00201 this.base_addr[n] = base_addr; 00202 endfunction: map_domain 00203 00204 00205 function void vmm_ral_block_or_sys::Xadd_constraintsX(string name); 00206 int n; 00207 00208 if (this.locked) begin 00209 `vmm_error(this.log, "Cannot add constraints to locked model"); 00210 return; 00211 end 00212 00213 // Check if the constraint block already exists 00214 foreach (this.constr[i]) begin 00215 if (this.constr[i] == name) begin 00216 `vmm_warning(this.log, $psprintf("Constraint \"%s\" already added", 00217 name)); 00218 return; 00219 end 00220 end 00221 00222 // Append the constraint name to the list 00223 n = this.constr.size(); 00224 this.constr = new [n+1] (this.constr); 00225 this.constr[n] = name; 00226 endfunction: Xadd_constraintsX 00227 00228 00229 function string vmm_ral_block_or_sys::get_name(); 00230 get_name = this.name; 00231 endfunction: get_name 00232 00233 00234 function string vmm_ral_block_or_sys::get_type(); 00235 return this.typename; 00236 endfunction: get_type 00237 00238 00239 function string vmm_ral_block_or_sys::get_fullname(); 00240 vmm_ral_block_or_sys bos; 00241 00242 get_fullname = this.get_name(); 00243 00244 // Do not include top-level name in full name 00245 bos = this.get_parent(); 00246 if (bos == null) return get_fullname; 00247 if (bos.get_parent() == null) return get_fullname; 00248 00249 get_fullname = {this.parent.get_fullname(), ".", get_fullname}; 00250 endfunction: get_fullname 00251 00252 00253 function void vmm_ral_block_or_sys::get_domains(ref string names[]); 00254 names = new [this.domains.size()] (this.domains); 00255 endfunction: get_domains 00256 00257 00258 function vmm_ral_sys vmm_ral_block_or_sys::get_parent(); 00259 get_parent = this.parent; 00260 endfunction: get_parent 00261 00262 00263 function bit [`VMM_RAL_ADDR_WIDTH-1:0] vmm_ral_block_or_sys::get_base_addr(string domain); 00264 int i; 00265 00266 i = this.get_domain_index(domain); 00267 if (i < 0) return 0; 00268 get_base_addr = this.base_addr[i]; 00269 endfunction: get_base_addr 00270 00271 00272 function int unsigned vmm_ral_block_or_sys::get_n_bytes(string domain); 00273 int i; 00274 00275 i = this.get_domain_index(domain); 00276 if (i < 0) return 0; 00277 get_n_bytes = this.n_bytes[i]; 00278 endfunction: get_n_bytes 00279 00280 00281 function vmm_ral::endianness_e vmm_ral_block_or_sys::get_endian(string domain); 00282 int i; 00283 00284 i = this.get_domain_index(domain); 00285 if (i < 0) return vmm_ral::LITTLE_ENDIAN; 00286 get_endian = this.endian[i]; 00287 endfunction: get_endian 00288 00289 00290 function vmm_ral::path_e vmm_ral_block_or_sys::get_default_access(); 00291 if (this.default_access != vmm_ral::DEFAULT) begin 00292 return this.default_access; 00293 end 00294 00295 if (this.parent != null) begin 00296 return this.parent.get_default_access(); 00297 end 00298 00299 // Default access is defined by RAL access 00300 if (this.ral_access != null) begin 00301 get_default_access = this.ral_access.default_path; 00302 end 00303 else begin 00304 `vmm_fatal(log, $psprintf("RAL model for \"%s\" is not associated with a RAL access interface", this.get_fullname())); 00305 get_default_access = vmm_ral::BFM; 00306 end 00307 00308 if (get_default_access == vmm_ral::DEFAULT) begin 00309 // Front door by default 00310 get_default_access = vmm_ral::BFM; 00311 end 00312 endfunction: get_default_access 00313 00314 00315 function string vmm_ral_block_or_sys::get_parent_domain(string domain); 00316 int i; 00317 00318 // if this is the top-most block or system, there is no parent! 00319 if (this.parent == null) return domain; 00320 00321 i = this.get_domain_index(domain); 00322 if (i < 0) return domain; 00323 00324 return this.in_domains[i]; 00325 endfunction: get_parent_domain 00326 00327 00328 function string vmm_ral_block_or_sys::get_external_domain(string domain); 00329 int i; 00330 00331 // if this is the top-most block or system, there is no parent! 00332 if (this.parent == null) return domain; 00333 00334 i = this.get_domain_index(domain); 00335 if (i < 0) return domain; 00336 return this.parent.get_external_domain(this.in_domains[i]); 00337 endfunction: get_external_domain 00338 00339 00340 function void vmm_ral_block_or_sys::display(string prefix, 00341 string domain); 00342 $write("%s\n", this.psdisplay(prefix, domain)); 00343 endfunction: display 00344 00345 00346 function void vmm_ral_block_or_sys::get_constraints(ref string names[]); 00347 names = new [this.constr.size()] (this.constr); 00348 endfunction: get_constraints 00349 00350 00351 function bit vmm_ral_block_or_sys::set_cover(bit is_on); 00352 set_cover = this.cover_on; 00353 00354 if (this.no_cover && is_on) begin 00355 `vmm_warning(this.log, $psprintf("Cannot turn cover ON in %s if constructed with coverage disabled", this.get_fullname())); 00356 return 0; 00357 end 00358 00359 this.cover_on = is_on; 00360 endfunction: set_cover 00361 00362 00363 function bit vmm_ral_block_or_sys::is_cover_on(); 00364 is_cover_on = this.cover_on; 00365 endfunction: is_cover_on 00366 00367 00368 function void vmm_ral_block_or_sys::prepend_callback(vmm_ral_callbacks cbs); 00369 endfunction: prepend_callback 00370 00371 00372 function void vmm_ral_block_or_sys::append_callback(vmm_ral_callbacks cbs); 00373 endfunction: append_callback 00374 00375 00376 function void vmm_ral_block_or_sys::unregister_callback(vmm_ral_callbacks cbs); 00377 endfunction: unregister_callback 00378 00379 00380 function int vmm_ral_block_or_sys::get_domain_index(string domain); 00381 // If the domain is "" and there is only one domain, 00382 // assume it is the one domain available to avoid 00383 // having to always have to specify domains 00384 if (domain == "" && this.domains.size() == 1) return 0; 00385 00386 foreach (this.domains[i]) begin 00387 if (this.domains[i] == domain) return i; 00388 end 00389 `vmm_warning(this.log, $psprintf("Unknown domain name \"%s\" in %s.", 00390 domain, this.get_fullname())); 00391 return -1; 00392 endfunction: get_domain_index 00393 00394
![]() Intelligent Design Verification Project: VMM, Revision: 1.0.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.5.6 Sat Oct 18 11:38:21 2008 |