OpenCores
URL https://opencores.org/ocsvn/avalon-wishbone-bridge/avalon-wishbone-bridge/trunk

Subversion Repositories avalon-wishbone-bridge

[/] [avalon-wishbone-bridge/] [trunk/] [UVM/] [wb_slave_agent/] [wb_slave_seq_item.svh] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sumanta.ch
//------------------------------------------------------------
2
//   Copyright 2010 Mentor Graphics Corporation
3
//   All Rights Reserved Worldwide
4
//
5
//   Licensed under the Apache License, Version 2.0 (the
6
//   "License"); you may not use this file except in
7
//   compliance with the License.  You may obtain a copy of
8
//   the License at
9
//
10
//       http://www.apache.org/licenses/LICENSE-2.0
11
//
12
//   Unless required by applicable law or agreed to in
13
//   writing, software distributed under the License is
14
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
15
//   CONDITIONS OF ANY KIND, either express or implied.  See
16
//   the License for the specific language governing
17
//   permissions and limitations under the License.
18
//------------------------------------------------------------
19
 
20
// Questa recording macro:
21
 
22
//`define uvm_record_field(NAME,VALUE) \
23
//   $add_attribute(recorder.tr_handle,VALUE,NAME);
24
 
25
//
26
// Class Description:
27
//
28
//
29
class wb_slave_seq_item #(AW =32, DW=64, TW= 2) extends uvm_sequence_item;
30
 
31
// UVM Factory Registration Macro
32
//
33
`uvm_object_utils(wb_slave_seq_item)
34
 
35
//------------------------------------------
36
// Data Members (Outputs rand, inputs non-rand)
37
//------------------------------------------
38
logic[AW-1:0] addr;
39
logic[DW-1:0] wdata;
40
logic[TW-1:0] tag;
41
logic rw;
42
 
43
rand logic[DW-1:0] rdata;
44
rand logic slv_err;
45
rand int delay;
46
 
47
constraint delay_bounds {
48
  delay inside {[0:2]};
49
}
50
 
51
constraint error_dist {
52
  slv_err dist {0 := 80, 1 := 20};
53
}
54
 
55
//------------------------------------------
56
// Methods
57
//------------------------------------------
58
 
59
// Standard UVM Methods:
60
extern function new(string name = "wb_slave_seq_item");
61
extern function void do_copy(uvm_object rhs);
62
extern function bit do_compare(uvm_object rhs, uvm_comparer comparer);
63
extern function string convert2string();
64
extern function void do_print(uvm_printer printer);
65
extern function void do_record(uvm_recorder recorder);
66
 
67
endclass:wb_slave_seq_item
68
 
69
function wb_slave_seq_item::new(string name = "wb_slave_seq_item");
70
  super.new(name);
71
endfunction
72
 
73
function void wb_slave_seq_item::do_copy(uvm_object rhs);
74
  wb_slave_seq_item rhs_;
75
 
76
  if(!$cast(rhs_, rhs)) begin
77
    `uvm_fatal("do_copy", "cast of rhs object failed")
78
  end
79
  super.do_copy(rhs);
80
  // Copy over data members:
81
  addr = rhs_.addr;
82
  wdata = rhs_.wdata;
83
  rw = rhs_.rw;
84
  slv_err = rhs_.slv_err;
85
  rdata = rhs_.rdata;
86
  delay = rhs_.delay;
87
 
88
endfunction:do_copy
89
 
90
function bit wb_slave_seq_item::do_compare(uvm_object rhs, uvm_comparer comparer);
91
  wb_slave_seq_item rhs_;
92
 
93
  if(!$cast(rhs_, rhs)) begin
94
    `uvm_error("do_copy", "cast of rhs object failed")
95
    return 0;
96
  end
97
  return super.do_compare(rhs, comparer) &&
98
         addr == rhs_.addr &&
99
         wdata == rhs_.wdata &&
100
         rw   == rhs_.rw &&
101
         slv_err == rhs_.slv_err &&
102
         rdata == rhs_.rdata;
103
  // Delay is not relevant to the comparison
104
endfunction:do_compare
105
 
106
function string wb_slave_seq_item::convert2string();
107
  string s;
108
 
109
  $sformat(s, "%s\n", super.convert2string());
110
  // Convert to string function reusing s:
111
  $sformat(s, "%s\n addr\t%0h\n wdata\t%0h\n rw\t%0b\n", s, addr, wdata, rw);
112
  $sformat(s, "%s\n slv_err\t%0b\n rdata\t%0h\n delay\t%0d\n", s, slv_err, rdata, delay);
113
  return s;
114
 
115
endfunction:convert2string
116
 
117
function void wb_slave_seq_item::do_print(uvm_printer printer);
118
  if(printer.knobs.sprint == 0) begin
119
    $display(convert2string());
120
  end
121
  else begin
122
    printer.m_string = convert2string();
123
  end
124
endfunction:do_print
125
 
126
function void wb_slave_seq_item:: do_record(uvm_recorder recorder);
127
  super.do_record(recorder);
128
 
129
  // Use the record macros to record the item fields:
130
  `uvm_record_field("addr", addr)
131
  `uvm_record_field("wdata", wdata)
132
  `uvm_record_field("rdata", rdata)
133
  `uvm_record_field("rw", rw)
134
  `uvm_record_field("slv_err", slv_err)
135
  `uvm_record_field("delay", delay)
136
endfunction:do_record
137
 

powered by: WebSVN 2.1.0

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