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

Subversion Repositories uart2bus_testbench

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 HanySalah
//
2
// -------------------------------------------------------------
3
//    Copyright 2004-2009 Synopsys, Inc.
4
//    Copyright 2010-2011 Mentor Graphics Corporation
5
//    Copyright 2010 Cadence Design Systems, Inc.
6
//    All Rights Reserved Worldwide
7
//
8
//    Licensed under the Apache License, Version 2.0 (the
9
//    "License"); you may not use this file except in
10
//    compliance with the License.  You may obtain a copy of
11
//    the License at
12
//
13
//        http://www.apache.org/licenses/LICENSE-2.0
14
//
15
//    Unless required by applicable law or agreed to in
16
//    writing, software distributed under the License is
17
//    distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
18
//    CONDITIONS OF ANY KIND, either express or implied.  See
19
//    the License for the specific language governing
20
//    permissions and limitations under the License.
21
// -------------------------------------------------------------
22
//
23
 
24
//------------------------------------------------------------------------------
25
// TITLE: Global Declarations for the Register Layer
26
//------------------------------------------------------------------------------
27
//
28
// This section defines globally available types, enums, and utility classes.
29
//
30
//------------------------------------------------------------------------------
31
 
32
`ifndef UVM_REG_MODEL__SV
33
`define UVM_REG_MODEL__SV
34
 
35
 
36
typedef class uvm_reg_field;
37
typedef class uvm_vreg_field;
38
typedef class uvm_reg;
39
typedef class uvm_reg_file;
40
typedef class uvm_vreg;
41
typedef class uvm_reg_block;
42
typedef class uvm_mem;
43
typedef class uvm_reg_item;
44
typedef class uvm_reg_map;
45
typedef class uvm_reg_map_info;
46
typedef class uvm_reg_sequence;
47
typedef class uvm_reg_adapter;
48
typedef class uvm_reg_indirect_data;
49
 
50
 
51
//-------------
52
// Group: Types
53
//-------------
54
 
