-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrggen_ral_rowo_field.svh
118 lines (99 loc) · 2.78 KB
/
rggen_ral_rowo_field.svh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
class rggen_ral_rowo_field extends rggen_ral_field;
local static string access_name = "ROWO";
local static bit defined = define_access(access_name);
protected uvm_reg_data_t m_read_mirrored;
function new(string name);
super.new(name);
endfunction
function string get_access(uvm_reg_map map = null);
uvm_reg parent;
if (map == uvm_reg_map::backdoor()) begin
return access_name;
end
parent = get_parent();
case (parent.get_rights(map))
"WO": return "WO";
"RO": return "RO";
default: return access_name;
endcase
endfunction
function bit is_writable(uvm_reg_map map = null);
return get_access(map) != "RO";
endfunction
function bit is_readable(uvm_reg_map map = null);
return get_access(map) != "WO";
endfunction
function bit is_known_access(uvm_reg_map map = null);
return 1;
endfunction
virtual function uvm_reg_data_t get_write_mirrored_value(
string fname,
int lineno
);
return get_mirrored_value(fname, lineno);
endfunction
virtual function uvm_reg_data_t get_read_mirrored_value(
string fname,
int lineno
);
// set fname and lineno
void'(get(fname, lineno));
return m_read_mirrored;
endfunction
function bit needs_update();
uvm_reg_data_t mirrored_value;
uvm_reg_data_t desired_value;
mirrored_value = get_mirrored_value();
desired_value = get();
return mirrored_value != desired_value;
endfunction
function void do_predict(
uvm_reg_item rw,
uvm_predict_e kind = UVM_PREDICT_DIRECT,
uvm_reg_byte_en_t be = -1
);
if (kind == UVM_PREDICT_READ) begin
do_read_predict(rw, be);
end
else begin
super.do_predict(rw, kind, be);
end
endfunction
function uvm_reg_data_t XpredictX(
uvm_reg_data_t cur_val,
uvm_reg_data_t wr_val,
uvm_reg_map map
);
if (is_writable(map)) begin
return wr_val;
end
else begin
return cur_val;
end
endfunction
protected virtual function void do_read_predict(
uvm_reg_item rw,
uvm_reg_byte_en_t be
);
uvm_reg_data_t mask;
uvm_reg_data_t field_value;
uvm_reg_field_cb_iter cbs;
// set fname and lineno
void'(get(rw.fname, rw.lineno));
if (rw.path inside {UVM_FRONTDOOR, UVM_PREDICT}) begin
if (!is_readable(rw.map)) begin
return;
end
end
mask = (1 << get_n_bits()) - 1;
field_value = rw.value[0] & mask;
// process callbacks
cbs = new(this);
for (uvm_reg_cbs cb = cbs.first();cb != null;cb = cbs.next()) begin
cb.post_predict(
this, m_read_mirrored, field_value, UVM_PREDICT_READ, rw.path, rw.map
);
end
m_read_mirrored = field_value & mask;
endfunction
endclass