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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [verilog/] [or1200_monitor.v] - Diff between revs 360 and 397

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 360 Rev 397
Line 39... Line 39...
//
//
// Top of OR1200 inside test bench
// Top of OR1200 inside test bench
//
//
`define OR1200_TOP orpsoc_testbench.dut.or1200_top
`define OR1200_TOP orpsoc_testbench.dut.or1200_top
 
 
 
//
 
// Define to enable lookup file generation
 
//
 
//`define OR1200_MONITOR_LOOKUP
 
 
 
//
 
// Define to enable SPR access log file generation
 
//
 
//`define OR1200_MONITOR_SPRS
 
 
//
//
// Enable display_arch_state task
// Enable logging of state during execution
//
//
//`define OR1200_DISPLAY_ARCH_STATE
//`define OR1200_MONITOR_EXEC_STATE
 
 
//
//
// Enable disassembly of instructions in execution log
// Enable disassembly of instructions in execution state log
//
//
//`define OR1200_MONITOR_PRINT_DISASSEMBLY
//`define OR1200_MONITOR_PRINT_DISASSEMBLY
 
 
 
// Can either individually enable things above, or usually have the scripts
 
// running the simulation pass the PROCESSOR_MONITOR_ENABLE_LOGS define to
 
// enable them all.
 
 
 
`ifdef PROCESSOR_MONITOR_ENABLE_LOGS
 
 `define OR1200_MONITOR_EXEC_STATE
 
 `define OR1200_MONITOR_SPRS
 
 `define OR1200_MONITOR_LOOKUP
 
`endif
 
 
//
//
// Top of OR1200 inside test bench
// Top of OR1200 inside test bench
//
//
`define CPU or1200
`define CPU or1200
Line 65... Line 83...
 
 
module or1200_monitor;
module or1200_monitor;
 
 
   integer fexe;
   integer fexe;
   reg [23:0] ref;
   reg [23:0] ref;
 
`ifdef OR1200_MONITOR_SPRS
   integer    fspr;
   integer    fspr;
 
`endif
   integer    fgeneral;
   integer    fgeneral;
 
`ifdef OR1200_MONITOR_LOOKUP
   integer    flookup;
   integer    flookup;
 
`endif
   integer    r3;
   integer    r3;
   integer    insns;
   integer    insns;
 
 
 
 
   //
   //
   // Initialization
   // Initialization
   //
   //
   initial begin
   initial begin
      ref = 0;
      ref = 0;
 
`ifdef OR1200_MONITOR_EXEC_STATE
      fexe = $fopen({"../out/",`TEST_NAME_STRING,"-executed.log"});
      fexe = $fopen({"../out/",`TEST_NAME_STRING,"-executed.log"});
 
`endif
      $timeformat (-9, 2, " ns", 12);
      $timeformat (-9, 2, " ns", 12);
 
`ifdef OR1200_MONITOR_SPRS
      fspr = $fopen({"../out/",`TEST_NAME_STRING,"-sprs.log"});
      fspr = $fopen({"../out/",`TEST_NAME_STRING,"-sprs.log"});
 
