forked from nguyensinhton9x/uvm_env_ver3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuvm_env_0712.sv
196 lines (144 loc) · 5.4 KB
/
uvm_env_0712.sv
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
//--------------------------------------
//Project: The UVM environemnt for UART (Universal Asynchronous Receiver Transmitter)
//Function: TOP UVM environment
// - cApbMasterDriver - APB master model
// - cApbMasterMonitor - APB master monitor
// - cApbMasterSequencer - APB master sequencer
// -
//Author: Pham Thanh Tram, Nguyen Sinh Ton, Doan Duc Hoang, Truong Cong Hoang Viet, Nguyen Hung Quan
//Page: VLSI Technology
//--------------------------------------
typedef class cApbMasterAgent;
class cApbMasterSequencer extends uvm_sequencer#(cApbTransaction);
cApbMasterAgent coApbMasterAgent;
virtual ifInterrupt vifInterrupt;
`uvm_component_utils(cApbMasterSequencer)
function new (string name = "cApbMasterSequencer", uvm_component parent = null);
super.new(name,parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db#(virtual interface ifInterrupt)::get(this,"","vifInterrupt",vifInterrupt)) begin
`uvm_fatal("cVSequencer","Can't get vifInterrupt!!!")
end
endfunction
endclass
// Need to add other sequences (e.g. cApbMasterReadSeq)
class cApbMasterWriteSeq extends uvm_sequence#(cApbTransaction);
`uvm_object_utils(cApbMasterWriteSeq)
`uvm_declare_p_sequencer(cApbMasterSequencer)
rand logic [31:0] addr;
rand logic [31:0] data;
rand logic [ 3:0] be;
function new (string name = "cApbMasterWriteSeq");
super.new(name);
endfunction
virtual task body();
cApbTransaction coApbTransaction;
coApbTransaction = cApbTransaction::type_id::create("coApbTransaction");
start_item(coApbTransaction);
assert(coApbTransaction.randomize() with {
coApbTransaction.paddr == addr;
coApbTransaction.pwdata == data;
coApbTransaction.pstrb == be;
coApbTransaction.pwrite == 1;
});
finish_item(coApbTransaction);
endtask
endclass
class cApbMasterAgent extends uvm_agent;
cApbMasterDriver coApbMasterDriver;
cApbMasterSequencer coApbMasterSequencer;
cApbMasterMonitor coApbMasterMonitor;
`uvm_component_utils(cApbMasterAgent)
function new(string name = "cApbMasterAgent", uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
coApbMasterDriver = cApbMasterDriver::type_id::create("coApbMasterDriver",this);
coApbMasterSequencer = cApbMasterSequencer::type_id::create("coApbMasterSequencer",this);
coApbMasterMonitor = cApbMasterMonitor::type_id::create("coApbMasterMonitor",this);
endfunction
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
coApbMasterDriver.seq_item_port.connect(coApbMasterSequencer.seq_item_export);
endfunction
endclass
class cVSequencer extends uvm_sequencer#(cApbTransaction);
//cApbMasterSequencer coApbMasterSequencerTx;
//cApbMasterSequencer coApbMasterSequencerRx;
cApbMasterAgent coApbMasterAgentTx;
cApbMasterAgent coApbMasterAgentRx;
cScoreboard coScoreboard;
`uvm_component_utils(cVSequencer)
// TODO: component must have variable "parent"
// object must not have veriable "parent" (refer to class cVSequence)
function new (string name = "cVSequencer", uvm_component parent = null);
super.new(name,parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
endfunction
endclass
class cVSequence extends uvm_sequence#(cApbTransaction);
`uvm_object_utils(cVSequence)
function new (string name = "cVSequence");
super.new(name);
endfunction
task body();
// Content of test pattern.
endtask
endclass
class cEnv extends uvm_env;
cApbMasterAgent coApbMasterAgentTx;
cApbMasterAgent coApbMasterAgentRx;
cScoreboard coScoreboard;
cVSequencer coVSequencer;
`uvm_component_utils(cEnv)
function new (string name = "cEnv", uvm_component parent = null);
super.new(name,parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
coApbMasterAgentTx = cApbMasterAgent::type_id::create("coApbMasterAgentTx",this);
coApbMasterAgentRx = cApbMasterAgent::type_id::create("coApbMasterAgentRx",this);
coScoreboard = cScoreboard::type_id::create("coScoreboard",this);
coVSequencer = cVSequencer::type_id::create("coVSequencer",this);
endfunction
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
$cast(coVSequencer.coApbMasterAgentTx, this.coApbMasterAgentTx);
$cast(coVSequencer.coApbMasterAgentRx, this.coApbMasterAgentRx);
$cast(coVSequencer.coScoreboard, this.coScoreboard);
coApbMasterAgentTx.coApbMasterMonitor.ap_toScoreboardWrite.connect(coScoreboard.aimp_frmMonitorWrite);
// Add more connection here
endfunction
endclass
class cTest extends uvm_test;
cEnv coEnv;
cVSequence coVSequence;
`uvm_component_utils(cTest)
function new (string name = "cTest", uvm_component parent = null);
super.new(name,parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
coEnv = cEnv::type_id::create("coEnv",this);
coVSequence = cVSequence::type_id::create("coVSequence");
endfunction
task run_phase(uvm_phase phase);
super.run_phase(phase);
`uvm_info(get_full_name(), "run phase completed.", UVM_LOW)
phase.raise_objection(this);
fork
coVSequence.start(coEnv.coVSequencer);
begin
#1ms;
`uvm_error("TEST SEQUENCE", "TIMEOUT!!!")
end
join_any
disable fork;
phase.drop_objection(this);
endtask
endclass