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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [PCIe/] [sim/] [src/] [pcie_monitor_pkg.sv] - Blame information for rev 42

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

powered by: WebSVN 2.1.0

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