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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [verilog/] [or1200_monitor.v] - Blame information for rev 337

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's simulation monitor                                 ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Simulation monitor                                          ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - move it to bench                                         ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: or1200_monitor.v,v $
47
// Revision 1.4  2004/04/05 08:46:06  lampret
48
// Merged branch_qmem into main tree.
49
//
50
// Revision 1.3  2003/04/07 01:32:53  lampret
51
// Added get_gpr support for OR1200_RFRAM_GENERIC
52
//
53
// Revision 1.2  2002/08/12 05:38:11  lampret
54
// Added more WISHBONE protocol checks. Removed nop.log. Added general.log and lookup.log.
55
//
56
// Revision 1.1  2002/03/28 19:59:55  lampret
57
// Added bench directory
58
//
59
// Revision 1.9  2002/02/01 19:56:54  lampret
60
// Fixed combinational loops.
61
//
62
// Revision 1.8  2002/01/28 01:25:22  lampret
63
// Fixed display of new 'void' nop insns.
64
//
65
// Revision 1.7  2002/01/19 14:10:39  lampret
66
// Fixed OR1200_XILINX_RAM32X1D.
67
//
68
// Revision 1.6  2002/01/18 07:57:56  lampret
69
// Added support for reading XILINX_RAM32X1D register file.
70
//
71
// Revision 1.5  2002/01/14 06:19:35  lampret
72
// Added debug model for testing du. Updated or1200_monitor.
73
//
74
// Revision 1.4  2002/01/03 08:40:15  lampret
75
// Added second clock as RISC main clock. Updated or120_monitor.
76
//
77
// Revision 1.3  2001/11/23 08:50:35  lampret
78
// Typos.
79
//
80
// Revision 1.2  2001/11/10 04:22:55  lampret
81
// Modified monitor tu support exceptions.
82
//
83
// Revision 1.1.1.1  2001/11/04 18:51:07  lampret
84
// First import.
85
//
86
// Revision 1.1  2001/08/20 18:17:52  damjan
87
// Initial revision
88
//
89
// Revision 1.1  2001/08/13 03:37:07  lampret
90
// Added monitor.v and timescale.v
91
//
92
// Revision 1.1  2001/07/20 00:46:03  lampret
93
// Development version of RTL. Libraries are missing.
94
//
95
//
96 67 julius
 
97 55 julius
`include "timescale.v"
98 6 julius
`include "or1200_defines.v"
99
 
100
//
101
// Top of OR1200 inside test bench
102
//
103 67 julius
`ifndef OR1200_TOP
104
 `define OR1200_TOP orpsoc_testbench.dut.i_or1k.i_or1200_top
105
 `include "orpsoc_testbench_defines.v"
106
`else
107
 `include `TESTBENCH_DEFINES
108
`endif
109 6 julius
//
110
// Enable display_arch_state task
111
//
112
//`define OR1200_DISPLAY_ARCH_STATE
113
 
114
module or1200_monitor;
115
 
116
   integer fexe;
117
   reg [23:0] ref;
118
   integer    fspr;
119
   integer    fgeneral;
120
   integer    flookup;
121
   integer    r3;
122
   integer    insns;
123
 
124
   //
125
   // Initialization
126
   //
127
   initial begin
128
      ref = 0;
129
      fexe = $fopen({`TEST_RESULTS_DIR,`TEST_NAME_STRING,"-executed.log"});
130
      $timeformat (-9, 2, " ns", 12);
131
      fspr = $fopen({`TEST_RESULTS_DIR,`TEST_NAME_STRING,"-sprs.log"});
132
      fgeneral = $fopen({`TEST_RESULTS_DIR,`TEST_NAME_STRING,"-general.log"});
133
      flookup = $fopen({`TEST_RESULTS_DIR,`TEST_NAME_STRING,"-lookup.log"});
134
      insns = 0;
135
 
136
   end
137
 
138
   //
139
   // Get GPR
140
   //
141
   task get_gpr;
142
      input     [4:0]    gpr_no;
143
      output [31:0]      gpr;
144
      integer           j;
145
      begin
146
`ifdef OR1200_RFRAM_GENERIC
147
         for(j = 0; j < 32; j = j + 1) begin
148
            gpr[j] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.mem[gpr_no*32+j];
149
         end
150
`else
151
 `ifdef OR1200_XILINX_RAM32X1D
152
         gpr[0] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_0.mem[gpr_no];
153
         gpr[1] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_1.mem[gpr_no];
154
         gpr[2] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_2.mem[gpr_no];
155
         gpr[3] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_3.mem[gpr_no];
156
         gpr[4] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_4.mem[gpr_no];
157
         gpr[5] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_5.mem[gpr_no];
158
         gpr[6] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_6.mem[gpr_no];
159
         gpr[7] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_7.mem[gpr_no];
160
         gpr[8] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_0.mem[gpr_no];
161
gpr[9] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_1.mem[gpr_no];
162
         gpr[10] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_2.mem[gpr_no];
163
gpr[11] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_3.mem[gpr_no];
164
         gpr[12] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_4.mem[gpr_no];
165
gpr[13] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_5.mem[gpr_no];
166
         gpr[14] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_6.mem[gpr_no];
167
gpr[15] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_7.mem[gpr_no];
168
         gpr[16] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_0.mem[gpr_no];
169
gpr[17] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_1.mem[gpr_no];
170
gpr[18] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_2.mem[gpr_no];
171
gpr[19] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_3.mem[gpr_no];
172
gpr[20] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_4.mem[gpr_no];
173
gpr[21] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_5.mem[gpr_no];
174
gpr[22] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_6.mem[gpr_no];
175
gpr[23] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_7.mem[gpr_no];
176
gpr[24] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_0.mem[gpr_no];
177
gpr[25] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_1.mem[gpr_no];
178
gpr[26] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_2.mem[gpr_no];
179
gpr[27] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_3.mem[gpr_no];
180
gpr[28] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_4.mem[gpr_no];
181
gpr[29] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_5.mem[gpr_no];
182
gpr[30] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_6.mem[gpr_no];
183
gpr[31] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_7.mem[gpr_no];
184 67 julius
 `else
185
  `ifdef OR1200_XILINX_RAMB4
186 6 julius
         for(j = 0; j < 16; j = j + 1) begin
187
            gpr[j] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.ramb4_s16_0.mem[gpr_no*16+j];
188
         end
189 67 julius
         for(j = 0; j < 16; j = j + 1) begin
190
            gpr[j+16] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.ramb4_s16_1.mem[gpr_no*16+j];
191
         end
192 6 julius
  `else
193 67 julius
   `ifdef OR1200_ARTISAN_SDP
194
   `else
195
    `ifdef OR1200_XILINX_RAMB16
196
     `ifdef legacy_model
197
         for(j = 0; j < 32; j = j + 1) begin
198
            gpr[j] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.ramb16_s36_s36.mem[gpr_no*32+j];
199
         end
200
     `else
201
         gpr = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.ramb16_s36_s36.mem[gpr_no];
202
     `endif
203
    `else
204
         gpr = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.mem[gpr_no];
205
    `endif
206
   `endif
207 6 julius
  `endif
208
`endif
209
`endif
210
         end
211
 endtask
212
 
213
   //
214
   // Write state of the OR1200 registers into a file
215
   //
216
   // Limitation: only a small subset of register file RAMs
217
   // are supported
218
   //
219
   task display_arch_state;
220
      reg [5:0] i;
221
      reg [31:0] r;
222
      integer    j;
223
      begin
224
`ifdef OR1200_DISPLAY_ARCH_STATE
225
         ref = ref + 1;
226
         $fdisplay(flookup, "Instruction %d: %t", insns, $time);
227
         $fwrite(fexe, "\nEXECUTED(%d): %h:  %h", insns, `OR1200_TOP.or1200_cpu.or1200_except.wb_pc, `OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn);
228
         for(i = 0; i < 32; i = i + 1) begin
229
            if (i % 4 == 0)
230
              $fdisplay(fexe);
231
            get_gpr(i, r);
232
            $fwrite(fexe, "GPR%d: %h  ", i, r);
233
         end
234
         $fdisplay(fexe);
235
         r = `OR1200_TOP.or1200_cpu.or1200_sprs.sr;
236
         $fwrite(fexe, "SR   : %h  ", r);
237
         r = `OR1200_TOP.or1200_cpu.or1200_sprs.epcr;
238
         $fwrite(fexe, "EPCR0: %h  ", r);
239
         r = `OR1200_TOP.or1200_cpu.or1200_sprs.eear;
240
         $fwrite(fexe, "EEAR0: %h  ", r);
241
         r = `OR1200_TOP.or1200_cpu.or1200_sprs.esr;
242
         $fdisplay(fexe, "ESR0 : %h", r);
243
         insns = insns + 1;
244
`endif
245
end
246
   endtask // display_arch_state
247
 
248 57 julius
   //
249
   // Write state of the OR1200 registers into a file; version for exception
250
   //
251
   task display_arch_state_except;
252
      reg [5:0] i;
253
      reg [31:0] r;
254
      integer    j;
255
      begin
256
`ifdef OR1200_DISPLAY_ARCH_STATE
257
         ref = ref + 1;
258
         $fdisplay(flookup, "Instruction %d: %t", insns, $time);
259
         $fwrite(fexe, "\nEXECUTED(%d): %h:  %h  (exception)", insns, `OR1200_TOP.or1200_cpu.or1200_except.ex_pc, `OR1200_TOP.or1200_cpu.or1200_ctrl.ex_insn);
260
         for(i = 0; i < 32; i = i + 1) begin
261
            if (i % 4 == 0)
262
              $fdisplay(fexe);
263
            get_gpr(i, r);
264
            $fwrite(fexe, "GPR%d: %h  ", i, r);
265
         end
266
         $fdisplay(fexe);
267
         r = `OR1200_TOP.or1200_cpu.or1200_sprs.sr;
268
         $fwrite(fexe, "SR   : %h  ", r);
269
         r = `OR1200_TOP.or1200_cpu.or1200_sprs.epcr;
270
         $fwrite(fexe, "EPCR0: %h  ", r);
271
         r = `OR1200_TOP.or1200_cpu.or1200_sprs.eear;
272
         $fwrite(fexe, "EEAR0: %h  ", r);
273
         r = `OR1200_TOP.or1200_cpu.or1200_sprs.esr;
274
         $fdisplay(fexe, "ESR0 : %h", r);
275
         insns = insns + 1;
276
`endif
277
      end
278
   endtask // display_arch_state_except
279
 
280 6 julius
   /* Keep a trace buffer of the last lot of instructions and addresses
281
    * "executed",as read from the writeback stage, and cause a $finish if we hit
282
    * an instruction that is invalid, such as all zeros.
283
    * Currently, only breaks on an all zero instruction, but should probably be
284
    * made to break for anything with an X in it too. And of course ideally this
285
    * shouldn't be needed - but is handy if someone changes something and stops
286
    * the test continuing forever.
287
    */
288 49 julius
   integer num_nul_inst;
289
   initial num_nul_inst = 0;
290
 
291 6 julius
   task monitor_for_crash;
292
      `define OR1200_MONITOR_CRASH_TRACE_SIZE 32
293
      reg [31:0] insn_trace [0:`OR1200_MONITOR_CRASH_TRACE_SIZE-1]; //Trace buffer of 32 instructions
294
      reg [31:0] addr_trace [0:`OR1200_MONITOR_CRASH_TRACE_SIZE-1]; //Trace buffer of the addresses of those instructions
295
      integer i;
296
 
297
     begin
298
        if (`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn == 32'h00000000)
299 49 julius
          num_nul_inst = num_nul_inst + 1;
300
 
301
        if (num_nul_inst == 1000) // Sat a loop a bit too long...
302 6 julius
          begin
303
             $fdisplay(fgeneral, "ERROR - no instruction at PC %h", `OR1200_TOP.or1200_cpu.or1200_except.wb_pc);
304
             $fdisplay(fgeneral, "Crash trace: Last %d instructions: ",`OR1200_MONITOR_CRASH_TRACE_SIZE);
305
 
306
             $fdisplay(fgeneral, "PC\t\tINSTR");
307
             for(i=`OR1200_MONITOR_CRASH_TRACE_SIZE-1;i>=0;i=i-1) begin
308
                $fdisplay(fgeneral, "%h\t%h",addr_trace[i], insn_trace[i]);
309
             end
310
             #100 $finish;
311
          end
312
        else
313
          begin
314
             for(i=`OR1200_MONITOR_CRASH_TRACE_SIZE-1;i>0;i=i-1) begin
315
                insn_trace[i] = insn_trace[i-1];
316
                addr_trace[i] = addr_trace[i-1];
317
             end
318
             insn_trace[0] = `OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn;
319
             addr_trace[0] = `OR1200_TOP.or1200_cpu.or1200_except.wb_pc;
320
          end
321
 
322
     end
323
   endtask // monitor_for_crash
324
 
325
   integer iwb_progress;
326
   reg [31:0] iwb_progress_addr;
327
   //
328
   // WISHBONE bus checker
329
   //
330
   always @(posedge `OR1200_TOP.iwb_clk_i)
331
     if (`OR1200_TOP.iwb_rst_i) begin
332
        iwb_progress = 0;
333
        iwb_progress_addr = `OR1200_TOP.iwb_adr_o;
334
     end
335
     else begin
336
        if (`OR1200_TOP.iwb_cyc_o && (iwb_progress != 2)) begin
