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

Subversion Repositories qaz_libs

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 qaztronic
// (C) 2001-2016 Intel Corporation. All rights reserved.
2
// Your use of Intel Corporation's design tools, logic functions and other
3
// software and tools, and its AMPP partner logic functions, and any output
4
// files any of the foregoing (including device programming or simulation
5
// files), and any associated documentation or information are expressly subject
6
// to the terms and conditions of the Intel Program License Subscription
7
// Agreement, Intel MegaCore Function License Agreement, or other applicable
8
// license agreement, including, without limitation, that your use is for the
9
// sole purpose of programming logic devices manufactured by Intel and sold by
10
// Intel or its authorized distributors.  Please refer to the applicable
11
// agreement for further details.
12
 
13
 
14
// $Id: //acds/rel/16.1/ip/sopc/components/verification/lib/verbosity_pkg.sv#1 $
15
// $Revision: #1 $
16
// $Date: 2016/08/07 $
17
//-----------------------------------------------------------------------------
18
// =head1 NAME
19
// verbosity_pkg
20
// =head1 SYNOPSIS
21
// Package for controlling verbosity of messages sent to the console
22
//-----------------------------------------------------------------------------
23
// =head1 COPYRIGHT
24
// Copyright (c) 2008 Altera Corporation. All Rights Reserved.
25
// The information contained in this file is the property of Altera
26
// Corporation. Except as specifically authorized in writing by Altera
27
// Corporation, the holder of this file shall keep all information
28
// contained herein confidential and shall protect same in whole or in part
29
// from disclosure and dissemination to all third parties. Use of this
30
// program confirms your agreement with the terms of this license.
31
//-----------------------------------------------------------------------------
32
// =head1 DESCRIPTION
33
// This module will dump diagnostic messages to the console during
34
// simulation. The level of verbosity can be controlled in the test
35
// bench by using the *set_verbosity* method in the imported package
36
// verbosity_pkg. For a given setting, message at that level and all
37
// lower levels are dumped. For example, setting VERBOSITY_DEBUG level
38
// causes all messages to be dumped, while VERBOSITY_FAILURE restricts
39
// only failure messages and those tagged as VERBOSITY_NONE to be
40
// dumped.
41
// The different levels are:
42
// =over 4
43
// =item 1 VERBOSITY_NONE
44
// Messages tagged with this level are always dumped to the console.
45
// =item 2 VERBOSITY_FAILURE
46
// A fatal simulation error has occurred and the simulator will exit.
47
// =item 3 VERBOSITY_ERROR
48
// A non-fatal error has occured. An example is a data comparison mismatch.
49
// =item 4 VERBOSITY_WARNING
50
// Warn the user that a potential error has occurred.
51
// =item 5 VERBOSITY_INFO
52
// Informational message.
53
// =item 6 VERBOSITY_DEBUG
54
// Dump enough state to diagnose problem scenarios.
55
// =back
56
 
57
 
58
`ifndef _AVALON_VERBOSITY_PKG_
59
`define _AVALON_VERBOSITY_PKG_
60
 
61
package verbosity_pkg;
62
 
63
        timeunit 1ps;
64
        timeprecision 1ps;
65
 
66
   typedef enum int {VERBOSITY_NONE,
67
                     VERBOSITY_FAILURE,
68
                     VERBOSITY_ERROR,
69
                     VERBOSITY_WARNING,
70
                     VERBOSITY_INFO,
71
                     VERBOSITY_DEBUG} Verbosity_t;
72
 
73
   Verbosity_t  verbosity = VERBOSITY_INFO;
74
   string       message = "";
75
   int          dump_file;
76
   int          dump = 0;
77
 
78
   //--------------------------------------------------------------------------
79
   // =head1 Public Methods API
80
   // =pod
81
   // This section describes the public methods in the application programming
82
   // interface (API). In this case the application program is the test bench
83
   // or component which imports this package.
84
   // =cut
85
   //--------------------------------------------------------------------------
86
 
87
   function automatic Verbosity_t get_verbosity(); // public
