7 int Nvals[] = {100, 200, 500, 1000, 5000, 10000, 20000, 50000, 100000};
13 `uvm_component_utils_end
18 function new(
string name =
"cl_scb_test_benchmark", uvm_component parent = null);
19 super.new(name, parent);
25 extern function void test(
int N,
string fname);
26 extern function void log_time(
string fname);
27 extern function real get_time_diff(
string file1,
string file2);
28 extern function void pre_build();
31 function void cl_scb_test_benchmark::pre_build();
33 this.syoscb_cfgs.syoscb_cfg[0].set_compare_type(pk_syoscb::SYOSCB_COMPARE_OOO);
34 this.syoscb_cfgs.syoscb_cfg[0].set_disable_clone(1
'b0); 35 void'(this.syoscb_cfgs.syoscb_cfg[0].set_primary_queue(
"Q2"));
36 endfunction: pre_build
41 function void cl_scb_test_benchmark::test(
int N,
string fname);
42 cl_tb_seq_item items[];
48 foreach(items[i]) begin
49 items[i] = cl_tb_seq_item::type_id::create($sformatf(
"items[%0d]", i));
50 if(!items[i].randomize()) begin
51 `uvm_fatal(
"RAND", $sformatf(
"Unable to randomize items[%0d]", i))
55 foreach(items[i]) begin
56 this.scb_env.syoscb[0].add_item(
"Q1",
"P1", items[i]);
61 foreach(items[i]) begin
62 this.scb_env.syoscb[0].add_item(
"Q2",
"P1", items[i]);
65 time_diff = get_time_diff(
"t0",
"t1");
66 if(this.scb_env.syoscb[0].get_total_queue_size() != 0) begin
67 `uvm_fatal(
"ERR", $sformatf(
"Total queue size was not 0, is %0d", this.scb_env.syoscb[0].get_total_queue_size()))
70 fd = $fopen(fname,
"a");
71 $fwrite(fd, $sformatf(
"%0d, %0f\n", N, time_diff));
72 $display(
"N: %0d, time: %0f", N, time_diff);
77 function void cl_scb_test_benchmark::log_time(
string fname);
78 $system($sformatf(
"date -Ins > %0s.time", fname));
82 function real cl_scb_test_benchmark::get_time_diff(
string file1,
string file2);
84 string t1, t2, s1, s2, m1, m2, h1, h2;
85 real S1, S2, M1, M2, H1, H2;
88 f1 = $fopen($sformatf(
"%0s.time", file1),
"r");
89 f2 = $fopen($sformatf(
"%0s.time", file2),
"r");
91 void'($fgets(t1, f1)); 92 void'($fgets(t2, f2));
96 h1 = t1.substr(11, 12);
97 h2 = t2.substr(11, 12);
98 m1 = t1.substr(14, 15);
99 m2 = t2.substr(14, 15);
100 s1 = t1.substr(17, 28);
101 s2 = t2.substr(17, 28);
113 a = (H2-H1)*3600 + (M2-M1)*60 + S2-S1;
119 endfunction: get_time_diff
132 `uvm_component_utils_begin(cl_scb_test_benchmark_std)
134 `uvm_component_utils_end
139 function new(string name = "cl_scb_test_benchmark_std", uvm_component parent = null);
140 super.new(name, parent);
147 function void pre_build();
149 this.syoscb_cfgs.syoscb_cfg[0].set_queue_type(pk_syoscb::SYOSCB_QUEUE_STD);
150 endfunction: pre_build
152 task main_phase(uvm_phase phase);
154 phase.raise_objection(this);
155 super.main_phase(phase);
157 $fclose($fopen("std_log.txt", "w"));
159 foreach(this.Nvals[i]) begin
160 this.test(this.Nvals[i], "std_log.txt");
163 phase.drop_objection(this);
165 endclass: cl_scb_test_benchmark_std
178 `uvm_component_utils_begin(cl_scb_test_benchmark_md5)
180 `uvm_component_utils_end
185 function new(string name = "cl_scb_test_benchmark_md5", uvm_component parent = null);
186 super.new(name, parent);
192 function void pre_build();
194 this.syoscb_cfgs.syoscb_cfg[0].set_ordered_next(1'b0);
195 this.syoscb_cfgs.syoscb_cfg[0].set_queue_type(pk_syoscb::SYOSCB_QUEUE_MD5);
196 endfunction: pre_build
198 task main_phase(uvm_phase phase);
200 phase.raise_objection(this);
201 super.main_phase(phase);
203 $fclose($fopen("md5_log.txt", "w"));
204 foreach(this.Nvals[i]) begin
205 this.test(this.Nvals[i], "md5_log.txt");
208 phase.drop_objection(this);
210 endclass: cl_scb_test_benchmark_md5
222 `uvm_component_utils_begin(cl_scb_test_benchmark_md5_on)
224 `uvm_component_utils_end
229 function new(string name = "cl_scb_test_benchmark_md5", uvm_component parent = null);
230 super.new(name, parent);
236 function void pre_build();
238 this.syoscb_cfgs.syoscb_cfg[0].set_ordered_next(1'b1);
239 this.syoscb_cfgs.syoscb_cfg[0].set_queue_type(pk_syoscb::SYOSCB_QUEUE_MD5);
240 endfunction: pre_build
242 task main_phase(uvm_phase phase);
244 phase.raise_objection(this);
245 super.main_phase(phase);
247 $fclose($fopen("md5_on_log.txt", "w"));
248 foreach(this.Nvals[i]) begin
249 this.test(this.Nvals[i], "md5_on_log.txt");
252 phase.drop_objection(this);
254 endclass: cl_scb_test_benchmark_md5_on
Benchmark to compare performance of STD and Hash queues when executing OOO compare.