337
           iwb_progress = 1;
338
        end
339
        if (`OR1200_TOP.iwb_stb_o) begin
340
           if (iwb_progress >= 1) begin
341
              if (iwb_progress == 1)
342
                iwb_progress_addr = `OR1200_TOP.iwb_adr_o;
343
              iwb_progress = 2;
344
           end
345
           else begin
346
              $fdisplay(fgeneral, "WISHBONE protocol violation: `OR1200_TOP.iwb_stb_o raised without `OR1200_TOP.iwb_cyc_o, at %t\n", $time);
347
              #100 $finish;
348
           end
349
        end
350
        if (`OR1200_TOP.iwb_ack_i & `OR1200_TOP.iwb_err_i) begin
351
           $fdisplay(fgeneral, "WISHBONE protocol violation: `OR1200_TOP.iwb_ack_i and `OR1200_TOP.iwb_err_i raised at the same time, at %t\n", $time);
352
        end
353
        if ((iwb_progress == 2) && (iwb_progress_addr != `OR1200_TOP.iwb_adr_o)) begin
354
           $fdisplay(fgeneral, "WISHBONE protocol violation: `OR1200_TOP.iwb_adr_o changed while waiting for `OR1200_TOP.iwb_err_i/`OR1200_TOP.iwb_ack_i, at %t\n", $time);
355
           #100 $finish;
356
        end
357
        if (`OR1200_TOP.iwb_ack_i | `OR1200_TOP.iwb_err_i)
358
          if (iwb_progress == 2) begin
359
             iwb_progress = 0;
360
             iwb_progress_addr = `OR1200_TOP.iwb_adr_o;
361
          end
362
          else begin
363
             $fdisplay(fgeneral, "WISHBONE protocol violation: `OR1200_TOP.iwb_ack_i/`OR1200_TOP.iwb_err_i raised without `OR1200_TOP.iwb_cyc_i/`OR1200_TOP.iwb_stb_i, at %t\n", $time);
364
             #100 $finish;
365
          end
366
        if ((iwb_progress == 2) && !`OR1200_TOP.iwb_stb_o) begin
367
           $fdisplay(fgeneral, "WISHBONE protocol violation: `OR1200_TOP.iwb_stb_o lowered without `OR1200_TOP.iwb_err_i/`OR1200_TOP.iwb_ack_i, at %t\n", $time);
368
           /*                   #100 $finish;*/
369
        end
370
     end
371
 
372
   integer dwb_progress;
373
reg [31:0] dwb_progress_addr;
374
//
375
// WISHBONE bus checker
376
//
377
always @(posedge `OR1200_TOP.dwb_clk_i)
378
  if (`OR1200_TOP.dwb_rst_i)
379
    dwb_progress = 0;
380
  else begin
381
     if (`OR1200_TOP.dwb_cyc_o && (dwb_progress != 2))
382
       dwb_progress = 1;
383
     if (`OR1200_TOP.dwb_stb_o)
384
       if (dwb_progress >= 1) begin
385
          if (dwb_progress == 1)
386
            dwb_progress_addr = `OR1200_TOP.dwb_adr_o;
387
          dwb_progress = 2;
388
       end
389
       else begin
390
          $fdisplay(fgeneral, "WISHBONE protocol violation: `OR1200_TOP.dwb_stb_o raised without `OR1200_TOP.dwb_cyc_o, at %t\n", $time);
391
          #100 $finish;
392
       end
393
     if (`OR1200_TOP.dwb_ack_i & `OR1200_TOP.dwb_err_i) begin
394
        $fdisplay(fgeneral, "WISHBONE protocol violation: `OR1200_TOP.dwb_ack_i and `OR1200_TOP.dwb_err_i raised at the same time, at %t\n", $time);
395
     end
396
     if ((dwb_progress == 2) && (dwb_progress_addr != `OR1200_TOP.dwb_adr_o)) begin
