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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [uvm_src/] [reg/] [uvm_reg_item.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 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: Generic Register Operation Descriptors
25
//
26
// This section defines the abstract register transaction item. It also defines
27
// a descriptor for a physical bus operation that is used by 
28
// subtypes to convert from a protocol-specific address/data/rw operation to
29
// a bus-independent, canonical r/w operation.
30
//------------------------------------------------------------------------------
31
 
32
 
33
//------------------------------------------------------------------------------
34
// CLASS: uvm_reg_item
35
//
36
// Defines an abstract register transaction item. No bus-specific information
37
// is present, although a handle to a  is provided in case a user
38
// wishes to implement a custom address translation algorithm.
39
//------------------------------------------------------------------------------
40
 
41
class uvm_reg_item extends uvm_sequence_item;
42
 
43
  `uvm_object_utils(uvm_reg_item)
44
 
45
  // Variable: element_kind
46
  //
47
  // Kind of element being accessed: REG, MEM, or FIELD. See .
48
  //
49
  uvm_elem_kind_e element_kind;
50
 
51
 
52
  // Variable: element
53
  //
54
  // A handle to the RegModel model element associated with this transaction.
55
  // Use  to determine the type to cast  to: ,
56
  // , or .
57
  //
58
  uvm_object element;
59
 
60
 
61
  // Variable: kind
62
  //
63
  // Kind of access: READ or WRITE.
64
  //
65
  rand uvm_access_e kind;
66
 
67
 
68
  // Variable: value
69
  //
70
  // The value to write to, or after completion, the value read from the DUT.
71
  // Burst operations use the  property.
72
  //
73
  rand uvm_reg_data_t value[];
74
 
75
 
76
  // TODO: parameterize
77
  constraint max_values { value.size() > 0 && value.size() < 1000; }
78
 
79
  // Variable: offset
80
  //
81
  // For memory accesses, the offset address. For bursts,
82
  // the ~starting~ offset address.
83
  //
84
  rand uvm_reg_addr_t offset;
85
 
86
 
87
  // Variable: status
88
  //
89
  // The result of the transaction: IS_OK, HAS_X, or ERROR.
90
  // See .
91
  //
92
  uvm_status_e status;
93
 
94
 
95
  // Variable: local_map
96
  //
97
  // The local map used to obtain addresses. Users may customize
98
  // address-translation using this map. Access to the sequencer
99
  // and bus adapter can be obtained by getting this map's root map,
100
  // then calling  and
101
  // .
102
  //
103
  uvm_reg_map local_map;
104
 
105
 
106
  // Variable: map
107
  //
108
  // The original map specified for the operation. The actual 
109
  // used may differ when a test or sequence written at the block
110
  // level is reused at the system level.
111
  //
112
  uvm_reg_map map;
113
 
114
 
115
  // Variable: path
116
  //
117
  // The path being used:  or .
118
  //
119
  uvm_path_e path;
120
 
121
 
122
  // Variable: parent
123
  //
124
  // The sequence from which the operation originated.
125
  //
126
  rand uvm_sequence_base parent;
127
 
128
 
129
  // Variable: prior
130
  //
131
  // The priority requested of this transfer, as defined by
132
  // .
133
  //
134
  int prior = -1;
135
 
136
 
137
  // Variable: extension
138
  //
139
  // Handle to optional user data, as conveyed in the call to
140
  // write(), read(), mirror(), or update() used to trigger the operation.
141
  //
142
  rand uvm_object extension;
143
 
144
 
145
  // Variable: bd_kind
146
  //
147
  // If path is UVM_BACKDOOR, this member specifies the abstraction
148
  // kind for the backdoor access, e.g. "RTL" or "GATES".
149
  //
150
  string bd_kind;
151
 
152
 
153
  // Variable: fname
154
  //
155
  // The file name from where this transaction originated, if provided
156
  // at the call site.
157
  //
158
  string fname;
159
 
160
 
161
  // Variable: lineno
162
  //
163
  // The file name from where this transaction originated, if provided
164
  // at the call site.
165
  //
166
  int lineno;
167
 
168
 
169
  // Function: new
170
  //
171
  // Create a new instance of this type, giving it the optional ~name~.
172
  //
173
  function new(string name="");
174
    super.new(name);
175
    value = new[1];
176
  endfunction
177
 
178
 
179
  // Function: convert2string
180
  //
181
  // Returns a string showing the contents of this transaction.
182
  //
183
  virtual function string convert2string();
184
    string s,value_s;
185
    s = {"kind=",kind.name(),
186
         " ele_kind=",element_kind.name(),
187
         " ele_name=",element==null?"null":element.get_full_name() };
188
 
189
    if (value.size() > 1 && uvm_report_enabled(UVM_HIGH, UVM_INFO, "RegModel")) begin
190
      value_s = "'{";
191
      foreach (value[i])
192
         value_s = {value_s,$sformatf("%0h,",value[i])};
193
      value_s[value_s.len()-1]="}";
194
    end
195
    else
196
      value_s = $sformatf("%0h",value[0]);
197
    s = {s, " value=",value_s};
198
 
199
    if (element_kind == UVM_MEM)
200
      s = {s, $sformatf(" offset=%0h",offset)};
201
    s = {s," map=",(map==null?"null":map.get_full_name())," path=",path.name()};
202
    s = {s," status=",status.name()};
203
    return s;
204
  endfunction
205
 
206
 
207
  // Function: do_copy
208
  //
209
  // Copy the ~rhs~ object into this object. The ~rhs~ object must
210
  // derive from .
211
  //
212
  virtual function void do_copy(uvm_object rhs);
213
    uvm_reg_item rhs_;
214
    if (rhs == null)
215
     `uvm_fatal("REG/NULL","do_copy: rhs argument is null")
216
 
217
    if (!$cast(rhs_,rhs)) begin
218
      `uvm_error("WRONG_TYPE","Provided rhs is not of type uvm_reg_item")
219
      return;
220
    end
221
    super.copy(rhs);
222
    element_kind = rhs_.element_kind;
223
    element = rhs_.element;
224
    kind = rhs_.kind;
225
    value = rhs_.value;
226
    offset = rhs_.offset;
227
    status = rhs_.status;
228
    local_map = rhs_.local_map;
229
    map = rhs_.map;
230
    path = rhs_.path;
231
    extension = rhs_.extension;
232
    bd_kind = rhs_.bd_kind;
233
    parent = rhs_.parent;
234
    prior = rhs_.prior;
235
    fname = rhs_.fname;
236
    lineno = rhs_.lineno;
237
  endfunction
238
 
239
endclass
240
 
241
 
242
 
243
//------------------------------------------------------------------------------
244
//
245
// CLASS: uvm_reg_bus_op
246
//
247
// Struct that defines a generic bus transaction for register and memory accesses, having
248
// ~kind~ (read or write), ~address~, ~data~, and ~byte enable~ information.
249
// If the bus is narrower than the register or memory location being accessed,
250
// there will be multiple of these bus operations for every abstract
251
//  transaction. In this case, ~data~ represents the portion
252
// of  being transferred during this bus cycle.
253
// If the bus is wide enough to perform the register or memory operation in
254
// a single cycle, ~data~ will be the same as .
255
//------------------------------------------------------------------------------
256
 
257
typedef struct {
258
 
259
  // Variable: kind
260
  //
261
  // Kind of access: READ or WRITE.
262
  //
263
  uvm_access_e kind;
264
 
265
 
266
  // Variable: addr
267
  //
268
  // The bus address.
269
  //
270
  uvm_reg_addr_t addr;
271
 
272
 
273
  // Variable: data
274
  //
275
  // The data to write. If the bus width is smaller than the register or
276
  // memory width, ~data~ represents only the portion of ~value~ that is
277
  // being transferred this bus cycle.
278
  //
279
  uvm_reg_data_t data;
280
 
281
 
282
  // Variable: n_bits
283
  //
284
  // The number of bits of  being transferred by
285
  // this transaction.
286
 
287
  int n_bits;
288
 
289
  /*
290
  constraint valid_n_bits {
291
     n_bits > 0;
292
     n_bits <= `UVM_REG_DATA_WIDTH;
293
  }
294
  */
295
 
296
 
297
  // Variable: byte_en
298
  //
299
  // Enables for the byte lanes on the bus. Meaningful only when the
300
  // bus supports byte enables and the operation originates from a field
301
  // write/read.
302
  //
303
  uvm_reg_byte_en_t byte_en;
304
 
305
 
306
  // Variable: status
307
  //
308
  // The result of the transaction: UVM_IS_OK, UVM_HAS_X, UVM_NOT_OK.
309
  // See .
310
  //
311
  uvm_status_e status;
312
 
313
} uvm_reg_bus_op;
314
 
315
 

powered by: WebSVN 2.1.0

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