OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_lib/] [sim/] [src/] [axi4_bfm/] [axi4_transaction_pkg.sv] - Blame information for rev 29

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 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 axi4_transaction_pkg;
30
 
31
  // --------------------------------------------------------------------
32
  //
33
  class axi4_delay_class;
34
 
35
    rand int unsigned delay;
36
 
37
 
38
    // --------------------------------------------------------------------
39
    //
40
    function int unsigned
41
      next;
42
 
43
      assert(this.randomize() with{delay dist {0 := 40, [1:3] := 40, [4:7] := 20};});
44
      return(delay);
45
 
46
    endfunction: next
47
 
48
 
49
  // --------------------------------------------------------------------
50
  //
51
  endclass: axi4_delay_class
52
 
53
 
54
  // --------------------------------------------------------------------
55
  //
56
  class axi4_payload_class #(N = 8);
57
 
58
    rand logic [(8*N)-1:0]  w[];
59
 
60
 
61
    // --------------------------------------------------------------------
62
    //
63
    function
64
      new
65
      (
66
        logic [7:0] len = 0
67
      );
68
 
69
      this.w  = new[len + 1];
70
 
71
    endfunction: new
72
 
73
 
74
    // --------------------------------------------------------------------
75
    //
76
    function void
77
      random
78
      (
79
        logic [7:0] len = 0
80
      );
81
 
82
      this.w = new[len + 1];
83
      assert(this.randomize());
84
 
85
    endfunction: random
86
 
87
 
88
  // --------------------------------------------------------------------
89
  //
90
  endclass: axi4_payload_class
91
 
92
 
93
  // --------------------------------------------------------------------
94
  //
95
  class axi4_transaction_class #(A = 32, N = 8, I = 1);
96
 
97
    axi4_delay_class delay_h;
98
    axi4_payload_class #(.N(N)) payload_h;
99
    axi4_payload_class #(.N(N)) data_h;
100
    rand logic [(A-1):0]    addr = 'bz;
101
    rand logic [1:0]        burst = 2'b01;
102
    rand logic [7:0]        len = 0;
103
    rand logic [2:0]        size = $clog2(N);
104
    rand logic [(I-1):0]    id = 0;
105
    rand logic [1:0]        resp = 0;
106
 
107
    logic [3:0] cache   = 0;
108
    logic       lock    = 0;
109
    logic [2:0] prot    = 0;
110
    logic [3:0] qos     = 0;
111
    logic [3:0] region  = 0;
112
 
113
    constraint default_len
114
    {
115
      len dist {0 := 40, [1:15] := 40, [16:255] := 20};
116
    }
117
 
118
 
119
    // --------------------------------------------------------------------
120
    //
121
    function
122
      new
123
      (
124
        logic [7:0] len = 0
125
      );
126
 
127
      this.payload_h  = new(len + 1);
128
      this.delay_h    = new;
129
 
130
    endfunction: new
131
 
132
 
133
    // --------------------------------------------------------------------
134
    //
135
    function void
136
      basic_random;
137
 
138
      assert(this.randomize() with
139
      {
140
        this.id == 0;
141
        this.resp == 0;
142
        this.burst == 2'b01;
143
        this.len == 0;
144
        this.size == $clog2(N);
145
      });
146
 
147
      this.payload_h.random(this.len);
148
 
149
    endfunction: basic_random
150
 
151
 
152
    // --------------------------------------------------------------------
153
    //
154
    function void
155
      basic_random_burst;
156
 
157
      assert(this.randomize() with
158
      {
159
        this.addr[$clog2(N*8)-1:0] == 0;
160
        this.id == 0;
161
        this.resp == 0;
162
        this.burst == 2'b01;
163
        this.size == $clog2(N);
164
        this.len dist {0 := 40, [1:3] := 40, [4:15] := 20};
165
      });
166
 
167
      this.payload_h.random(this.len);
168
 
169
    endfunction: basic_random_burst
170
 
171
 
172
    // --------------------------------------------------------------------
173
    //
174
    function void
175
      basic_read
176
      (
177
        logic [(A-1):0] addr,
178
        logic [7:0] len = 0
179
      );
180
 
181
      this.id = 0;
182
      this.resp = 0;
183
      this.burst = 2'b01;
184
      this.size = $clog2(N);
185
      this.addr = addr;
186
      this.len = len;
187
      this.payload_h.random(len);
188
 
189
    endfunction: basic_read
190
 
191
 
192
    // --------------------------------------------------------------------
193
    //
194
    function void
195
      basic_write
196
      (
197
        logic [(A-1):0] addr,
198
        logic [7:0] len = 0
199
      );
200
 
201
      this.id = 0;
202
      this.resp = 0;
203
      this.burst = 2'b01;
204
      this.size = $clog2(N);
205
      this.addr = addr;
206
      this.len = len;
207
      this.payload_h.random(len);
208
 
209
    endfunction: basic_write
210
 
211
 
212
    // --------------------------------------------------------------------
213
    //
214
    function void copy
215
    (
216
      axi4_transaction_class #(.A(A), .N(N), .I(I)) from
217
    );
218
 
219
      this.addr     = from.addr;
220
      this.burst    = from.burst;
221
      this.len      = from.len;
222
      this.size     = from.size;
223
      this.id       = from.id;
224
      this.resp     = from.resp;
225
      this.cache    = from.cache;
226
      this.lock     = from.lock;
227
      this.prot     = from.prot;
228
      this.qos      = from.qos;
229
      this.region   = from.region;
230
 
231
    endfunction: copy
232
 
233
 
234
    // --------------------------------------------------------------------
235
    //
236
    virtual function axi4_transaction_class #(.A(A), .N(N), .I(I)) clone;
237
 
238
      clone = new();
239
      clone.copy(this);
240
      return(clone);
241
 
242
    endfunction: clone
243
 
244
 
245
  // --------------------------------------------------------------------
246
  //
247
  endclass: axi4_transaction_class
248
 
249
 
250
// --------------------------------------------------------------------
251
//
252
endpackage: axi4_transaction_pkg
253
 

powered by: WebSVN 2.1.0

© copyright 1999-2019 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.