397
        $fdisplay(fgeneral, "WISHBONE protocol violation: `OR1200_TOP.dwb_adr_o changed while waiting for `OR1200_TOP.dwb_err_i/`OR1200_TOP.dwb_ack_i, at %t\n", $time);
398
        #100 $finish;
399
     end
400
     if (`OR1200_TOP.dwb_ack_i | `OR1200_TOP.dwb_err_i)
401
       if (dwb_progress == 2) begin
402
          dwb_progress = 0;
403
          dwb_progress_addr = `OR1200_TOP.dwb_adr_o;
404
       end
405
       else begin
406
          $fdisplay(fgeneral, "WISHBONE protocol violation: `OR1200_TOP.dwb_ack_i/`OR1200_TOP.dwb_err_i raised without `OR1200_TOP.dwb_cyc_i/`OR1200_TOP.dwb_stb_i, at %t\n", $time);
407
          #100 $finish;
408
       end
409
     if ((dwb_progress == 2) && !`OR1200_TOP.dwb_stb_o) begin
410
        $fdisplay(fgeneral, "WISHBONE protocol violation: `OR1200_TOP.dwb_stb_o lowered without `OR1200_TOP.dwb_err_i/`OR1200_TOP.dwb_ack_i, at %t\n", $time);
411
        #100 $finish;
412
     end
413
       end
414
 
415
//
416
// Hooks for:
417
// - displaying registers
418
// - end of simulation
419
// - access to SPRs
420
//
421
   always @(posedge `OR1200_TOP.or1200_cpu.or1200_ctrl.clk)
422
     if (!`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_freeze) begin
423
        #2;
424
        if (((`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn[31:26] != `OR1200_OR32_NOP) || !`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn[16])
425
            && !(`OR1200_TOP.or1200_cpu.or1200_except.except_flushpipe && `OR1200_TOP.or1200_cpu.or1200_except.ex_dslot))
426
          begin
427
             display_arch_state;
428
             monitor_for_crash;
429
          end
430
        else
431
          if (`OR1200_TOP.or1200_cpu.or1200_except.except_flushpipe)
432
            display_arch_state_except;
433
        if (`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn == 32'h1500_0001) begin // small hack to stop simulation (l.nop 1)
434
           get_gpr(3, r3);
435
           $fdisplay(fgeneral, "%t: l.nop exit (%h)", $time, r3);
436
           $finish;
437
        end
438
        if (`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn == 32'h1500_000a) begin // debug if test (l.nop 10)
439
           $fdisplay(fgeneral, "%t: l.nop dbg_if_test", $time);
440
`ifdef DBG_IF_MODEL
441
           xess_top.i_xess_fpga.dbg_if_model.dbg_if_test_go = 1;
442
`endif
443
        end
444
if (`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn == 32'h1500_0002) begin // simulation reports (l.nop 2)
445
   get_gpr(3, r3);
446
   $fdisplay(fgeneral, "%t: l.nop report (%h)", $time, r3);
447
end
448
        if (`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn == 32'h1500_0003) begin // simulation printfs (l.nop 3)
449
           get_gpr(3, r3);
450
           $fdisplay(fgeneral, "%t: l.nop printf (%h)", $time, r3);
451
        end
452
        if (`OR1200_TOP.or1200_cpu.or1200_sprs.sprs_op == `OR1200_ALUOP_MTSR)  // l.mtspr
453
          $fdisplay(fspr, "%t: Write to SPR : [%h] <- %h", $time,
454
                    `OR1200_TOP.or1200_cpu.or1200_sprs.spr_addr, `OR1200_TOP.or1200_cpu.or1200_sprs.spr_dat_o);
455
        if (`OR1200_TOP.or1200_cpu.or1200_sprs.sprs_op == `OR1200_ALUOP_MFSR)  // l.mfspr
456
          $fdisplay(fspr, "%t: Read from SPR: [%h] -> %h", $time,
457
                    `OR1200_TOP.or1200_cpu.or1200_sprs.spr_addr, `OR1200_TOP.or1200_cpu.or1200_sprs.to_wbmux);
458
     end
459
 
460
endmodule

powered by: WebSVN 2.1.0

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