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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [avalon_lib/] [sim/] [src/] [amm_bfm/] [amm_transaction_pkg.sv] - Blame information for rev 31

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 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 amm_transaction_pkg;
30
 
31
  // --------------------------------------------------------------------
32
  //
33
  class amm_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: amm_delay_class
52
 
53
 
54
  // --------------------------------------------------------------------
55
  //
56
  class amm_payload_class #(N = 8, B = 1);
57
 
58
    rand logic [(8*N)-1:0]  w[];
59
 
60
 
61
    // --------------------------------------------------------------------
62
    //
63
    function
64
      new
65
      (
66
        logic [B-1:0] burstcount = 0
67
      );
68
 
69
      this.w  = new[burstcount + 1];
70
 
71
    endfunction: new
72
 
73
 
74
    // --------------------------------------------------------------------
75
    //
76
    function void
77
      random
78
      (
79
        logic [B-1:0] burstcount = 0
80
      );
81
 
82
      this.w = new[burstcount + 1];
83
      assert(this.randomize());
84
 
85
    endfunction: random
86
 
87
 
88
  // --------------------------------------------------------------------
89
  //
90
  endclass: amm_payload_class
91
 
92
 
93
  // --------------------------------------------------------------------
94
  //
95
  class amm_transaction_class #(A = 32, N = 8, B = 1);
96
 
97
    amm_delay_class delay_h;
98
    amm_payload_class #(.N(N), .B(B)) payload_h;
99
    amm_payload_class #(.N(N), .B(B)) data_h;
100
    rand logic  [(A-1):0]   address = 'bz;
101
    rand logic  [N-1:0]     byteenable = {N{1'b1}};
102
    rand logic  [B-1:0]     burstcount = 1;
103
 
104
    constraint default_burstcount
105
    {
106
      burstcount dist {0 := 40, [1:15] := 40, [16:255] := 20};
107
    }
108
 
109
 
110
    // --------------------------------------------------------------------
111
    //
112
    function
113
      new
114
      (
115
        logic [B-1:0] burstcount = 0
116
      );
117
 
118
      this.payload_h  = new(burstcount + 1);
119
      this.delay_h    = new;
120
 
121
    endfunction: new
122
 
123
 
124
    // --------------------------------------------------------------------
125
    //
126
    function void
127
      basic_random;
128
 
129
      assert(this.randomize() with
130
      {
131
        this.burstcount == 1;
132
      });
133
 
134
      this.payload_h.random(this.burstcount);
135
 
136
    endfunction: basic_random
137
 
138
 
139
    // // --------------------------------------------------------------------
140
    // //
141
    // function void
142
      // basic_random_burst;
143
 
144
      // assert(this.randomize() with
145
      // {
146
        // this.addr[$clog2(N*8)-1:0] == 0;
147
        // this.id == 0;
148
        // this.resp == 0;
149
        // this.burst == 2'b01;
150
        // this.size == $clog2(N);
151
        // this.len dist {0 := 40, [1:3] := 40, [4:15] := 20};
152
      // });
153
 
154
      // this.payload_h.random(this.len);
155
 
156
    // endfunction: basic_random_burst
157
 
158
 
159
    // --------------------------------------------------------------------
160
    //
161
    function void
162
      basic_read
163
      (
164
        logic [(A-1):0] address,
165
        logic [B-1:0] burstcount = 1
166
      );
167
 
168
      this.address = address;
169
      this.burstcount = burstcount;
170
      this.payload_h.random(burstcount);
171
 
172
    endfunction: basic_read
173
 
174
 
175
    // --------------------------------------------------------------------
176
    //
177
    function void
178
      basic_write
179
      (
180
        logic [(A-1):0] address,
181
        logic [B-1:0] burstcount = 1
182
      );
183
 
184
      this.address = address;
185
      this.burstcount = burstcount;
186
      this.payload_h.random(burstcount);
187
 
188
    endfunction: basic_write
189
 
190
 
191
    // --------------------------------------------------------------------
192
    //
193
    function void copy
194
    (
195
      amm_transaction_class #(.A(A), .N(N), .B(B)) from
196
    );
197
 
198
      this.address    = from.address;
199
      this.byteenable = from.byteenable;
200
      this.burstcount = from.burstcount;
201
 
202
    endfunction: copy
203
 
204
 
205
    // --------------------------------------------------------------------
206
    //
207
    virtual function amm_transaction_class #(.A(A), .N(N), .B(B)) clone;
208
 
209
      clone = new();
210
      clone.copy(this);
211
      return(clone);
212
 
213
    endfunction: clone
214
 
215
 
216
  // --------------------------------------------------------------------
217
  //
218
  endclass: amm_transaction_class
219
 
220
 
221
// --------------------------------------------------------------------
222
//
223
endpackage: amm_transaction_pkg
224
 

powered by: WebSVN 2.1.0

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