55
// Type: uvm_reg_data_t
56
//
57
// 2-state data value with <`UVM_REG_DATA_WIDTH> bits
58
//
59
typedef  bit unsigned [`UVM_REG_DATA_WIDTH-1:0]  uvm_reg_data_t ;
60
 
61
 
62
// Type: uvm_reg_data_logic_t
63
//
64
// 4-state data value with <`UVM_REG_DATA_WIDTH> bits
65
//
66
typedef  logic unsigned [`UVM_REG_DATA_WIDTH-1:0]  uvm_reg_data_logic_t ;
67
 
68
 
69
// Type: uvm_reg_addr_t
70
//
71
// 2-state address value with <`UVM_REG_ADDR_WIDTH> bits
72
//
73
typedef  bit unsigned [`UVM_REG_ADDR_WIDTH-1:0]  uvm_reg_addr_t ;
74
 
75
 
76
// Type: uvm_reg_addr_logic_t
77
//
78
// 4-state address value with <`UVM_REG_ADDR_WIDTH> bits
79
//
80
typedef  logic unsigned [`UVM_REG_ADDR_WIDTH-1:0]  uvm_reg_addr_logic_t ;
81
 
82
 
83
// Type: uvm_reg_byte_en_t
84
//
85
// 2-state byte_enable value with <`UVM_REG_BYTENABLE_WIDTH> bits
86
//
87
typedef  bit unsigned [`UVM_REG_BYTENABLE_WIDTH-1:0]  uvm_reg_byte_en_t ;
88
 
89
 
90
// Type: uvm_reg_cvr_t
91
//
92
// Coverage model value set with <`UVM_REG_CVR_WIDTH> bits.
93
//
94
// Symbolic values for individual coverage models are defined
95
// by the  type.
96
//
97
// The following bits in the set are assigned as follows
98
//
99
// 0-7     - UVM pre-defined coverage models
100
// 8-15    - Coverage models defined by EDA vendors,
101
//           implemented in a register model generator.
102
// 16-23   - User-defined coverage models
103
// 24..    - Reserved
104
//
105
typedef  bit [`UVM_REG_CVR_WIDTH-1:0]  uvm_reg_cvr_t ;
106
 
107
 
108
// Type: uvm_hdl_path_slice
109
//
110
// Slice of an HDL path
111
//
112
// Struct that specifies the HDL variable that corresponds to all
113
// or a portion of a register.
114
//
115
// path    - Path to the HDL variable.
116
// offset  - Offset of the LSB in the register that this variable implements
117
// size    - Number of bits (toward the MSB) that this variable implements
118
//
119
// If the HDL variable implements all of the register, ~offset~ and ~size~
120
// are specified as -1. For example:
121
//|
122
//| r1.add_hdl_path('{ '{"r1", -1, -1} });
123
//|
124
//
125
typedef struct {
126
   string path;
127
   int offset;
128
   int size;
129
} uvm_hdl_path_slice;
130
 
131
 
132
typedef uvm_resource_db#(uvm_reg_cvr_t) uvm_reg_cvr_rsrc_db;
133
 
134
 
135
//--------------------
136
// Group: Enumerations
137
//--------------------
138
 
139
// Enum: uvm_status_e
140
//
141
// Return status for register operations
142
//
143
// UVM_IS_OK      - Operation completed successfully
144
// UVM_NOT_OK     - Operation completed with error
145
// UVM_HAS_X      - Operation completed successfully bit had unknown bits.
146
//
147
 
148
   typedef enum {
149
      UVM_IS_OK,
150
      UVM_NOT_OK,
151
      UVM_HAS_X
152
   } uvm_status_e;
153
 
154
 
155
// Enum: uvm_path_e
156
//
157
// Path used for register operation
158
//
159
// UVM_FRONTDOOR    - Use the front door
160
// UVM_BACKDOOR     - Use the back door
161
// UVM_PREDICT      - Operation derived from observations by a bus monitor via
162
//                    the  class.
163
// UVM_DEFAULT_PATH - Operation specified by the context
164
//
165
   typedef enum {
166
      UVM_FRONTDOOR,
167
      UVM_BACKDOOR,
168
      UVM_PREDICT,
169
      UVM_DEFAULT_PATH
170
   } uvm_path_e;
171
 
172
 
173
// Enum: uvm_check_e
174
//
175
// Read-only or read-and-check
176
//
177
// UVM_NO_CHECK   - Read only
178
// UVM_CHECK      - Read and check
179
//
180
   typedef enum {
181
      UVM_NO_CHECK,
182
      UVM_CHECK
183
   } uvm_check_e;
184
 
185
 
186
// Enum: uvm_endianness_e
187
//
188
// Specifies byte ordering
189
//
190
// UVM_NO_ENDIAN      - Byte ordering not applicable
191
// UVM_LITTLE_ENDIAN  - Least-significant bytes first in consecutive addresses
192
// UVM_BIG_ENDIAN     - Most-significant bytes first in consecutive addresses
193
// UVM_LITTLE_FIFO    - Least-significant bytes first at the same address
194
// UVM_BIG_FIFO       - Most-significant bytes first at the same address
195
//
196
   typedef enum {
197
      UVM_NO_ENDIAN,
198
      UVM_LITTLE_ENDIAN,
199
      UVM_BIG_ENDIAN,
200
      UVM_LITTLE_FIFO,
201
      UVM_BIG_FIFO
202
   } uvm_endianness_e;
203
 
204
 
205
// Enum: uvm_elem_kind_e
206
//
207
// Type of element being read or written
208
//
209
// UVM_REG      - Register
210
// UVM_FIELD    - Field
211
// UVM_MEM      - Memory location
212
//
213
   typedef enum {
214
      UVM_REG,
215
      UVM_FIELD,
216
      UVM_MEM
217
   } uvm_elem_kind_e;
218
 
219
 
220
// Enum: uvm_access_e
221
//
222
// Type of operation begin performed
223
//
224
// UVM_READ     - Read operation
225
// UVM_WRITE    - Write operation
226
//
227
   typedef enum {
228
      UVM_READ,
229
      UVM_WRITE,
230
      UVM_BURST_READ,
231
      UVM_BURST_WRITE
232
   } uvm_access_e;
233
 
234
 
235
// Enum: uvm_hier_e
236
//
237
// Whether to provide the requested information from a hierarchical context.
238
//
239
// UVM_NO_HIER - Provide info from the local context
240
// UVM_HIER    - Provide info based on the hierarchical context
241
 
242
   typedef enum {
243
      UVM_NO_HIER,
244
      UVM_HIER
245
   } uvm_hier_e;
246
 
247
 
248
// Enum: uvm_predict_e
249
//
250
// How the mirror is to be updated
251
//
252
// UVM_PREDICT_DIRECT  - Predicted value is as-is
253
// UVM_PREDICT_READ    - Predict based on the specified value having been read
254
// UVM_PREDICT_WRITE   - Predict based on the specified value having been written
255
//
256
   typedef enum {
257
      UVM_PREDICT_DIRECT,
258
      UVM_PREDICT_READ,
259
      UVM_PREDICT_WRITE
260
   } uvm_predict_e;
261
 
262
 
263
// Enum: uvm_coverage_model_e
264
//
265
// Coverage models available or desired.
266
// Multiple models may be specified by bitwise OR'ing individual model identifiers.
267
//
268
// UVM_NO_COVERAGE      - None
269
// UVM_CVR_REG_BITS     - Individual register bits
270
// UVM_CVR_ADDR_MAP     - Individual register and memory addresses
271
// UVM_CVR_FIELD_VALS   - Field values
272
// UVM_CVR_ALL          - All coverage models
273
//
274
   typedef enum uvm_reg_cvr_t {
275
      UVM_NO_COVERAGE      = 'h0000,
276
      UVM_CVR_REG_BITS     = 'h0001,
277
      UVM_CVR_ADDR_MAP     = 'h0002,
278
      UVM_CVR_FIELD_VALS   = 'h0004,
279
      UVM_CVR_ALL          = -1
280
   } uvm_coverage_model_e;
281
 
282
 
283
// Enum: uvm_reg_mem_tests_e
284
//
285
// Select which pre-defined test sequence to execute.
286
//
287
// Multiple test sequences may be selected by bitwise OR'ing their
288
// respective symbolic values.
289
//
290
// UVM_DO_REG_HW_RESET      - Run 
291
// UVM_DO_REG_BIT_BASH      - Run 
292
// UVM_DO_REG_ACCESS        - Run 
293
// UVM_DO_MEM_ACCESS        - Run 
294
// UVM_DO_SHARED_ACCESS     - Run 
295
// UVM_DO_MEM_WALK          - Run 
296
// UVM_DO_ALL_REG_MEM_TESTS - Run all of the above
297
//
298
// Test sequences, when selected, are executed in the
299
// order in which they are specified above.
300
//
301
typedef enum bit [63:0] {
302
  UVM_DO_REG_HW_RESET      = 64'h0000_0000_0000_0001,
303
  UVM_DO_REG_BIT_BASH      = 64'h0000_0000_0000_0002,
304
  UVM_DO_REG_ACCESS        = 64'h0000_0000_0000_0004,
305
  UVM_DO_MEM_ACCESS        = 64'h0000_0000_0000_0008,
306
  UVM_DO_SHARED_ACCESS     = 64'h0000_0000_0000_0010,
307
  UVM_DO_MEM_WALK          = 64'h0000_0000_0000_0020,
308
  UVM_DO_ALL_REG_MEM_TESTS = 64'hffff_ffff_ffff_ffff
309
} uvm_reg_mem_tests_e;
310
 
311
 
312
 
313
//-----------------------
314
// Group: Utility Classes
315
//-----------------------
316
 
317
//------------------------------------------------------------------------------
318
// Class: uvm_hdl_path_concat
319
//
320
// Concatenation of HDL variables
321
//
322
// A dArray of  specifying a concatenation
323
// of HDL variables that implement a register in the HDL.
324
//
325
// Slices must be specified in most-to-least significant order.
326
// Slices must not overlap. Gaps may exist in the concatenation
327
// if portions of the registers are not implemented.
328
//
329
// For example, the following register
330
//|
331
//|        1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
332
//| Bits:  5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
333
//|       +-+---+-------------+---+-------+
334
//|       |A|xxx|      B      |xxx|   C   |
335
//|       +-+---+-------------+---+-------+
336
//|
337
//
338
// If the register is implemented using a single HDL variable,
339
// The array should specify a single slice with its ~offset~ and ~size~
340
// specified as -1. For example:
341
//
342
//| concat.set('{ '{"r1", -1, -1} });
343
//
344
//------------------------------------------------------------------------------
345
 
346
class uvm_hdl_path_concat;
347
 
348
   // Variable: slices
349
   // Array of individual slices,
350
   // stored in most-to-least significant order
351
   uvm_hdl_path_slice slices[];
352
 
353
   // Function: set
354
   // Initialize the concatenation using an array literal
355
   function void set(uvm_hdl_path_slice t[]);
356
      slices = t;
357
   endfunction
358
 
359
   // Function: add_slice
360
   // Append the specified ~slice~ literal to the path concatenation
361
   function void add_slice(uvm_hdl_path_slice slice);
362
      slices = new [slices.size()+1] (slices);
363
      slices[slices.size()-1] = slice;
364
   endfunction
365
 
366
   // Function: add_path
367
   // Append the specified ~path~ to the path concatenation,
368
   // for the specified number of bits at the specified ~offset~.
369
   function void add_path(string path,
370
                          int unsigned offset = -1,
371
                          int unsigned size = -1);
372
      uvm_hdl_path_slice t;
373
      t.offset = offset;
374
      t.path   = path;
375
      t.size   = size;
376
 
377
      add_slice(t);
378
   endfunction
379
 
380
endclass
381
 
382
 
383
 
384
 
385
// concat2string
386
 
387
function automatic string uvm_hdl_concat2string(uvm_hdl_path_concat concat);
388
   string image = "{";
389
 
390
   if (concat.slices.size() == 1 &&
391
       concat.slices[0].offset == -1 &&
392
       concat.slices[0].size == -1)
393
      return concat.slices[0].path;
394
 
395
   foreach (concat.slices[i]) begin
396
      uvm_hdl_path_slice slice=concat.slices[i];
397
 
398
      image = { image, (i == 0) ? "" : ", ", slice.path };
399
      if (slice.offset >= 0)
400
         image = { image, "@", $sformatf("[%0d +: %0d]", slice.offset, slice.size) };
401
   end
402
 
403
   image = { image, "}" };
404
 
405
   return image;
406
endfunction
407
 
408
typedef struct packed {
409
  uvm_reg_addr_t min;
410
  uvm_reg_addr_t max;
411
  int unsigned stride;
412
  } uvm_reg_map_addr_range;
413
 
414
 
415
`include "reg/uvm_reg_item.svh"
416
`include "reg/uvm_reg_adapter.svh"
417
`include "reg/uvm_reg_predictor.svh"
418
`include "reg/uvm_reg_sequence.svh"
419
`include "reg/uvm_reg_cbs.svh"
420
`include "reg/uvm_reg_backdoor.svh"
421
`include "reg/uvm_reg_field.svh"
422
`include "reg/uvm_vreg_field.svh"
423
`include "reg/uvm_reg.svh"
424
`include "reg/uvm_reg_indirect.svh"
425
`include "reg/uvm_reg_fifo.svh"
426
`include "reg/uvm_reg_file.svh"
427
`include "reg/uvm_mem_mam.svh"
428
`include "reg/uvm_vreg.svh"
429
`include "reg/uvm_mem.svh"
430
`include "reg/uvm_reg_map.svh"
431
`include "reg/uvm_reg_block.svh"
432
 
433
`include "reg/sequences/uvm_reg_hw_reset_seq.svh"
434
`include "reg/sequences/uvm_reg_bit_bash_seq.svh"
435
`include "reg/sequences/uvm_mem_walk_seq.svh"
436
`include "reg/sequences/uvm_mem_access_seq.svh"
437
`include "reg/sequences/uvm_reg_access_seq.svh"
438
`include "reg/sequences/uvm_reg_mem_shared_access_seq.svh"
439
`include "reg/sequences/uvm_reg_mem_built_in_seq.svh"
440
`include "reg/sequences/uvm_reg_mem_hdl_paths_seq.svh"
441
 
442
`endif // UVM_REG_MODEL__SV

powered by: WebSVN 2.1.0

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