Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / common / verilog / misc / dump.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: dump.v
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35reg [2047:0] dumpfilename;
36integer limit_dump;
37integer start_dump;
38integer stop_dump;
39
40initial
41 begin
42 limit_dump = 0;
43 end
44
45//----------------------------------------------------------
46// Dumpfiles
47// User chooses Debussy or VCD on sims command line
48//
49`ifndef ALL_DUMP_OFF
50
51`ifndef VCD_OFF
52// VCD Dumpfile
53// sims does file naming and start/stop for us.
54 initial begin
55 if ($test$plusargs("vcd")) begin
56 `PR_NORMAL("arg", `NORMAL, "VCD dumping enabled");
57 if ($test$plusargs("DUMP_ALL")) begin
58 $dumpvars;
59 `PR_NORMAL("arg", `NORMAL, "VCD dumping w/ DUMP_ALL");
60 end
61`ifdef FC_BENCH
62 else if ($test$plusargs("DUMP_LIMIT")) begin
63 `PR_NORMAL("arg", `NORMAL, "VCD dumping w/ DUMP_LIMIT");
64 // Limit dumpfile scope (aka modules)
65 // (see :/verif/env/<TB>/dump_scope.vh)
66 `include "vcd_scope.vh"
67 end
68`endif
69 else begin
70 $dumpvars(99,tb_top);
71 `PR_NORMAL("arg", `NORMAL, "VCD dumping tb_top down");
72 end
73
74 // sims uses +vcs+dumpon+ / +vcs+dumpoff+ if
75 // user uses sims -start_dump/stop_dump
76 if ($test$plusargs("vcs+dumpon")) $dumpoff;
77 else $dumpon;
78 end
79 end
80`endif
81
82`ifndef FSDB_OFF
83 // Debussy Dumpfile
84 initial begin
85 if ($test$plusargs("debussy")) begin
86 if ($test$plusargs("fsdbfile")) begin
87 if ($value$plusargs ("fsdbfile=%s", dumpfilename)) begin
88 `PR_NORMAL("arg", `NORMAL, "debussy - filename=%s",dumpfilename);
89 end
90 end
91 else begin
92 dumpfilename = "tb_top.fsdb";
93 `PR_NORMAL("arg", `NORMAL, "debussy - filename=tb_top.fsdb");
94 end
95
96
97 if (!$test$plusargs("fsdbAutoSwitchDumpfile")) begin
98 if ($test$plusargs("fsdbDumplimit"))
99 begin
100 if ($value$plusargs ("fsdbDumplimit=%d", limit_dump))
101 begin
102 // Minimum limit size is 10 Mbytes (10).
103 // Maximum size is 1800 Mbytes on a 32bit machine.
104 // Size is in Mbytes only.
105 // File will have latest data, *does not stop writing*.
106 // Do NOT use this from time zero if the fail is very
107 // late in time, use -dump_start=time
108 $fsdbDumplimit(limit_dump);
109 `PR_NORMAL("arg", `NORMAL, "debussy - dump size limited to %d",limit_dump);
110 end
111 end // if ($test$plusargs("fsdbDumplimit"))
112 $fsdbDumpfile(dumpfilename);
113 end
114
115`ifndef AXIS_BUILD
116 if ($test$plusargs("fsdbAutoSwitchDumpfile")) begin
117 `PR_ERROR("arg", `ERROR, "debussy - fsdbAutoSwitchDumpfile will not work with AXIS");
118 end
119`endif
120`ifndef AXIS_TL
121 if ($test$plusargs("fsdbAutoSwitchDumpfile")) begin
122 `PR_ERROR("arg", `ERROR, "debussy - fsdbAutoSwitchDumpfile will not work with AXIS");
123 end
124`endif
125
126`ifndef AXIS_TL
127`ifndef AXIS_BUILD
128`ifndef AXIS
129 // ---> see notes at end of this file... <---
130 if ($test$plusargs("fsdbAutoSwitchDumpfile")) begin
131 if ($value$plusargs ("fsdbAutoSwitchDumpfile=%d", limit_dump))
132 begin
133 // Minimum limit size is 2 Mbytes (2).
134 // Size is in Mbytes only.
135 // Once the fsdb file fills up, it will be closed and a new one started.
136 // file names will be dumpfilename_000.fsdb, dumpfilename_001.fsdb, ...
137 // dumpfilename.log will have the time ranges for each file
138 $fsdbAutoSwitchDumpfile(limit_dump, dumpfilename, 10); // only allow 10 fsdb files for now
139 `PR_NORMAL("arg", `NORMAL, "debussy - fsdbAutoSwitchDumpfile with dump size limited to %d",limit_dump);
140 `PR_NORMAL("arg", `NORMAL, "debussy - Set env var NOVAS_FSDB_ENV_WRITER_MEM_LIMIT to 64 when using fsdbAutoSwitchDumpfile to get smaller files!!!");
141 end
142 end
143`endif
144`endif
145`endif
146
147 // Limit dumpfile scope (aka modules)
148 // (see :/verif/env/<TB>/dump_scope.vh)
149 `include "dump_scope.vh"
150
151 // sims uses +fsdb+dumpon+ / +fsdb+dumpoff+ if
152 // user uses sims -start_dump/stop_dump
153 if ($test$plusargs("fsdb+dumpon")) $fsdbDumpoff;
154 else $fsdbDumpon;
155
156`ifdef FC_BENCH
157 if ($test$plusargs("fsdb+dumpon") || $test$plusargs("fsdb+dumpoff"))
158 `PR_ALWAYS("arg", `ALWAYS, "debussy - sims start/stop_dump must be given in ps!!!\nYou may have to remove the two rightmost digits from the times you see in FC log files!!!");
159`endif
160 end
161 end // initial
162
163`endif
164`endif
165
166/*
167 Why is the total FSDB file size bigger when using $fsdbAutoSwitchDumpfile?
168
169The FSDB file grows bigger using fsdbAutoSwitchDumpFile because
170
171 1. The memory limit size is tuned down to 7M by the FSDB writer when
172 the $fsdbAutoSwitchDumpfile task is called.
173 2. The default memory limit is 64M with other FSDB dumping tasks.
174 3. Generally speaking, the bigger memory limit leads to a better compression
175 ratio; therefore, the smaller default limit with $fsdbAutoSwitchDumpfile
176 causes the FSDB file size to increase.
177
178Consider two different simulation runs where the only change is the
179setup call to automatically switch FSDB files or not. For example:
180
181Run 1 used: $fsdbDumpfile( "myfull_dump.fsdb" );
182
183Run 2 used: $fsdbAutoSwitchDumpfile(1900, "my_dump.fsdb", 0, "debussyAutoSwitch.log" );
184
185The simulation time was the same in the two runs but the FSDB file
186size increased using the $fsdbAutoSwitchDumpfile task. The simulation
187results follow:
188
189Run 1: fsdbDumpfile with default memory buffer of 64 MB
190
191~401 MB (disk size of 401214254 bytes)
192
193
194Run 2: fsdbAutoSwitchDumpfile with default memory buffer of 7 MB
195
196~637 MB (disk size of 637572720 bytes)
197
198
199The reason fsdbAutoSwitchDumpfile has a default buffer size of 7 MB is
200to have more accurate file sizes. With the default buffer size the
201file size will be +/- ~7 MB. If the buffer was 64 MB, the file sizes
202would be accurate to +/- ~64 MB.
203
204To reduce the total FSDB file size using the system task
205$fsdbAutoSwitchDumpfile, please do the following.
206
207a. Before running the simulation, setenv NOVAS_FSDB_ENV_WRITER_MEM_LIMIT 64
208(or to a bigger value)
209
210b. Run the test case again.
211
212The simulation results after changing the buffer size follow:
213
214Run 2: fsdbAutoSwitchDumpfile with NOVAS_FSDB_ENV_WRITER_MEM_LIMIT = 2 MB
215~759 MB (disk size of 759143293 bytes)
216
217
218Run 2: fsdbAutoSwitchDumpfile with NOVAS_FSDB_ENV_WRITER_MEM_LIMIT = 64 MB
219~401 MB (disk size of 401214254 bytes)
220
221From these results, fsdbAutoSwitchDumpfile = fsdbDumpfile if the
222buffer is set to 64 MB (maximum compression). As the buffer size is
223decreased, the FSDB file size generated with fsdbAutoSwitchDumpfile
224will increase (minimum compression).
225
226*/