OpenCores
URL https://opencores.org/ocsvn/1000base-x/1000base-x/trunk

Subversion Repositories 1000base-x

[/] [1000base-x/] [trunk/] [testbench/] [rtl/] [verilog/] [tb_utils.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 dwp
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "tb_utils.v"                                         ////
4
////                                                              ////
5
////  This file is part of the :                                  ////
6
////                                                              ////
7
//// "1000BASE-X IEEE 802.3-2008 Clause 36 - PCS project"         ////
8
////                                                              ////
9
////  http://opencores.org/project,1000base-x                     ////
10
////                                                              ////
11
////  Author(s):                                                  ////
12
////      - D.W.Pegler Cambridge Broadband Networks Ltd           ////
13
////                                                              ////
14
////      { peglerd@gmail.com, dwp@cambridgebroadand.com }        ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2009 AUTHORS. All rights reserved.             ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
////                                                              ////
43
//// Model of the  IEEE 802.3-2008 Clause 22 MDIO/MDC management  ////
44
////                                                              ////
45
//////////////////////////////////////////////////////////////////////
46
 
47
`include "timescale_tb.v"
48
 
49
package tb_utils;
50
 
51
  class VirIntfHandle;
52
 
53
   virtual serial_model_if      serial_model;
54
 
55
   // GMII models
56
   virtual gmii_tx_if           gmii_tx_model;
57
   virtual gmii_rx_if           gmii_rx_model;
58
 
59
   // 8B/10B models
60
   virtual encoder_8b_tx_if     encoder_8b_tx_model;
61
   virtual encoder_10b_rx_if    encoder_10b_rx_model;
62
   virtual decoder_8b_rx_if     decoder_8b_rx_model;
63
 
64
  endclass
65
 
66
  function automatic string hexformat(int data[], string fmt="0x%02x", string joiner=", ");
67
    string buffer = "";
68
    string temp;
69
    for(int i=0; i<data.size(); i++)
70
      begin
71
        $sformat(temp, fmt, data[i]);
72
        if(i!=0)
73
          buffer = {buffer, joiner, temp};
74
        else
75
          buffer = {buffer, temp};
76
      end
77
    return buffer;
78
  endfunction
79
 
80
  function automatic string hexpretty(int data[], int n_start=4, int n_end=4);
81
    int n = data.size();
82
 
83
    if(n < n_start+n_end)
84
      return hexformat(data, "0x%02x", ",");
85
    else
86
      begin
87
        int head[] = new[n_start];
88
        int tail[] = new[n_end];
89
        string s;
90
 
91
        for(int i=0; i<n_start; i++)
92
          head[i] = data[i];
93
 
94
        for(int i=0; i<n_end; i++)
95
          tail[i] = data[n-n_end+i];
96
 
97
        $sformat(s, "%s...%s",
98
                 hexformat(head, "0x%02x", ","),
99
                 hexformat(tail, "0x%02x", ",")
100
                );
101
        return s;
102
      end
103
  endfunction
104
 
105
 
106
 
107
endpackage
108
 

powered by: WebSVN 2.1.0

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