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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [PCIe/] [sim/] [src/] [pcie_bfm_pkg.sv] - Blame information for rev 32

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 32 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
// --------------------------------------------------------------------
30
//
31
package pcie_bfm_pkg;
32
 
33
  // --------------------------------------------------------------------
34
  //
35
  import pcie_common_pkg::*;
36
 
37
 
38
  // --------------------------------------------------------------------
39
  //
40
  class altera_pcie_transaction;
41
 
42
    tlp_header_class hd_h;
43
    byte packet[];
44
 
45
 
46
    //--------------------------------------------------------------------
47
    //
48
    function new(tlp_header_class hd_h, bit qword_aligned);
49
      this.hd_h = hd_h;
50
      if(qword_aligned & hd_h.fmt_type[5] == 0)
51
        if(hd_h.length == 0)
52
          this.packet = new[1024 + 1];
53
        else
54
          this.packet = new[hd_h.length + 1];
55
      else
56
        if(hd_h.length == 0)
57
          this.packet = new[1024];
58
        else
59
          this.packet = new[hd_h.length];
60
    endfunction: new
61
 
62
 
63
  // --------------------------------------------------------------------
64
  //
65
  endclass: altera_pcie_transaction
66
 
67
 
68
  // // --------------------------------------------------------------------
69
  // //
70
  // class base_tlp_packet_class;
71
 
72
    // tlp_type_t        header_type       = Reserved;
73
    // tlp_routing_t     routing_type      = ROUTING_UNKNOWN;
74
    // tlp_transaction_t transaction_type  = TRANSACTION_UNKNOWN;
75
    // logic [7:0] fmt_type;
76
    // logic [2:0] tc;
77
    // logic       th;
78
    // logic [2:0] attr;
79
    // logic       td;
80
    // logic       ep;
81
    // logic [9:0] length;
82
    // logic [7:0] header [16];
83
    // logic       header_is_4_dw;
84
 
85
 
86
    // // --------------------------------------------------------------------
87
    // //
88
    // function tlp_type_t get_tlp_type(logic [7:0] fmt_type);
89
 
90
      // casez(fmt_type)
91
        // 8'b000_00000: get_tlp_type = MRd;
92
        // 8'b001_00000: get_tlp_type = MRd;
93
        // 8'b000_00001: get_tlp_type = MRdLk;
94
        // 8'b001_00001: get_tlp_type = MRdLk;
95
        // 8'b010_00000: get_tlp_type = MWr;
96
        // 8'b011_00000: get_tlp_type = MWr;
97
        // 8'b000_00010: get_tlp_type = IORd;
98
        // 8'b010_00010: get_tlp_type = IOWr;
99
        // 8'b000_00100: get_tlp_type = CfgRd0;
100
        // 8'b010_00100: get_tlp_type = CfgWr0;
101
        // 8'b000_00101: get_tlp_type = CfgRd1;
102
        // 8'b010_00101: get_tlp_type = CfgWr1;
103
        // 8'b000_11011: get_tlp_type = TCfgRd;
104
        // 8'b010_11011: get_tlp_type = TCfgWr;
105
        // 8'b001_10???: get_tlp_type = Msg;
106
        // 8'b011_10???: get_tlp_type = MsgD;
107
        // 8'b000_01010: get_tlp_type = Cpl;
108
        // 8'b010_01010: get_tlp_type = CplD;
109
        // 8'b000_01011: get_tlp_type = CplLk;
110
        // 8'b010_01011: get_tlp_type = CplDLk;
111
        // 8'b010_01100: get_tlp_type = FetchAdd;
112
        // 8'b011_01100: get_tlp_type = FetchAdd;
113
        // 8'b010_01101: get_tlp_type = Swap;
114
        // 8'b011_01101: get_tlp_type = Swap;
115
        // 8'b010_01110: get_tlp_type = CAS;
116
        // 8'b011_01110: get_tlp_type = CAS;
117
        // 8'b100_0????: get_tlp_type = LPrfx;
118
        // 8'b100_1????: get_tlp_type = EPrfx;
119
        // default:      get_tlp_type = Reserved;
120
      // endcase
121
 
122
    // endfunction: get_tlp_type
123
 
124
 
125
    // // --------------------------------------------------------------------
126
    // //
127
    // function tlp_routing_t get_tlp_routing(tlp_type_t tlp_type);
128
 
129
      // case(tlp_type)
130
        // MRd:      get_tlp_routing = ADDRESS;
131
        // MRdLk:    get_tlp_routing = ADDRESS;
132
        // MWr:      get_tlp_routing = ADDRESS;
133
        // IORd:     get_tlp_routing = ADDRESS;
134
        // IOWr:     get_tlp_routing = ADDRESS;
135
        // CfgRd0:   get_tlp_routing = ID;
136
        // CfgWr0:   get_tlp_routing = ID;
137
        // CfgRd1:   get_tlp_routing = ID;
138
        // CfgWr1:   get_tlp_routing = ID;
