OpenCores
URL https://opencores.org/ocsvn/uart2bus_testbench/uart2bus_testbench/trunk

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [uvm_src/] [reg/] [sequences/] [uvm_reg_mem_hdl_paths_seq.svh] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 HanySalah
//
2
// -------------------------------------------------------------
3
//    Copyright 2010 Cadence.
4
//    Copyright 2011 Mentor Graphics Corporation
5
//    All Rights Reserved Worldwide
6
//
7
//    Licensed under the Apache License, Version 2.0 (the
8
//    "License"); you may not use this file except in
9
//    compliance with the License.  You may obtain a copy of
10
//    the License at
11
//
12
//        http://www.apache.org/licenses/LICENSE-2.0
13
//
14
//    Unless required by applicable law or agreed to in
15
//    writing, software distributed under the License is
16
//    distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17
//    CONDITIONS OF ANY KIND, either express or implied.  See
18
//    the License for the specific language governing
19
//    permissions and limitations under the License.
20
// -------------------------------------------------------------
21
//
22
 
23
//
24
// TITLE: HDL Paths Checking Test Sequence
25
//
26
 
27
//
28
// class: uvm_reg_mem_hdl_paths_seq
29
//
30
// Verify the correctness of HDL paths specified for registers and memories.
31
//
32
// This sequence is be used to check that the specified backdoor paths
33
// are indeed accessible by the simulator.
34
// By default, the check is performed for the default design abstraction.
35
// If the simulation contains multiple models of the DUT,
36
// HDL paths for multiple design abstractions can be checked.
37
//
38
// If a path is not accessible by the simulator, it cannot be used for
39
// read/write backdoor accesses. In that case a warning is produced.
40
// A simulator may have finer-grained access permissions such as separate
41
// read or write permissions.
42
// These extra access permissions are NOT checked.
43
//
44
// The test is performed in zero time and
45
// does not require any reads/writes to/from the DUT.
46
//
47
 
48
class uvm_reg_mem_hdl_paths_seq extends uvm_reg_sequence #(uvm_sequence #(uvm_reg_item));
49
    // Variable: abstractions
50
    // If set, check the HDL paths for the specified design abstractions.
51
    // If empty, check the HDL path for the default design abstraction,
52
    // as specified with 
53
    string abstractions[$];
54
 
55
    `uvm_object_utils_begin(uvm_reg_mem_hdl_paths_seq)
56
        `uvm_field_queue_string(abstractions, UVM_DEFAULT)
57
    `uvm_object_utils_end
58
 
59
    function new(string name="uvm_reg_mem_hdl_paths_seq");
60
        super.new(name);
61
    endfunction
62
 
63
    virtual task body();
64
 
65
        if (model == null) begin
66
            uvm_report_error("uvm_reg_mem_hdl_paths_seq", "Register model handle is null");
67
            return;
68
        end
69
 
70
       `uvm_info("uvm_reg_mem_hdl_paths_seq",
71
                 {"checking HDL paths for all registers/memories in ",
72
                  model.get_full_name()}, UVM_LOW);
73
 
74
       if (abstractions.size() == 0)
75
          do_block(model, "");
76
       else begin
77
          foreach (abstractions[i])
78
             do_block(model, abstractions[i]);
79
       end
80
 
81
        `uvm_info("uvm_reg_mem_hdl_paths_seq", "HDL path validation completed ",UVM_LOW);
82
 
83
    endtask: body
84
 
85
 
86
    // Any additional steps required to reset the block
87
    // and make it accessible
88
    virtual task reset_blk(uvm_reg_block blk);
89
    endtask
90
 
91
 
92
    protected virtual function void do_block(uvm_reg_block blk,
93
                                             string        kind);
94
        uvm_reg       regs[$];
95
        uvm_mem       mems[$];
96
 
97
       `uvm_info("uvm_reg_mem_hdl_paths_seq",
98
                 {"Validating HDL paths in ", blk.get_full_name(),
99
                  " for ", (kind == "") ? "default" : kind,
100
                  " design abstraction"}, UVM_MEDIUM)
101
 
102
       // Iterate over all registers, checking accesses
103
       blk.get_registers(regs, UVM_NO_HIER);
104
       foreach (regs[i])
105
          check_reg(regs[i], kind);
106
 
107
       blk.get_memories(mems, UVM_NO_HIER);
108
       foreach (mems[i])
109
          check_mem(mems[i], kind);
110
 
111
       begin
112
          uvm_reg_block blks[$];
113
 
114
          blk.get_blocks(blks);
115
          foreach (blks[i]) begin
116
             do_block(blks[i], kind);
117
          end
118
       end
119
    endfunction: do_block
120
 
121
 
122
    protected virtual function void check_reg(uvm_reg r,
123
                                              string kind);
124
        uvm_hdl_path_concat paths[$];
125
 
126
        // avoid calling get_full_hdl_path when the register has not path for this abstraction kind
127
        if(!r.has_hdl_path(kind))
128
                return;
129
 
130
        r.get_full_hdl_path(paths, kind);
131
        if (paths.size() == 0) return;
132
 
133
        foreach(paths[p]) begin
134
            uvm_hdl_path_concat path=paths[p];
135
            foreach (path.slices[j]) begin
136
                string p_ = path.slices[j].path;
137
                uvm_reg_data_t d;
138
                if (!uvm_hdl_read(p_,d))
139
                    `uvm_error("uvm_reg_mem_hdl_paths_seq",
140
                               $sformatf("HDL path \"%s\" for register \"%s\" is not readable",
141
                                         p_, r.get_full_name()));
142
                if (!uvm_hdl_check_path(p_))
143
                    `uvm_error("uvm_reg_mem_hdl_paths_seq",
144
                               $sformatf("HDL path \"%s\" for register \"%s\" is not accessible",
145
                                         p_, r.get_full_name()));
146
            end
147
        end
148
    endfunction
149
 
150
 
151
    protected virtual function void check_mem(uvm_mem m,
152
                                              string kind);
153
        uvm_hdl_path_concat paths[$];
154
 
155
        // avoid calling get_full_hdl_path when the register has not path for this abstraction kind
156
        if(!m.has_hdl_path(kind))
157
                return;
158
 
159
        m.get_full_hdl_path(paths, kind);
160
        if (paths.size() == 0) return;
161
 
162
        foreach(paths[p]) begin
163
            uvm_hdl_path_concat path=paths[p];
164
            foreach (path.slices[j])
165
            begin
166
                string p_ = path.slices[j].path;
167
                if(!uvm_hdl_check_path(p_))
168
                    `uvm_error("uvm_reg_mem_hdl_paths_seq",
169
                               $sformatf("HDL path \"%s\" for memory \"%s\" is not accessible",
170
                                         p_, m.get_full_name()));
171
            end
172
        end
173
    endfunction
174
endclass: uvm_reg_mem_hdl_paths_seq

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.