//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// OR1200's simulation monitor ////
|
//// OR1200's simulation monitor ////
|
//// ////
|
//// ////
|
//// This file is part of the OpenRISC 1200 project ////
|
//// This file is part of the OpenRISC 1200 project ////
|
//// http://www.opencores.org/cores/or1k/ ////
|
//// http://www.opencores.org/cores/or1k/ ////
|
//// ////
|
//// ////
|
//// Description ////
|
//// Description ////
|
//// Simulation monitor ////
|
//// Simulation monitor ////
|
//// ////
|
//// ////
|
//// To Do: ////
|
//// To Do: ////
|
//// - move it to bench ////
|
//// - move it to bench ////
|
//// ////
|
//// ////
|
//// Author(s): ////
|
//// Author(s): ////
|
//// - Damjan Lampret, lampret@opencores.org ////
|
//// - Damjan Lampret, lampret@opencores.org ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
//// ////
|
//// ////
|
//// This source file may be used and distributed without ////
|
//// This source file may be used and distributed without ////
|
//// restriction provided that this copyright statement is not ////
|
//// restriction provided that this copyright statement is not ////
|
//// removed from the file and that any derivative work contains ////
|
//// removed from the file and that any derivative work contains ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// ////
|
//// ////
|
//// This source file is free software; you can redistribute it ////
|
//// This source file is free software; you can redistribute it ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// later version. ////
|
//// later version. ////
|
//// ////
|
//// ////
|
//// This source is distributed in the hope that it will be ////
|
//// This source is distributed in the hope that it will be ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// details. ////
|
//// details. ////
|
//// ////
|
//// ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// Public License along with this source; if not, download it ////
|
//// Public License along with this source; if not, download it ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
// Revision 1.1 2001/08/20 18:17:52 damjan
|
// Revision 1.1 2001/08/20 18:17:52 damjan
|
// Initial revision
|
// Initial revision
|
//
|
//
|
// Revision 1.1 2001/08/13 03:37:07 lampret
|
// Revision 1.1 2001/08/13 03:37:07 lampret
|
// Added monitor.v and timescale.v
|
// Added monitor.v and timescale.v
|
//
|
//
|
// Revision 1.1 2001/07/20 00:46:03 lampret
|
// Revision 1.1 2001/07/20 00:46:03 lampret
|
// Development version of RTL. Libraries are missing.
|
// Development version of RTL. Libraries are missing.
|
//
|
//
|
//
|
//
|
|
|
`include "defines.v"
|
`include "defines.v"
|
|
|
// Enable debug_mem task. Only affects simulation.
|
// Enable debug_mem task. Only affects simulation.
|
`define enable_debug_mem
|
`define enable_debug_mem
|
|
|
// Enable display_arch_state task. Only affects simulation.
|
// Enable display_arch_state task. Only affects simulation.
|
`define enable_display_arch_state
|
`define enable_display_arch_state
|
|
|
module or1200_monitor;
|
module or1200_monitor;
|
|
|
task monitortask;
|
task monitortask;
|
begin
|
begin
|
end
|
end
|
endtask
|
endtask
|
|
|
integer fexe;
|
integer fexe;
|
reg [23:0] ref;
|
reg [23:0] ref;
|
|
|
initial begin
|
initial begin
|
ref = 0;
|
ref = 0;
|
fexe = $fopen("executed.log");
|
fexe = $fopen("executed.log");
|
$timeformat (-9, 2, " ns", 12);
|
$timeformat (-9, 2, " ns", 12);
|
end
|
end
|
|
|
task finish_simulation;
|
task finish_simulation;
|
begin
|
begin
|
$fclose(fexe);
|
$fclose(fexe);
|
display_arch_state;
|
display_arch_state;
|
display_memory(0, 8191);
|
display_memory(0, 8191);
|
$shm_save;
|
$shm_save;
|
$shm_close;
|
$shm_close;
|
$dumpflush;
|
$dumpflush;
|
$finish;
|
$finish;
|
end
|
end
|
endtask
|
endtask
|
|
|
task caught_sys203;
|
task caught_sys203;
|
begin
|
begin
|
$display("simulation terminated due to l.sys 203");
|
$display("simulation terminated due to l.sys 203");
|
finish_simulation;
|
finish_simulation;
|
end
|
end
|
endtask
|
endtask
|
|
|
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 enable_display_arch_state
|
`ifdef enable_display_arch_state
|
ref = ref + 1;
|
ref = ref + 1;
|
// if (ref == 17890) begin
|
// if (ref == 17890) begin
|
// $dumpfile("dump.vcd");
|
// $dumpfile("dump.vcd");
|
// $dumpvars(20,tb_or1200);
|
// $dumpvars(20,tb_or1200);
|
// end
|
// end
|
$fwrite(fexe, "\nEXECUTED(): %h: %h", xess_top.i_xess_fpga.risc.cpu.except.wb_pc, xess_top.i_xess_fpga.risc.cpu.id.wb_insn);
|
$fwrite(fexe, "\nEXECUTED(): %h: %h", xess_top.i_xess_fpga.risc.cpu.except.wb_pc, xess_top.i_xess_fpga.risc.cpu.id.wb_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);
|
`ifdef XILINX_RAMB4
|
`ifdef XILINX_RAMB4
|
r = 32'h0000_0000;
|
r = 32'h0000_0000;
|
for(j = 0; j < 16; j = j + 1) begin
|
for(j = 0; j < 16; j = j + 1) begin
|
r[j] = xess_top.i_xess_fpga.risc.cpu.rf.rf_a.ramb4_s16_0.mem[i*16+j];
|
r[j] = xess_top.i_xess_fpga.risc.cpu.rf.rf_a.ramb4_s16_0.mem[i*16+j];
|
end
|
end
|
for(j = 0; j < 16; j = j + 1) begin
|
for(j = 0; j < 16; j = j + 1) begin
|
r[j+16] = xess_top.i_xess_fpga.risc.cpu.rf.rf_a.ramb4_s16_1.mem[i*16+j];
|
r[j+16] = xess_top.i_xess_fpga.risc.cpu.rf.rf_a.ramb4_s16_1.mem[i*16+j];
|
end
|
end
|
$fwrite(fexe, "GPR%d: %h ", i, r);
|
$fwrite(fexe, "GPR%d: %h ", i, r);
|
`else
|
`else
|
`ifdef XILINX_RAM32X1D
|
`ifdef XILINX_RAM32X1D
|
`else
|
`else
|
`ifdef ARTISAN_SDP
|
`ifdef ARTISAN_SDP
|
`else
|
`else
|
$fwrite(fexe, "GPR%d: %h ", i, xess_top.i_xess_fpga.risc.cpu.rf.rf_a.mem[i]);
|
$fwrite(fexe, "GPR%d: %h ", i, xess_top.i_xess_fpga.risc.cpu.rf.rf_a.mem[i]);
|
`endif
|
`endif
|
`endif
|
`endif
|
`endif
|
`endif
|
end
|
end
|
$fdisplay(fexe);
|
$fdisplay(fexe);
|
r = xess_top.i_xess_fpga.risc.cpu.sprs.sr;
|
r = xess_top.i_xess_fpga.risc.cpu.sprs.sr;
|
$fwrite(fexe, "SR : %h ", r);
|
$fwrite(fexe, "SR : %h ", r);
|
r = xess_top.i_xess_fpga.risc.cpu.sprs.epcr;
|
r = xess_top.i_xess_fpga.risc.cpu.sprs.epcr;
|
$fwrite(fexe, "EPCR0: %h ", r);
|
$fwrite(fexe, "EPCR0: %h ", r);
|
r = xess_top.i_xess_fpga.risc.cpu.sprs.eear;
|
r = xess_top.i_xess_fpga.risc.cpu.sprs.eear;
|
$fwrite(fexe, "EEAR0: %h ", r);
|
$fwrite(fexe, "EEAR0: %h ", r);
|
r = xess_top.i_xess_fpga.risc.cpu.sprs.esr;
|
r = xess_top.i_xess_fpga.risc.cpu.sprs.esr;
|
$fdisplay(fexe, "ESR0 : %h", r);
|
$fdisplay(fexe, "ESR0 : %h", r);
|
// $fdisplay(fexe);
|
// $fdisplay(fexe);
|
`endif
|
`endif
|
end
|
end
|
endtask
|
endtask
|
|
|
task display_memory;
|
task display_memory;
|
input [31:0] from;
|
input [31:0] from;
|
input [31:0] to;
|
input [31:0] to;
|
integer i;
|
integer i;
|
begin
|
begin
|
// for(i = from; i < to; i = i + 4)
|
// for(i = from; i < to; i = i + 4)
|
// $display("mem[%h] = %h mem[%h] = %h mem[%h] = %h mem[%h] = %h ",
|
// $display("mem[%h] = %h mem[%h] = %h mem[%h] = %h mem[%h] = %h ",
|
// i, sram2.ramCore[i], i+4, sram2.ramCore[i+1], i+8, sram2.ramCore[i+2], i+12, sram2.ramCore[i+3]); //zSramX32
|
// i, sram2.ramCore[i], i+4, sram2.ramCore[i+1], i+8, sram2.ramCore[i+2], i+12, sram2.ramCore[i+3]); //zSramX32
|
// i<<2, sram2.mem[i], (i<<2)+4, sram2.mem[i+1], (i<<2)+8, sram2.mem[i+2], (i<<2)+12, sram2.mem[i+3]); //sram32kx32
|
// i<<2, sram2.mem[i], (i<<2)+4, sram2.mem[i+1], (i<<2)+8, sram2.mem[i+2], (i<<2)+12, sram2.mem[i+3]); //sram32kx32
|
end
|
end
|
endtask
|
endtask
|
|
|
task debug_mem;
|
task debug_mem;
|
input [79:0] device;
|
input [79:0] device;
|
input write;
|
input write;
|
input [31:0] addr;
|
input [31:0] addr;
|
input [31:0] data;
|
input [31:0] data;
|
input [3:0] bs;
|
input [3:0] bs;
|
begin
|
begin
|
`ifdef enable_debug_mem
|
`ifdef enable_debug_mem
|
if (write)
|
if (write)
|
$display( "%t: WRITE to %s addr 0x%h with a value of 0x%h using byte enables of 'b%b", $time, device, addr, data, bs);
|
$display( "%t: WRITE to %s addr 0x%h with a value of 0x%h using byte enables of 'b%b", $time, device, addr, data, bs);
|
else
|
else
|
$display( "%t: READ from %s addr 0x%h which contains a value of 0x%h using byte enables of 'b%b", $time, device, addr, data, bs);
|
$display( "%t: READ from %s addr 0x%h which contains a value of 0x%h using byte enables of 'b%b", $time, device, addr, data, bs);
|
`endif
|
`endif
|
end
|
end
|
endtask
|
endtask
|
|
|
always @(posedge xess_top.i_xess_fpga.risc.cpu.id.clk)
|
always @(posedge xess_top.i_xess_fpga.risc.cpu.id.clk)
|
if (!xess_top.i_xess_fpga.risc.cpu.id.wb_freeze) begin
|
if (!xess_top.i_xess_fpga.risc.cpu.id.wb_freeze) begin
|
#2;
|
#2;
|
if ((xess_top.i_xess_fpga.risc.cpu.id.wb_insn != 32'h1500ffff) && (xess_top.i_xess_fpga.risc.cpu.id.wb_insn != 32'h14000000)
|
if ((xess_top.i_xess_fpga.risc.cpu.id.wb_insn != 32'h1500ffff) && (xess_top.i_xess_fpga.risc.cpu.id.wb_insn != 32'h14000000)
|
&& (xess_top.i_xess_fpga.risc.cpu.id.wb_insn != 32'h14004444))
|
&& (xess_top.i_xess_fpga.risc.cpu.id.wb_insn != 32'h14004444))
|
display_arch_state;
|
display_arch_state;
|
if (xess_top.i_xess_fpga.risc.cpu.id.ex_insn == 32'h200000cb) // small hack to stop simulation (l.sys 203)
|
if (xess_top.i_xess_fpga.risc.cpu.id.ex_insn == 32'h200000cb) // small hack to stop simulation (l.sys 203)
|
caught_sys203;
|
caught_sys203;
|
end
|
end
|
|
|
endmodule
|
endmodule
|
|
|
|
|
|
|