139
        // TCfgRd:   get_tlp_routing = ID;
140
        // TCfgWr:   get_tlp_routing = ID;
141
        // Msg:      get_tlp_routing = ROUTING_UNKNOWN;
142
        // MsgD:     get_tlp_routing = ROUTING_UNKNOWN;
143
        // Cpl:      get_tlp_routing = ID;
144
        // CplD:     get_tlp_routing = ID;
145
        // CplLk:    get_tlp_routing = ID;
146
        // CplDLk:   get_tlp_routing = ID;
147
        // FetchAdd: get_tlp_routing = ROUTING_UNKNOWN;
148
        // Swap:     get_tlp_routing = ROUTING_UNKNOWN;
149
        // CAS:      get_tlp_routing = ROUTING_UNKNOWN;
150
        // LPrfx:    get_tlp_routing = ROUTING_UNKNOWN;
151
        // EPrfx:    get_tlp_routing = ROUTING_UNKNOWN;
152
        // default:  get_tlp_routing = ROUTING_UNKNOWN;
153
      // endcase
154
 
155
    // endfunction: get_tlp_routing
156
 
157
 
158
    // // --------------------------------------------------------------------
159
    // //
160
    // function tlp_transaction_t get_tlp_transaction(tlp_type_t tlp_type);
161
 
162
      // case(tlp_type)
163
        // MRd:      get_tlp_transaction = REQUESTER;
164
        // MRdLk:    get_tlp_transaction = REQUESTER;
165
        // MWr:      get_tlp_transaction = REQUESTER;
166
        // IORd:     get_tlp_transaction = REQUESTER;
167
        // IOWr:     get_tlp_transaction = REQUESTER;
168
        // CfgRd0:   get_tlp_transaction = REQUESTER;
169
        // CfgWr0:   get_tlp_transaction = REQUESTER;
170
        // CfgRd1:   get_tlp_transaction = REQUESTER;
171
        // CfgWr1:   get_tlp_transaction = REQUESTER;
172
        // TCfgRd:   get_tlp_transaction = REQUESTER;
173
        // TCfgWr:   get_tlp_transaction = REQUESTER;
174
        // Msg:      get_tlp_transaction = REQUESTER;
175
        // MsgD:     get_tlp_transaction = REQUESTER;
176
        // Cpl:      get_tlp_transaction = COMPLETER;
177
        // CplD:     get_tlp_transaction = COMPLETER;
178
        // CplLk:    get_tlp_transaction = COMPLETER;
179
        // CplDLk:   get_tlp_transaction = COMPLETER;
180
        // FetchAdd: get_tlp_transaction = TRANSACTION_UNKNOWN;
181
        // Swap:     get_tlp_transaction = TRANSACTION_UNKNOWN;
182
        // CAS:      get_tlp_transaction = TRANSACTION_UNKNOWN;
183
        // LPrfx:    get_tlp_transaction = TRANSACTION_UNKNOWN;
184
        // EPrfx:    get_tlp_transaction = TRANSACTION_UNKNOWN;
185
        // default:  get_tlp_transaction = TRANSACTION_UNKNOWN;
186
      // endcase
187
 
188
    // endfunction: get_tlp_transaction
189
 
190
 
191
    // // --------------------------------------------------------------------
192
    // //
193
    // function void display_tlp_cfg(tlp_type_t tlp_type);
194
 
195
      // logic [5:0] Register_Number = header[11][7:2];
196
      // logic [3:0] Extended_Register_Number = header[10][3:0];
197
 
198
      // // $display("??? %16.t | Register_Number           = %b", $time, Register_Number);
199
      // // $display("??? %16.t | Extended_Register_Number  = %b", $time, Extended_Register_Number);
200
      // $display("??? %16.t | config offset             = 0x%5.x",
201
                // $time, {Extended_Register_Number, Register_Number, 2'b00});
202
 
203
    // endfunction: display_tlp_cfg
204
 
205
 
206
    // // --------------------------------------------------------------------
207
    // //
208
    // function void display_tlp_type(tlp_type_t tlp_type);
209
 
210
      // case(tlp_type)
211
        // // MRd:      get_tlp_transaction = REQUESTER;
212
        // // MRdLk:    get_tlp_transaction = REQUESTER;
213
        // // MWr:      get_tlp_transaction = REQUESTER;
214
        // // IORd:     get_tlp_transaction = REQUESTER;
215
        // // IOWr:     get_tlp_transaction = REQUESTER;
216
        // CfgRd0:   display_tlp_cfg(tlp_type);
217
        // CfgWr0:   display_tlp_cfg(tlp_type);
218
        // CfgRd1:   display_tlp_cfg(tlp_type);
219
        // CfgWr1:   display_tlp_cfg(tlp_type);
220
        // TCfgRd:   display_tlp_cfg(tlp_type);
221
        // TCfgWr:   display_tlp_cfg(tlp_type);
222
        // // Msg:      get_tlp_transaction = REQUESTER;
223
        // // MsgD:     get_tlp_transaction = REQUESTER;
224
        // // Cpl:      get_tlp_transaction = COMPLETER;
225
        // // CplD:     get_tlp_transaction = COMPLETER;
226
        // // CplLk:    get_tlp_transaction = COMPLETER;
227
        // // CplDLk:   get_tlp_transaction = COMPLETER;
228
        // // FetchAdd: get_tlp_transaction = TRANSACTION_UNKNOWN;
229
        // // Swap:     get_tlp_transaction = TRANSACTION_UNKNOWN;
230
        // // CAS:      get_tlp_transaction = TRANSACTION_UNKNOWN;
231
        // // LPrfx:    get_tlp_transaction = TRANSACTION_UNKNOWN;
232
        // // EPrfx:    get_tlp_transaction = TRANSACTION_UNKNOWN;
233
        // default:  return;
234
      // endcase
235
 
236
    // endfunction: display_tlp_type
237
 
238
 
239
    // // --------------------------------------------------------------------
240
    // //
241
    // function void set_little_endian_header( logic [127:0] data);
242
 
243
      // logic [2:0] fmt = data[7:5];
244
 
245
      // if(fmt > 3'b011)
246
      // begin
247
        // $display("!!! %16.t | fmt 3'b%b not supported", $time, fmt);
248
        // $stop;
249
      // end
250
 
251
      // header_is_4_dw = data[5];
252
 
253
      // for(int i = 0; i < (header_is_4_dw ? 16 : 12); i += 4)
254
        // {header[i + 0], header[i + 1], header[i + 2], header[i + 3]} = data[i*8 +: 32];
255
 
256
      // header_type      = get_tlp_type(header[0]);
257
      // routing_type     = get_tlp_routing(header_type);
258
      // transaction_type = get_tlp_transaction(header_type);
259
 
260
      // fmt_type = header[0];
261
      // tc       = header[1][6:4];
262
      // th       = header[1][0];
263
      // attr     = {header[1][2], header[2][5:4]};
264
      // td       = header[2][7];
265
      // ep       = header[2][6];
266
      // length   = {header[2][1:0], header[3]};
267
 
268
    // endfunction: set_little_endian_header
269
 
270
 
271
    // // --------------------------------------------------------------------
272
    // //
273
    // function void display_header(string str);
274
 
275
      // $display("??? %16.t | .....................", $time);
276
      // $display("??? %16.t | %s | TLP type | %s", $time, str, header_type.name);
277
      // // $display("??? %16.t | fmt           = %b | type = %b", $time, fmt_type[7:5], fmt_type[4:0]);
278
      // $display("??? %16.t | length = %d", $time, length);
279
      // $display("??? %16.t | tc = %b | th = %b | attr = %b | td = %b | ep = %b",
280
                // $time, tc, th, attr, td, ep);
281
 
282
      // if(routing_type == ADDRESS)
283
        // if(header_is_4_dw)
284
          // $display("??? %16.t | address[63:0] = 0x%16.x", $time,
285
                    // { header[8],  header[9],  header[10], header[11],
286
                      // header[12], header[13], header[14], header[15][7:2], 2'b00});
287
        // else
288
          // $display("??? %16.t | address[31:0] = 0x%8.x", $time,
289
                    // { header[8],  header[9],  header[10], header[11][7:2], 2'b00});
290
      // else if(routing_type == ID)
291
          // $display("??? %16.t | bus = 0x%2.x | device = 0x%x | function = 0x%x", $time,
292
                    // header[8],  header[9][7:3],  header[9][2:0]);
293
 
294
      // if(transaction_type == COMPLETER)
295
      // begin
296
        // $display("??? %16.t | Completer ID  = %b", $time, {header[4], header[5]});
297
        // $display("??? %16.t | requester ID  = %b", $time, {header[8], header[9]});
298
        // $display("??? %16.t | tag           = %b", $time, header[10]);
299
      // end
300
      // else
301
      // begin
302
        // $display("??? %16.t | requester ID  = %b", $time, {header[4], header[5]});
303
        // $display("??? %16.t | tag           = %b", $time, header[6]);
304
        // $display("??? %16.t | last DW BE = %b | first DW BE = %b",
305
                  // $time, header[7][7:4], header[7][3:0]);
306
      // end
307
 
308
      // display_tlp_type(header_type);
309
 
310
      // $display("??? %16.t | ---------------------", $time);
311
 
312
    // endfunction: display_header
313
 
314
 
315
    // // //--------------------------------------------------------------------
316
    // // //
317
    // // function new;
318
 
319
    // // endfunction: new
320
 
321
 
322
  // // --------------------------------------------------------------------
323
  // //
324
  // endclass: base_tlp_packet_class
325
 
326
 
327
// --------------------------------------------------------------------
328
//
329
endpackage: pcie_bfm_pkg
330
 
331
 

powered by: WebSVN 2.1.0

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