`endif
      fgeneral = $fopen({"../out/",`TEST_NAME_STRING,"-general.log"});
      fgeneral = $fopen({"../out/",`TEST_NAME_STRING,"-general.log"});
 
`ifdef OR1200_MONITOR_LOOKUP
      flookup = $fopen({"../out/",`TEST_NAME_STRING,"-lookup.log"});
      flookup = $fopen({"../out/",`TEST_NAME_STRING,"-lookup.log"});
 
`endif
      insns = 0;
      insns = 0;
 
 
   end
   end
 
 
   //
   //
Line 121... Line 149...
   task display_arch_state;
   task display_arch_state;
      reg [5:0] i;
      reg [5:0] i;
      reg [31:0] r;
      reg [31:0] r;
      integer    j;
      integer    j;
      begin
      begin
`ifdef OR1200_DISPLAY_ARCH_STATE
`ifdef OR1200_MONITOR_EXEC_STATE
         ref = ref + 1;
         ref = ref + 1;
 
 `ifdef OR1200_MONITOR_LOOKUP
         $fdisplay(flookup, "Instruction %d: %t", insns, $time);
         $fdisplay(flookup, "Instruction %d: %t", insns, $time);
 
 `endif
         $fwrite(fexe, "\nEXECUTED(%d): %h:  %h", insns,
         $fwrite(fexe, "\nEXECUTED(%d): %h:  %h", insns,
                 `OR1200_TOP.`CPU_cpu.`CPU_except.wb_pc,
                 `OR1200_TOP.`CPU_cpu.`CPU_except.wb_pc,
                 `OR1200_TOP.`CPU_cpu.`CPU_ctrl.wb_insn);
                 `OR1200_TOP.`CPU_cpu.`CPU_ctrl.wb_insn);
 `ifdef OR1200_MONITOR_PRINT_DISASSEMBLY
 `ifdef OR1200_MONITOR_PRINT_DISASSEMBLY
         $fwrite(fexe,"\t");
         $fwrite(fexe,"\t");
Line 147... Line 177...
         $fwrite(fexe, "EPCR0: %h  ", r);
         $fwrite(fexe, "EPCR0: %h  ", r);
         r = `OR1200_TOP.`CPU_cpu.`CPU_sprs.eear;
         r = `OR1200_TOP.`CPU_cpu.`CPU_sprs.eear;
         $fwrite(fexe, "EEAR0: %h  ", r);
         $fwrite(fexe, "EEAR0: %h  ", r);
         r = `OR1200_TOP.`CPU_cpu.`CPU_sprs.esr;
         r = `OR1200_TOP.`CPU_cpu.`CPU_sprs.esr;
         $fdisplay(fexe, "ESR0 : %h", r);
         $fdisplay(fexe, "ESR0 : %h", r);
`endif //  `ifdef OR1200_DISPLAY_ARCH_STATE
`endif //  `ifdef OR1200_MONITOR_EXEC_STATE
`ifdef OR1200_DISPLAY_EXECUTED
`ifdef OR1200_DISPLAY_EXECUTED
         ref = ref + 1;
         ref = ref + 1;
 
 `ifdef OR1200_MONITOR_LOOKUP
         $fdisplay(flookup, "Instruction %d: %t", insns, $time);
         $fdisplay(flookup, "Instruction %d: %t", insns, $time);
 
 `endif
         $fwrite(fexe, "\nEXECUTED(%d): %h:  %h", insns, `OR1200_TOP.`CPU_cpu.`CPU_except.wb_pc, `OR1200_TOP.`CPU_cpu.`CPU_ctrl.wb_insn);
         $fwrite(fexe, "\nEXECUTED(%d): %h:  %h", insns, `OR1200_TOP.`CPU_cpu.`CPU_except.wb_pc, `OR1200_TOP.`CPU_cpu.`CPU_ctrl.wb_insn);
`endif
`endif
         insns = insns + 1;
         insns = insns + 1;
end
end
   endtask // display_arch_state
   endtask // display_arch_state
Line 217... Line 249...
   task display_arch_state_except;
   task display_arch_state_except;
      reg [5:0] i;
      reg [5:0] i;
      reg [31:0] r;
      reg [31:0] r;
      integer    j;
      integer    j;
      begin
      begin
`ifdef OR1200_DISPLAY_ARCH_STATE
`ifdef OR1200_MONITOR_EXEC_STATE
         ref = ref + 1;
         ref = ref + 1;
 
 `ifdef OR1200_MONITOR_LOOKUP
         $fdisplay(flookup, "Instruction %d: %t", insns, $time);
         $fdisplay(flookup, "Instruction %d: %t", insns, $time);
 
 `endif
         $fwrite(fexe, "\nEXECUTED(%d): %h:  %h  (exception)", insns, `OR1200_TOP.`CPU_cpu.`CPU_except.ex_pc, `OR1200_TOP.`CPU_cpu.`CPU_ctrl.ex_insn);
         $fwrite(fexe, "\nEXECUTED(%d): %h:  %h  (exception)", insns, `OR1200_TOP.`CPU_cpu.`CPU_except.ex_pc, `OR1200_TOP.`CPU_cpu.`CPU_ctrl.ex_insn);
         for(i = 0; i < 32; i = i + 1) begin
         for(i = 0; i < 32; i = i + 1) begin
            if (i % 4 == 0)
            if (i % 4 == 0)
              $fdisplay(fexe);
              $fdisplay(fexe);
            get_gpr(i, r);
            get_gpr(i, r);
Line 237... Line 271...
         r = `OR1200_TOP.`CPU_cpu.`CPU_sprs.eear;
         r = `OR1200_TOP.`CPU_cpu.`CPU_sprs.eear;
         $fwrite(fexe, "EEAR0: %h  ", r);
         $fwrite(fexe, "EEAR0: %h  ", r);
         r = `OR1200_TOP.`CPU_cpu.`CPU_sprs.esr;
         r = `OR1200_TOP.`CPU_cpu.`CPU_sprs.esr;
         $fdisplay(fexe, "ESR0 : %h", r);
         $fdisplay(fexe, "ESR0 : %h", r);
         insns = insns + 1;
         insns = insns + 1;
`endif //  `ifdef OR1200_DISPLAY_ARCH_STATE
`endif //  `ifdef OR1200_MONITOR_EXEC_STATE
`ifdef OR1200_DISPLAY_EXECUTED
`ifdef OR1200_DISPLAY_EXECUTED
         ref = ref + 1;
         ref = ref + 1;
 
 `ifdef OR1200_MONITOR_LOOKUP
         $fdisplay(flookup, "Instruction %d: %t", insns, $time);
         $fdisplay(flookup, "Instruction %d: %t", insns, $time);
 
 `endif
         $fwrite(fexe, "\nEXECUTED(%d): %h:  %h  (exception)", insns,
         $fwrite(fexe, "\nEXECUTED(%d): %h:  %h  (exception)", insns,
                 `OR1200_TOP.`CPU_cpu.`CPU_except.ex_pc,
                 `OR1200_TOP.`CPU_cpu.`CPU_except.ex_pc,
                 `OR1200_TOP.`CPU_cpu.`CPU_ctrl.ex_insn);
                 `OR1200_TOP.`CPU_cpu.`CPU_ctrl.ex_insn);
         insns = insns + 1;
         insns = insns + 1;
`endif
`endif
Line 369... Line 405...
           $finish;
           $finish;
        end
        end
        // debug if test (l.nop 10)
        // debug if test (l.nop 10)
        if (`OR1200_TOP.`CPU_cpu.`CPU_ctrl.wb_insn == 32'h1500_000a) begin
        if (`OR1200_TOP.`CPU_cpu.`CPU_ctrl.wb_insn == 32'h1500_000a) begin
           $fdisplay(fgeneral, "%t: l.nop dbg_if_test", $time);
           $fdisplay(fgeneral, "%t: l.nop dbg_if_test", $time);
`ifdef DBG_IF_MODEL
 
           xess_top.i_xess_fpga.dbg_if_model.dbg_if_test_go = 1;
 
`endif
 
        end
        end
        // simulation reports (l.nop 2)
        // simulation reports (l.nop 2)
        if (`OR1200_TOP.`CPU_cpu.`CPU_ctrl.wb_insn == 32'h1500_0002) begin
        if (`OR1200_TOP.`CPU_cpu.`CPU_ctrl.wb_insn == 32'h1500_0002) begin
           get_gpr(3, r3);
           get_gpr(3, r3);
           $fdisplay(fgeneral, "%t: l.nop report (%h)", $time, r3);
           $fdisplay(fgeneral, "%t: l.nop report (%h)", $time, r3);
Line 389... Line 422...
           // simulation putc (l.nop 4)
           // simulation putc (l.nop 4)
           get_gpr(3, r3);
           get_gpr(3, r3);
           $write("%c", r3);
           $write("%c", r3);
           $fdisplay(fgeneral, "%t: l.nop putc (%c)", $time, r3);
           $fdisplay(fgeneral, "%t: l.nop putc (%c)", $time, r3);
        end
        end
        if (`OR1200_TOP.`CPU_cpu.alu_op/*`CPU_sprs.sprs_op*/ ==
`ifdef OR1200_MONITOR_SPRS
            `OR1200_ALUOP_MTSR)  // l.mtspr
        if (`OR1200_TOP.`CPU_cpu.`CPU_sprs.spr_we)
          $fdisplay(fspr, "%t: Write to SPR : [%h] <- %h", $time,
          $fdisplay(fspr, "%t: Write to SPR : [%h] <- %h", $time,
                    `OR1200_TOP.`CPU_cpu.alu_op/*`CPU_sprs.spr_addr*/,
                    `OR1200_TOP.`CPU_cpu.`CPU_sprs.spr_addr,
                    `OR1200_TOP.`CPU_cpu.`CPU_sprs.spr_dat_o);
                    `OR1200_TOP.`CPU_cpu.`CPU_sprs.spr_dat_o);
        if (`OR1200_TOP.`CPU_cpu.alu_op/*`CPU_sprs.sprs_op*/ ==
        if ((|`OR1200_TOP.`CPU_cpu.`CPU_sprs.spr_cs) &
            `OR1200_ALUOP_MFSR)  // l.mfspr
            !`OR1200_TOP.`CPU_cpu.`CPU_sprs.spr_we)
          $fdisplay(fspr, "%t: Read from SPR: [%h] -> %h", $time,
          $fdisplay(fspr, "%t: Read from SPR: [%h] -> %h", $time,
                    `OR1200_TOP.`CPU_cpu.`CPU_sprs.spr_addr,
                    `OR1200_TOP.`CPU_cpu.`CPU_sprs.spr_addr,
                    `OR1200_TOP.`CPU_cpu.`CPU_sprs.to_wbmux);
                    `OR1200_TOP.`CPU_cpu.`CPU_sprs.to_wbmux);
 
`endif
     end
     end
 
 
 
 
`ifdef VERSATILE_SDRAM
`ifdef VERSATILE_SDRAM
 `define SDRAM_TOP design_testbench.sdram0
 `define SDRAM_TOP design_testbench.sdram0

powered by: WebSVN 2.1.0

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