-
Notifications
You must be signed in to change notification settings - Fork 63
/
p552.sv
39 lines (30 loc) · 851 Bytes
/
p552.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
function int[$] GenQueue(int low, int high);
int[$] q;
randsequence()
TOP : BOUND(low) LIST BOUND(high) ;
LIST : LIST ITEM := 8 { q = { q, ITEM }; }
| ITEM := 2 { q = { q, ITEM }; }
;
int ITEM : { return $urandom_range( low, high ); } ;
BOUND(int b) : { q = { q, b }; } ;
endsequence
GenQueue = q;
endfunction
class DSL;
endclass
module top;
initial begin
// class that creates valid DSL packets
randsequence (STREAM)
STREAM : GAP DATA := 80
| DATA := 20 ;
DATA : PACKET(0) := 94 { transmit( PACKET ); }
| PACKET(1) := 6 { transmit( PACKET ); } ;
DSL PACKET (bit bad) : { DSL d = new;
if( bad ) d.crc ^= 23;
return d;
};
GAP: { ## {$urandom_range( 1, 20 )}; };
endsequence
end
endmodule