⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mem_walk.sv

📁 VMM 文档加源码, synopsys公司很好的验证资料
💻 SV
字号:
// // -------------------------------------------------------------//    Copyright 2004-2008 Synopsys, Inc.//    All Rights Reserved Worldwide// //    Licensed under the Apache License, Version 2.0 (the//    "License"); you may not use this file except in//    compliance with the License.  You may obtain a copy of//    the License at// //        http://www.apache.org/licenses/LICENSE-2.0// //    Unless required by applicable law or agreed to in//    writing, software distributed under the License is//    distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR//    CONDITIONS OF ANY KIND, either express or implied.  See//    the License for the specific language governing//    permissions and limitations under the License.// -------------------------------------------------------------// `include "ral_env.svh"`ifndef RAL_TB_ENV`define RAL_TB_ENV tb_env`endifprogram mem_walk;vmm_log log = new("Mem Walk", "Test");`RAL_TB_ENV env = new;initialbegin   vmm_ral_block_or_sys ral_model;   vmm_ral_mem mems[];   ral_model = env.ral.get_model();   if (ral_model == null) begin      `vmm_fatal(log, "No RAL abstraction model was specified");   end   env.reset_dut();   ral_model.reset();   // Walk over all RW memories   ral_model.get_memories(mems);   foreach (mems[i]) begin      vmm_ral::access_e mode;      string domains[];      int n_bits;      n_bits = mems[i].get_n_bits();      // Memories may be accessible from multiple physical interfaces (domains)      mems[i].get_domains(domains);      // Walk the memory via each domain      foreach (domains[j]) begin         vmm_rw::status_e status;         bit [`VMM_RAL_DATA_WIDTH-1:0] val, exp, v;            // Only deal with RW memories         if (mems[i].get_access(domains[j]) != vmm_ral::RW) continue;         `vmm_note(log, $psprintf("Walking memory %s in domain \"%s\"...",                                  mems[i].get_fullname(), domains[j]));         // The walking process is, for address k:         // - Write ~k         // - Read k-1 and expect ~(k-1) if k > 0         // - Write k-1 at k-1         // - Read k and expect ~k if k == last address         for (int k = 0; k < mems[i].get_size(); k++) begin            mems[i].write(status, k, ~k, vmm_ral::BFM, domains[j]);            if (status != vmm_rw::IS_OK) begin               `vmm_error(log, $psprintf("Status was %s when writing \"%s[%0d]\" through domain \"%s\".",                                         status.name(), mems[i].get_fullname(), k, domains[j]));            end            if (k > 0) begin               mems[i].read(status, k-1, val, vmm_ral::BFM, domains[j]);               if (status != vmm_rw::IS_OK) begin                  `vmm_error(log, $psprintf("Status was %s when reading \"%s[%0d]\" through domain \"%s\".",                                            status.name(), mems[i].get_fullname(), k, domains[j]));               end               else begin                  exp = ~(k-1) & ((1'b1<<n_bits)-1);                  if (val !== exp) begin                     `vmm_error(log, $psprintf("\"%s[%0d-1]\" read back as 'h%h instead of 'h%h.",                                               mems[i].get_fullname(), k, val, exp));                  end               end               mems[i].write(status, k-1, k-1, vmm_ral::BFM, domains[j]);               if (status != vmm_rw::IS_OK) begin                  `vmm_error(log, $psprintf("Status was %s when writing \"%s[%0d-1]\" through domain \"%s\".",                                            status.name(), mems[i].get_fullname(), k, domains[j]));               end            end            if (k == mems[i].get_size() - 1) begin               mems[i].read(status, k, val, vmm_ral::BFM, domains[j]);               if (status != vmm_rw::IS_OK) begin                  `vmm_error(log, $psprintf("Status was %s when reading \"%s[%0d]\" through domain \"%s\".",                                            status.name(), mems[i].get_fullname(), k, domains[j]));               end               else begin                  exp = ~(k) & ((1'b1<<n_bits)-1);                  if (val !== exp) begin                     `vmm_error(log, $psprintf("\"%s[%0d]\" read back as 'h%h instead of 'h%h.",                                               mems[i].get_fullname(), k, val, exp));                  end               end            end         end      end   end      env.log.report();endendprogram: mem_walk

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -