1 |
50 |
qaztronic |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// Copyright (C) 2015 Authors and OPENCORES.ORG ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This source file may be used and distributed without ////
|
6 |
|
|
//// restriction provided that this copyright statement is not ////
|
7 |
|
|
//// removed from the file and that any derivative work contains ////
|
8 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
9 |
|
|
//// ////
|
10 |
|
|
//// This source file is free software; you can redistribute it ////
|
11 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
12 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
13 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
14 |
|
|
//// later version. ////
|
15 |
|
|
//// ////
|
16 |
|
|
//// This source is distributed in the hope that it will be ////
|
17 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
18 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
19 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
20 |
|
|
//// details. ////
|
21 |
|
|
//// ////
|
22 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
23 |
|
|
//// Public License along with this source; if not, download it ////
|
24 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
25 |
|
|
//// ////
|
26 |
|
|
//////////////////////////////////////////////////////////////////////
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
package bfm_pkg;
|
30 |
|
|
|
31 |
|
|
// --------------------------------------------------------------------
|
32 |
|
|
//
|
33 |
|
|
typedef enum
|
34 |
|
|
{
|
35 |
|
|
NONE,
|
36 |
|
|
REGULAR
|
37 |
|
|
// BURSTY
|
38 |
|
|
} traffic_type_e;
|
39 |
|
|
|
40 |
|
|
// --------------------------------------------------------------------
|
41 |
|
|
//
|
42 |
|
|
class delay_class;
|
43 |
|
|
|
44 |
|
|
rand int unsigned delay = 0;
|
45 |
|
|
|
46 |
|
|
// --------------------------------------------------------------------
|
47 |
|
|
//
|
48 |
|
|
virtual function void set_delay(traffic_type_e kind = REGULAR);
|
49 |
|
|
case(kind)
|
50 |
|
|
NONE: delay = 0;
|
51 |
|
|
REGULAR: assert(this.randomize() with{delay dist {0 := 60, [1:3] := 30, [4:7] := 10};});
|
52 |
|
|
default: delay = 0;
|
53 |
|
|
endcase
|
54 |
|
|
endfunction: set_delay
|
55 |
|
|
|
56 |
|
|
// --------------------------------------------------------------------
|
57 |
|
|
//
|
58 |
|
|
virtual function int next(traffic_type_e kind = REGULAR);
|
59 |
|
|
set_delay(kind);
|
60 |
|
|
return(delay);
|
61 |
|
|
endfunction: next
|
62 |
|
|
|
63 |
|
|
// --------------------------------------------------------------------
|
64 |
|
|
//
|
65 |
|
|
endclass: delay_class
|
66 |
|
|
|
67 |
|
|
// --------------------------------------------------------------------
|
68 |
|
|
//
|
69 |
|
|
virtual class transaction_class #(parameter type TR_T);
|
70 |
|
|
|
71 |
|
|
delay_class delay_h;
|
72 |
|
|
|
73 |
|
|
// --------------------------------------------------------------------
|
74 |
|
|
//
|
75 |
|
|
function void random;
|
76 |
|
|
assert(this.randomize());
|
77 |
|
|
endfunction: random
|
78 |
|
|
|
79 |
|
|
//--------------------------------------------------------------------
|
80 |
|
|
//
|
81 |
|
|
function new;
|
82 |
|
|
delay_h = new();
|
83 |
|
|
endfunction: new
|
84 |
|
|
|
85 |
|
|
// --------------------------------------------------------------------
|
86 |
|
|
//
|
87 |
|
|
pure virtual function void copy(TR_T from);
|
88 |
|
|
|
89 |
|
|
// --------------------------------------------------------------------
|
90 |
|
|
//
|
91 |
|
|
function automatic TR_T clone;
|
92 |
|
|
TR_T child;
|
93 |
|
|
clone = new();
|
94 |
|
|
$cast(child, this);
|
95 |
|
|
clone.copy(child);
|
96 |
|
|
return(clone);
|
97 |
|
|
endfunction: clone
|
98 |
|
|
|
99 |
|
|
// --------------------------------------------------------------------
|
100 |
|
|
//
|
101 |
|
|
endclass: transaction_class
|
102 |
|
|
|
103 |
|
|
//--------------------------------------------------------------------
|
104 |
|
|
//
|
105 |
|
|
endpackage: bfm_pkg
|
106 |
|
|
|