-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestBad.sv
More file actions
42 lines (32 loc) · 1.02 KB
/
Copy pathTestBad.sv
File metadata and controls
42 lines (32 loc) · 1.02 KB
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
class bad_packet extends packet;
static int corruption_cnt;
virtual function automatic void calc_header_checksum();
int corrupt;
corrupt = $urandom_range(0,99);
header.calc_header_checksum();
if(corrupt < 2) begin
header.header_checksum = ~header.header_checksum;
corruption_cnt++;
end
endfunction
endclass // bad_packet
class TestBad extends component;
typedef registry #(TestBad, "TestBad") type_id;
Environment env;
virtual task run_test();
Driver_cbs_scoreboard sb_callback;
bad_packet badp;
$display("Running Good Test:");
env = new(1000);
env.build();
begin
sb_callback = new();
badp = new();
env.gen.blueprint = badp;
env.drv.cbs.push_back(sb_callback);
end
env.run();
$display("%0t:Send %0d Bad Packets",$time, bad_packet::corruption_cnt);
$display("%0t:Test Finished with %d comparisons.",$time, sb_callback.scb.num_compared);
endtask // run_test
endclass // TestBad