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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [src/] [tb/] [legacy/] [logger_pkg.sv] - Blame information for rev 50

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 50 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 logger_pkg;
30
 
31
  // --------------------------------------------------------------------
32
  //
33
  typedef enum
34
  {
35
    FATAL,
36
    ERROR,
37
    WARNING,
38
    INFO
39
  } logger_severity_t;
40
 
41
 
42
  // --------------------------------------------------------------------
43
  //
44
  class logger_class;
45
 
46
    logger_severity_t verbosity = WARNING;
47
    bit log_debug = 0;
48
    string time_string;
49
    int error_count = 0;
50
    int max_error_display = 8;
51
    bit stop_at_max_error = 1;
52
 
53
    // --------------------------------------------------------------------
54
    //
55
    function void
56
      set_verbosity(logger_severity_t level);
57
      verbosity = level;
58
    endfunction: set_verbosity
59
 
60
 
61
    // --------------------------------------------------------------------
62
    //
63
    function void
64
      debug_enable;
65
      log_debug = 1;
66
    endfunction: debug_enable
67
 
68
 
69
    // --------------------------------------------------------------------
70
    //
71
    function void debug(string message);
72
      time_string = $sformatf("??? %16.t | ", $time);
73
      if(log_debug == 1)
74
        $display({time_string, message});
75
    endfunction: debug
76
 
77
 
78
    // --------------------------------------------------------------------
79
    //
80
    function void display(string message);
81
      time_string = $sformatf("--- %16.t | ", $time);
82
      $display({time_string, message});
83
    endfunction: display
84
 
85
 
86
    // --------------------------------------------------------------------
87
    //
88
    function void info(string message);
89
      time_string = $sformatf("^^^ %16.t | ", $time);
90
      if(verbosity >= INFO)
91
        $display({time_string, message});
92
    endfunction: info
93
 
94
 
95
    // --------------------------------------------------------------------
96
    //
97
    function void warning(string message);
98
      time_string = $sformatf("*** %16.t | ", $time);
99
      if(verbosity >= WARNING)
100
        $display({time_string, message});
101
    endfunction: warning
102
 
103
 
104
    // --------------------------------------------------------------------
105
    //
106
    function void error(string message);
107
      time_string = $sformatf("!!! %16.t | ", $time);
108
      error_count++;
109
      if(error_count > max_error_display)
110
        if(stop_at_max_error)
111
          $stop;
112
        else
113
          return;
114
 
115
      if(verbosity >= ERROR)
116
        $display({time_string, message});
117
    endfunction: error
118
 
119
 
120
    // --------------------------------------------------------------------
121
    //
122
    function void fatal(string message);
123
      if(verbosity >= FATAL)
124
        $fatal(1, message);
125
    endfunction: fatal
126
 
127
 
128
  //--------------------------------------------------------------------
129
  //
130
  endclass: logger_class
131
 
132
 
133
//--------------------------------------------------------------------
134
//
135
endpackage: logger_pkg
136
 

powered by: WebSVN 2.1.0

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