88
      // Returns the global verbosity setting.
89
      return verbosity;
90
   endfunction
91
 
92
   function automatic void set_verbosity ( // public
93
      Verbosity_t v
94
   );
95
      // Sets the global verbosity setting.
96
 
97
      string       verbosity_str;
98
      verbosity = v;
99
 
100
      case(verbosity)
101
        VERBOSITY_NONE: verbosity_str = "VERBOSITY_";
102
        VERBOSITY_FAILURE: verbosity_str = "VERBOSITY_FAILURE";
103
        VERBOSITY_ERROR: verbosity_str = "VERBOSITY_ERROR";
104
        VERBOSITY_WARNING: verbosity_str = "VERBOSITY_WARNING";
105
        VERBOSITY_INFO: verbosity_str = "VERBOSITY_INFO";
106
        VERBOSITY_DEBUG: verbosity_str = "VERBOSITY_DEBUG";
107
        default: verbosity_str = "UNKNOWN";
108
      endcase
109
      $sformat(message, "%m: Setting Verbosity level=%0d (%s)",
110
               verbosity, verbosity_str);
111
      print(VERBOSITY_NONE, message);
112
   endfunction
113
 
114
   function automatic void print( // public
115
      Verbosity_t level,
116
      string message
117
   );
118
      // Print a message to the console if the verbosity argument
119
      // is less than or equal to the global verbosity setting.
120
      string level_str;
121
 
122
      if (level <= verbosity) begin
123
         case(level)
124
           VERBOSITY_NONE: level_str = "";
125
           VERBOSITY_FAILURE: level_str = "FAILURE:";
126
           VERBOSITY_ERROR: level_str = "ERROR:";
127
           VERBOSITY_WARNING: level_str = "WARNING:";
128
           VERBOSITY_INFO: level_str = "INFO:";
129
           VERBOSITY_DEBUG: level_str = "DEBUG:";
130
           default: level_str = "UNKNOWN:";
131
         endcase
132
 
133
         $display("%t: %s %s",$time, level_str, message);
134
         if (dump) begin
135
            $fdisplay(dump_file, "%t: %s %s",$time, level_str, message);
136
         end
137
      end
138
   endfunction
139
 
140
   function automatic void print_divider( // public
141
      Verbosity_t level
142
   );
143
      // Prints a divider line to the console to make a block of related text
144
      // easier to identify and read.
145
      string message;
146
      $sformat(message,
147
               "------------------------------------------------------------");
148
      print(level, message);
149
   endfunction
150
 
151
   function automatic void open_dump_file ( // public
152
      string dump_file_name = "avalon_bfm_sim.log"
153
   );
154
      // Opens a dump file which collects console messages.
155
 
156
      if (dump) begin
157
         $sformat(message, "%m: Dump file already open - ignoring open.");
158
         print(VERBOSITY_ERROR, message);
159
      end else begin
160
         dump_file = $fopen(dump_file_name, "w");
161
         $fdisplay(dump_file, "testing dump file");
162
         $sformat(message, "%m: Opening dump file: %s", dump_file_name);
163
         print(VERBOSITY_INFO, message);
164
         dump = 1;
165
      end
166
   endfunction
167
 
168
   function automatic void close_dump_file();  // public
169
      // Close the console message dump file.
170
      if (!dump) begin
171
         $sformat(message, "%m: No open dump file - ignoring close.");
172
         print(VERBOSITY_ERROR, message);
173
      end else begin
174
         dump = 0;
175
         $fclose(dump_file);
176
         $sformat(message, "%m: Closing dump file");
177
         print(VERBOSITY_INFO, message);
178
      end
179
   endfunction
180
 
181
   function automatic void abort_simulation();
182
      string message;
183
      $sformat(message, "%m: Abort the simulation due to fatal error incident.");
184
      print(VERBOSITY_FAILURE, message);
185
      $stop;
186
   endfunction
187
 
188
endpackage
189
 
190
// =cut
191
 
192
`endif
193
 

powered by: WebSVN 2.1.0

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