-
Notifications
You must be signed in to change notification settings - Fork 35
/
axi_test.sv
168 lines (130 loc) · 5.33 KB
/
axi_test.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
class axi_base_test extends uvm_test;
`uvm_component_utils(axi_base_test)
// Components
axi_env env;
axi_write_seq#(.D_WIDTH(D_WIDTH), .A_WIDTH(A_WIDTH)) wr_seq;
axi_read_seq#(.D_WIDTH(D_WIDTH), .A_WIDTH(A_WIDTH)) rd_seq;
// variables
env_config env_cfg;
test_config test_cfg;
function new(string name, uvm_component parent);
super.new(name, parent);
test_cfg = new("test_cfg");
test_cfg.no_write_cases = 20;
test_cfg.no_read_cases = 20;
endfunction //new()
// Function: build_phase
extern function void build_phase(uvm_phase phase);
// Function: end_of_elaboration_phase
extern function void end_of_elaboration_phase(uvm_phase phase);
// Function: run_phase
extern task run_phase(uvm_phase phase);
endclass //axi_base_test extends uvm_test
function void axi_base_test::build_phase(uvm_phase phase);
test_cfg.burst_type = -1;
uvm_config_db#(test_config)::set(null, "uvm_test_top.seq", "config", test_cfg);
wr_seq = new("wr_seq");
rd_seq = new("rd_seq");
env = axi_env::type_id::create("env", this);
endfunction: build_phase
function void axi_base_test::end_of_elaboration_phase(uvm_phase phase);
super.end_of_elaboration_phase(phase);
uvm_top.print_topology();
endfunction: end_of_elaboration_phase
task axi_base_test::run_phase(uvm_phase phase);
phase.raise_objection(this);
fork
wr_seq.start(env.master.w_seqr);
begin
#200;
rd_seq.start(env.master.r_seqr);
end
join
phase.drop_objection(this);
endtask: run_phase
// ****************************************************************************************
// Directed Test Cases
// ****************************************************************************************
class axi_write_test extends axi_base_test;
`uvm_component_utils(axi_write_test)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction //new()
function void build_phase(uvm_phase phase);
super.build_phase(phase);
endfunction: build_phase
function void end_of_elaboration_phase(uvm_phase phase);
super.end_of_elaboration_phase(phase);
endfunction: end_of_elaboration_phase
task run_phase(uvm_phase phase);
phase.raise_objection(this);
wr_seq.start(env.master.w_seqr);
phase.drop_objection(this);
endtask: run_phase
endclass //write_test extends axi_base_test
class axi_read_test extends axi_base_test;
`uvm_component_utils(axi_read_test)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction //new()
function void build_phase(uvm_phase phase);
super.build_phase(phase);
endfunction: build_phase
function void end_of_elaboration_phase(uvm_phase phase);
super.end_of_elaboration_phase(phase);
endfunction: end_of_elaboration_phase
task run_phase(uvm_phase phase);
phase.raise_objection(this);
wr_seq.start(env.master.w_seqr);
rd_seq.start(env.master.r_seqr);
phase.drop_objection(this);
endtask: run_phase
endclass //write_test extends axi_base_test
class axi_fixed_test extends axi_base_test;
`uvm_component_utils(axi_fixed_test)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction //new()
function void build_phase(uvm_phase phase);
test_cfg.burst_type = 0;
uvm_config_db#(test_config)::set(null, "uvm_test_top.seq", "config", test_cfg);
wr_seq = new("wr_seq");
rd_seq = new("rd_seq");
env = axi_env::type_id::create("env", this);
endfunction: build_phase
task run_phase(uvm_phase phase);
super.run_phase(phase);
endtask: run_phase
endclass //axi_fixed_test extends axi_base_test
class axi_incr_test extends axi_base_test;
`uvm_component_utils(axi_incr_test)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction //new()
function void build_phase(uvm_phase phase);
test_cfg.burst_type = 1;
uvm_config_db#(test_config)::set(null, "uvm_test_top.seq", "config", test_cfg);
wr_seq = new("wr_seq");
rd_seq = new("rd_seq");
env = axi_env::type_id::create("env", this);
endfunction: build_phase
task run_phase(uvm_phase phase);
super.run_phase(phase);
endtask: run_phase
endclass //axi_fixed_test extends axi_base_test
class axi_wrap_test extends axi_base_test;
`uvm_component_utils(axi_wrap_test)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction //new()
function void build_phase(uvm_phase phase);
test_cfg.burst_type = 2;
uvm_config_db#(test_config)::set(null, "uvm_test_top.seq", "config", test_cfg);
wr_seq = new("wr_seq");
rd_seq = new("rd_seq");
env = axi_env::type_id::create("env", this);
endfunction: build_phase
task run_phase(uvm_phase phase);
super.run_phase(phase);
endtask: run_phase
endclass //axi_fixed_test extends axi_base_test