reality_mon.v
11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
// $Id: reality_mon.v,v 1.1 2002/03/28 00:26:14 berndt Exp $
module reality_mon(clock, reset_l);
`include "rcp.vh"
`include "define.vh"
input clock;
input reset_l;
reg [1:256*8] vifilename;
reg [31:0] timelimit;
reg [31:0] cyclelimit;
reg [31:0] startdump;
reg [31:0] cycle_count;
initial begin
if ($test$plusargs("help")) begin
$display("general arguments include:");
$display(" +help - log this message");
$display(" +dump - generate a verilog dump file");
$display(" +adac_mon - log audio dac activity");
$display(" +cbuf_mon - log cbuf activity");
$display(" +cbus_mon - log cbus activity");
$display(" +mbus_mon - log mbus activity");
$display(" +xbus_mon - log xbus activity");
$display(" +cart_mon - log cartridge activity");
$display(" +mem_mon - log mem activity");
$display(" +span_mon - log span activity");
$display(" +spandata_mon - log span data read/write activity");
$display(" +r4200_mon - log 4200 activity");
$display(" +load_rom - load cartridge ROM from rom_?.data");
$display(" +load_rdram - load Rambus DRAM from rdram_reorderd_?.data");
$display(" +load_dmem - load SP DMEM from dmem_even.data & dmem_odd.data");
$display(" +load_imem - load SP IMEM from imem.data");
$display(" +load_pif - load PIF ROM from pif.data");
$display(" +cyclelimit=<cyc> - limit simulation to no more than <cyc> cycles");
$display(" +startdump=<cyc> - turn dump on at cycle <cyc>");
$display(" +enable_nmi - enable nmi generation from PIF");
$display(" +vitab=file - turn on dumping of video data for software monitor");
$display(" +mmap_rdram=file - load Rambus DRAM from memory mapped file.main and file.hidden");
$display("");
#1 $finish;
end
`ifdef GATE_LEVEL
if ($test$plusargs("dump")) begin
//$dumpvars(0, reality.rcp_0.if_logic);
//$dumpvars(0, reality.rcp_0.vclk_driver_0);
$dumpvars(0, reality.rcp_0.if_logic);
//$dumpvars(0, reality.rcp_0.ri_0);
//$dumpvars(0, reality.rcp_0.rsp_0_su );
//$dumpvars(0, reality.rcp_0.rsp_0_ls );
//$dumpvars(0, reality.rcp_0.rsp_0_io_logic );
//$dumpvars(0, reality.rcp_0.pi_0);
//$dumpvars(0, reality.rcp_0.rsp_0_io_logic );
//$dumpvars(0, reality.rcp_0.vi_0);
//$dumpvars(0, reality.rcp_0.left_pads.rac_0);
//$dumpvars(0, reality.rcp_0.rdp_0_tc_logic );
//$dumpvars(0, reality.rcp_0.rdp_0_ms_grp );
//$dumpvars(0, reality.rcp_0.rdp_0_tf_logic );
//$dumpvars(0, reality.rcp_0.rdp_0_tm_grp );
//$dumpvars(0, reality.rcp_0.rdp_0_cs_ew_cv );
//$dumpvars(0, reality.rcp_0.rdp_0_bl_logic );
//$dumpvars(0, reality.rcp_0.rdp_0_cc_logic );
$dumpvars(1, reality);
$dumpvars(1, reality.rcp_0);
end
if ($test$plusargs("rcp_dump")) $dumpvars(0, reality.rcp_0);
if ($test$plusargs("rcp_top_dump")) $dumpvars(1, reality.rcp_0);
if ($test$plusargs("vi_dump")) begin
$dumpvars(3, reality.rcp_0.vi_0);
//$dumpvars(0, reality.rcp_0.vi_0.vi_grp.vi_logic.clk_blk);
end
/*
if ($test$plusargs("ms_dump")) begin
$dumpvars(1, reality.rcp_0);
$dumpvars(0, reality.rcp_0.\rdp_0/memspan );
end
if ($test$plusargs("tc_dump")) begin
$dumpvars(1, reality.rcp_0);
$dumpvars(0, reality.rcp_0.\rdp_0/tc_logic );
end
*/
if ($test$plusargs("tst_dump")) $dumpvars(0, reality.rcp_0.if_logic);
`else
if ($test$plusargs("dump")) begin
$dumpvars(1, reality);
$dumpvars(1, reality.rcp_0);
$dumpvars(0, reality.rcp_0.pad_0);
$dumpvars(0, reality.rcp_0.rsp_0);
$dumpvars(0, reality.rcp_0.rdp_0);
$dumpvars(0, reality.rcp_0.mi_0);
$dumpvars(0, reality.rcp_0.pi_0);
$dumpvars(0, reality.rcp_0.si_0);
$dumpvars(0, reality.rcp_0.ai_0);
$dumpvars(0, reality.rcp_0.vi_0);
$dumpvars(0, reality.rcp_0.arb_0);
$dumpvars(0, reality.rcp_0.ri_0);
$dumpvars(0, reality.rcp_0.tst_0);
end
if ($test$plusargs("all_dump")) $dumpvars;
if ($test$plusargs("reality_top_dump")) $dumpvars(1, reality);
if ($test$plusargs("rcp_top_dump")) $dumpvars(1, reality.rcp_0);
if ($test$plusargs("rcp_dump")) $dumpvars(0, reality.rcp_0);
if ($test$plusargs("pad_dump")) $dumpvars(0, reality.rcp_0.pad_0);
if ($test$plusargs("rsp_dump")) $dumpvars(0, reality.rcp_0.rsp_0);
if ($test$plusargs("rdp_dump")) $dumpvars(0, reality.rcp_0.rdp_0);
if ($test$plusargs("tc_dump")) $dumpvars(0, reality.rcp_0.rdp_0.tc);
if ($test$plusargs("mi_dump")) $dumpvars(0, reality.rcp_0.mi_0);
if ($test$plusargs("pi_dump")) $dumpvars(0, reality.rcp_0.pi_0);
if ($test$plusargs("si_dump")) $dumpvars(0, reality.rcp_0.si_0);
if ($test$plusargs("ai_dump")) $dumpvars(0, reality.rcp_0.ai_0);
if ($test$plusargs("vi_dump")) $dumpvars(3, reality.rcp_0.vi_0);
if ($test$plusargs("arb_dump")) $dumpvars(0, reality.rcp_0.arb_0);
if ($test$plusargs("ri_dump")) $dumpvars(0, reality.rcp_0.ri_0);
if ($test$plusargs("rac_dump")) $dumpvars(0, reality.rcp_0.pad_0.left_pads.rac_0);
if ($test$plusargs("pif_dump")) $dumpvars(0, reality.pif_0);
`endif
`ifdef RDRAM_0_PRESENT
if ($test$plusargs("rdram_dump")) $dumpvars(0, reality.rdram_0);
`endif
`ifdef RDRAM_1_PRESENT
if ($test$plusargs("rdram_dump")) $dumpvars(0, reality.rdram_1);
`endif
`ifdef ROM_0_PRESENT
if ($test$plusargs("rom_dump")) $dumpvars(0, reality.rom_0);
`endif
`ifdef ROM_1_PRESENT
if ($test$plusargs("rom_dump")) $dumpvars(0, reality.rom_1);
`endif
`ifdef GATE_LEVEL
`else
`ifdef IPC_PRESENT
if ($test$plusargs("ms_dump")) $dumpvars(0, reality.rcp_0.rdp_0.ms);
`endif
`endif
if ($getnum$plusarg("timelimit=", timelimit) == 1) $set_timelimit(timelimit);
end
// always @(reality.rcp_0.syn_clk) $display($time,, reality.rcp_0.syn_clk);
`ifdef IPC_PRESENT
initial
begin
if ($getstr$plusarg("vitab=", vifilename) == 1)
begin
if ($open_viout_file(vifilename) == -1)
begin
$write("Cannot open vi out file \n");
end
end
end
always @(posedge reality.rcp_0.vi_0.vclk)
begin
if ($output_vi(reality.rcp_0.vi_0.vbus_data, reality.rcp_0.vi_0.vbus_sync) == -1)
begin
$write("Cannot write vi output values \n");
end
end
`endif
initial begin
if ($test$plusargs("refresh")) begin
wait(reset_l);
wait(~reset_l);
wait(reset_l);
force reality.rcp_0.refresh_strobe = LOW;
forever begin
repeat (200) @(posedge clock);
force reality.rcp_0.refresh_strobe = HIGH;
@(posedge clock);
force reality.rcp_0.refresh_strobe = LOW;
end
end
end
`ifdef RSP_PRESENT
initial begin
if ($test$plusargs("load_dmem")) begin
$display("Loading DMEM ........");
`ifdef GATE_LEVEL
//from rcpgate_rsp_regr.h
`define DMEM_L reality.rcp_0.rsp_0_dmemx2_dmemLow
`define DMEM_H reality.rcp_0.rsp_0_dmemx2_dmemHigh
// $display(" You want me to load DMEM ??? Do it yourself");
$readmemh("SpData/d_0.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemHigh.ram_prim7, 0);
$readmemh("SpData/d_1.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemHigh.ram_prim6 , 0);
$readmemh("SpData/d_2.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemHigh.ram_prim5 , 0);
$readmemh("SpData/d_3.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemHigh.ram_prim4 , 0);
$readmemh("SpData/d_4.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemHigh.ram_prim3 , 0);
$readmemh("SpData/d_5.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemHigh.ram_prim2 , 0);
$readmemh("SpData/d_6.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemHigh.ram_prim1 , 0);
$readmemh("SpData/d_7.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemHigh.ram_prim0 , 0);
$readmemh("SpData/d_8.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemLow.ram_prim7 , 0);
$readmemh("SpData/d_9.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemLow.ram_prim6 , 0);
$readmemh("SpData/d_a.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemLow.ram_prim5 , 0);
$readmemh("SpData/d_b.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemLow.ram_prim4 , 0);
$readmemh("SpData/d_c.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemLow.ram_prim3 , 0);
$readmemh("SpData/d_d.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemLow.ram_prim2 , 0);
$readmemh("SpData/d_e.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemLow.ram_prim1 , 0);
$readmemh("SpData/d_f.dhex",
reality.rcp_0.rsp_0_dmemx2_dmemLow.ram_prim0 , 0);
`else
$readmemh("SpData/d_0.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemHigh.ram_prim7, 0);
$readmemh("SpData/d_1.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemHigh.ram_prim6, 0);
$readmemh("SpData/d_2.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemHigh.ram_prim5, 0);
$readmemh("SpData/d_3.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemHigh.ram_prim4, 0);
$readmemh("SpData/d_4.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemHigh.ram_prim3, 0);
$readmemh("SpData/d_5.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemHigh.ram_prim2, 0);
$readmemh("SpData/d_6.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemHigh.ram_prim1, 0);
$readmemh("SpData/d_7.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemHigh.ram_prim0, 0);
$readmemh("SpData/d_8.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemLow.ram_prim7, 0);
$readmemh("SpData/d_9.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemLow.ram_prim6, 0);
$readmemh("SpData/d_a.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemLow.ram_prim5, 0);
$readmemh("SpData/d_b.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemLow.ram_prim4, 0);
$readmemh("SpData/d_c.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemLow.ram_prim3, 0);
$readmemh("SpData/d_d.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemLow.ram_prim2, 0);
$readmemh("SpData/d_e.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemLow.ram_prim1, 0);
$readmemh("SpData/d_f.dhex",
reality.rcp_0.rsp_0.dmemx2.dmemLow.ram_prim0, 0);
`endif
end
end
initial begin
/* wait for reset to go away */
wait(`SYSTEM_READY);
/*
* wait additional cycles just to be sure.
* config_rdram should easily use up these cycles anyway
*/
repeat (4) @(posedge clock);
if ($test$plusargs("load_imem")) begin
$display($time," Loading IMEM ........");
`ifdef GATE_LEVEL
$readmemh("SpData/idata.ihex",
reality.rcp_0.rsp_0_imem.ram_prim , 0);
`else
$readmemh("SpData/idata.ihex",
reality.rcp_0.rsp_0.imem.ram_prim, 0);
`endif
end
end
`endif
initial begin
cycle_count = 0;
cyclelimit = 32'hfffffff0;
startdump = 32'hfffffff0;
if ($getnum$plusarg("cyclelimit=", cyclelimit) == 1)
begin
end
if ($getnum$plusarg("startdump=", startdump) == 1)
begin
$dumpoff;
$display("Dump=OFF (dump will be turned on at cycle 0x%h or %d)",
startdump, startdump);
end
forever @(posedge clock) begin
if (cycle_count === cyclelimit)
$finish;
else if (cycle_count == startdump) begin
$dumpon;
$display("Dump=ON");
end
cycle_count = cycle_count + 32'h1;
end
end
// Create reset for gate level memspan copy-load bus counter
//`ifdef GATE_LEVEL
//always @(reset_l) begin
// if (!reset_l) begin
// force reality.rcp_0.\rdp_0/memspan .\ms/rp/n6903 = 1;
// end
// else begin
// release reality.rcp_0.\rdp_0/memspan .\ms/rp/n6903 ;
// end
//end
//`endif
endmodule