reg_access.sv

Go to the documentation of this file.
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 `include "ral_env.svh"
00024 
00025 `ifndef RAL_TB_ENV
00026 `define RAL_TB_ENV tb_env
00027 `endif
00028 
00029 
00030 program reg_access;
00031 
00032 vmm_log log = new("Reg Access", "Test");
00033 `RAL_TB_ENV env = new;
00034 
00035 initial
00036 begin
00037    vmm_ral_block_or_sys ral_model;
00038    vmm_ral_reg regs[];
00039 
00040    ral_model = env.ral.get_model();
00041    if (ral_model == null) begin
00042       `vmm_fatal(log, "No RAL abstraction model was specified");
00043    end
00044 
00045    env.reset_dut();
00046    ral_model.reset();
00047 
00048    // Iterate over all registers, checking accesses
00049    ral_model.get_registers(regs);
00050    foreach (regs[i]) begin: next_reg
00051       string domains[];
00052 
00053       // Can only deal with registers with backdoor access
00054       if (regs[i].get_backdoor() == null) begin
00055          `vmm_warning(log, $psprintf("Register \"%s\" does not have a backdoor mechanism available",
00056                                      regs[i].get_fullname()));
00057          continue;
00058       end
00059 
00060       // Registers may be accessible from multiple physical interfaces (domains)
00061       regs[i].get_domains(domains);
00062 
00063       // Cannot test access if register contains RO or OTHER fields
00064       begin
00065          vmm_ral_field fields[];
00066          regs[i].get_fields(fields);
00067          foreach (fields[j]) begin
00068             foreach (domains[k]) begin
00069                if (fields[j].get_access(domains[k]) == vmm_ral::RO) begin
00070                   `vmm_warning(log, $psprintf("Register \"%s\" has RO bits",
00071                                               regs[i].get_fullname()));
00072                   disable next_reg;
00073                end
00074                if (fields[j].get_access(domains[k]) >= vmm_ral::OTHER) begin
00075                   `vmm_warning(log, $psprintf("Register \"%s\" has OTHER or USER bits",
00076                                               regs[i].get_fullname()));
00077                   disable next_reg;
00078                end
00079             end
00080          end
00081       end
00082 
00083       // Access each register:
00084       // - Write complement of reset value via front door
00085       // - Read value via backdoor and compare against mirror
00086       // - Write reset value via backdoor
00087       // - Read via front door and compare against mirror
00088       foreach (domains[j]) begin
00089          vmm_rw::status_e status;
00090          bit [`VMM_RAL_DATA_WIDTH-1:0] v, exp;
00091       
00092          `vmm_note(log, $psprintf("Verifying access of register %s in domain \"%s\"...",
00093                                   regs[i].get_fullname(), domains[j]));
00094 
00095          v = regs[i].get();
00096 
00097          regs[i].write(status, ~v, vmm_ral::BFM, domains[j]);
00098          if (status != vmm_rw::IS_OK) begin
00099             `vmm_error(log, $psprintf("Status was %s when writing \"%s\" through domain \"%s\".",
00100                                       status.name(), regs[i].get_fullname(), domains[j]));
00101          end
00102 
00103          regs[i].mirror(status, vmm_ral::VERB, vmm_ral::BACKDOOR);
00104          if (status != vmm_rw::IS_OK) begin
00105             `vmm_error(log, $psprintf("Status was %s when reading reset value of register \"%s\" through backdoor.",
00106                                       status.name(), regs[i].get_fullname()));
00107          end
00108 
00109          regs[i].write(status, v, vmm_ral::BACKDOOR, domains[j]);
00110          if (status != vmm_rw::IS_OK) begin
00111             `vmm_error(log, $psprintf("Status was %s when writing \"%s\" through backdoor.",
00112                                       status.name(), regs[i].get_fullname()));
00113          end
00114 
00115          regs[i].mirror(status, vmm_ral::VERB, vmm_ral::BFM, domains[j]);
00116          if (status != vmm_rw::IS_OK) begin
00117             `vmm_error(log, $psprintf("Status was %s when reading reset value of register \"%s\" through domain \"%s\".",
00118                                       status.name(), regs[i].get_fullname(), domains[j]));
00119          end
00120       end
00121    end
00122    
00123    env.log.report();
00124 end
00125 endprogram: reg_access

Intelligent Design Verification
Intelligent Design Verification
Project: VMM, Revision: 1.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
Doxygen Version: 1.5.6
Sat Oct 18 11:32:18 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV