1 |
266 |
lampret |
//////////////////////////////////////////////////////////////////////
|
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: not supported by cvs2svn $
|
47 |
318 |
lampret |
// Revision 1.1.1.1 2001/11/04 18:51:07 lampret
|
48 |
|
|
// First import.
|
49 |
|
|
//
|
50 |
266 |
lampret |
// Revision 1.1 2001/08/20 18:17:52 damjan
|
51 |
|
|
// Initial revision
|
52 |
|
|
//
|
53 |
|
|
// Revision 1.1 2001/08/13 03:37:07 lampret
|
54 |
|
|
// Added monitor.v and timescale.v
|
55 |
|
|
//
|
56 |
|
|
// Revision 1.1 2001/07/20 00:46:03 lampret
|
57 |
|
|
// Development version of RTL. Libraries are missing.
|
58 |
|
|
//
|
59 |
|
|
//
|
60 |
|
|
|
61 |
|
|
`include "defines.v"
|
62 |
|
|
|
63 |
|
|
// Enable debug_mem task. Only affects simulation.
|
64 |
|
|
`define enable_debug_mem
|
65 |
|
|
|
66 |
|
|
// Enable display_arch_state task. Only affects simulation.
|
67 |
|
|
`define enable_display_arch_state
|
68 |
|
|
|
69 |
|
|
module or1200_monitor;
|
70 |
|
|
|
71 |
|
|
task monitortask;
|
72 |
|
|
begin
|
73 |
|
|
end
|
74 |
|
|
endtask
|
75 |
|
|
|
76 |
|
|
integer fexe;
|
77 |
|
|
reg [23:0] ref;
|
78 |
|
|
|
79 |
|
|
initial begin
|
80 |
|
|
ref = 0;
|
81 |
|
|
fexe = $fopen("executed.log");
|
82 |
|
|
$timeformat (-9, 2, " ns", 12);
|
83 |
|
|
end
|
84 |
|
|
|
85 |
|
|
task finish_simulation;
|
86 |
|
|
begin
|
87 |
|
|
$fclose(fexe);
|
88 |
|
|
display_arch_state;
|
89 |
|
|
display_memory(0, 8191);
|
90 |
|
|
$shm_save;
|
91 |
|
|
$shm_close;
|
92 |
|
|
$dumpflush;
|
93 |
|
|
$finish;
|
94 |
|
|
end
|
95 |
|
|
endtask
|
96 |
|
|
|
97 |
|
|
task caught_sys203;
|
98 |
|
|
begin
|
99 |
|
|
$display("simulation terminated due to l.sys 203");
|
100 |
|
|
finish_simulation;
|
101 |
|
|
end
|
102 |
|
|
endtask
|
103 |
|
|
|
104 |
|
|
task display_arch_state;
|
105 |
|
|
reg [5:0] i;
|
106 |
|
|
reg [31:0] r;
|
107 |
|
|
integer j;
|
108 |
|
|
begin
|
109 |
|
|
`ifdef enable_display_arch_state
|
110 |
|
|
ref = ref + 1;
|
111 |
|
|
// if (ref == 17890) begin
|
112 |
|
|
// $dumpfile("dump.vcd");
|
113 |
|
|
// $dumpvars(20,tb_or1200);
|
114 |
|
|
// end
|
115 |
|
|
$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);
|
116 |
|
|
for(i = 0; i < 32; i = i + 1) begin
|
117 |
|
|
if (i % 4 == 0)
|
118 |
|
|
$fdisplay(fexe);
|
119 |
|
|
`ifdef XILINX_RAMB4
|
120 |
|
|
r = 32'h0000_0000;
|
121 |
|
|
for(j = 0; j < 16; j = j + 1) begin
|
122 |
|
|
r[j] = xess_top.i_xess_fpga.risc.cpu.rf.rf_a.ramb4_s16_0.mem[i*16+j];
|
123 |
|
|
end
|
124 |
|
|
for(j = 0; j < 16; j = j + 1) begin
|
125 |
|
|
r[j+16] = xess_top.i_xess_fpga.risc.cpu.rf.rf_a.ramb4_s16_1.mem[i*16+j];
|
126 |
|
|
end
|
127 |
|
|
$fwrite(fexe, "GPR%d: %h ", i, r);
|
128 |
|
|
`else
|
129 |
|
|
`ifdef XILINX_RAM32X1D
|
130 |
|
|
`else
|
131 |
|
|
`ifdef ARTISAN_SDP
|
132 |
|
|
`else
|
133 |
|
|
$fwrite(fexe, "GPR%d: %h ", i, xess_top.i_xess_fpga.risc.cpu.rf.rf_a.mem[i]);
|
134 |
|
|
`endif
|
135 |
|
|
`endif
|
136 |
|
|
`endif
|
137 |
|
|
end
|
138 |
|
|
$fdisplay(fexe);
|
139 |
|
|
r = xess_top.i_xess_fpga.risc.cpu.sprs.sr;
|
140 |
|
|
$fwrite(fexe, "SR : %h ", r);
|
141 |
|
|
r = xess_top.i_xess_fpga.risc.cpu.sprs.epcr;
|
142 |
|
|
$fwrite(fexe, "EPCR0: %h ", r);
|
143 |
|
|
r = xess_top.i_xess_fpga.risc.cpu.sprs.eear;
|
144 |
|
|
$fwrite(fexe, "EEAR0: %h ", r);
|
145 |
|
|
r = xess_top.i_xess_fpga.risc.cpu.sprs.esr;
|
146 |
|
|
$fdisplay(fexe, "ESR0 : %h", r);
|
147 |
|
|
// $fdisplay(fexe);
|
148 |
|
|
`endif
|
149 |
|
|
end
|
150 |
|
|
endtask
|
151 |
|
|
|
152 |
|
|
task display_memory;
|
153 |
|
|
input [31:0] from;
|
154 |
|
|
input [31:0] to;
|
155 |
|
|
integer i;
|
156 |
|
|
begin
|
157 |
|
|
// for(i = from; i < to; i = i + 4)
|
158 |
|
|
// $display("mem[%h] = %h mem[%h] = %h mem[%h] = %h mem[%h] = %h ",
|
159 |
|
|
// i, sram2.ramCore[i], i+4, sram2.ramCore[i+1], i+8, sram2.ramCore[i+2], i+12, sram2.ramCore[i+3]); //zSramX32
|
160 |
|
|
// 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
|
161 |
|
|
end
|
162 |
|
|
endtask
|
163 |
|
|
|
164 |
|
|
task debug_mem;
|
165 |
|
|
input [79:0] device;
|
166 |
|
|
input write;
|
167 |
|
|
input [31:0] addr;
|
168 |
|
|
input [31:0] data;
|
169 |
|
|
input [3:0] bs;
|
170 |
|
|
begin
|
171 |
|
|
`ifdef enable_debug_mem
|
172 |
|
|
if (write)
|
173 |
|
|
$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);
|
174 |
|
|
else
|
175 |
|
|
$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);
|
176 |
|
|
`endif
|
177 |
|
|
end
|
178 |
|
|
endtask
|
179 |
|
|
|
180 |
|
|
always @(posedge xess_top.i_xess_fpga.risc.cpu.id.clk)
|
181 |
|
|
if (!xess_top.i_xess_fpga.risc.cpu.id.wb_freeze) begin
|
182 |
|
|
#2;
|
183 |
|
|
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)
|
184 |
318 |
lampret |
&& (xess_top.i_xess_fpga.risc.cpu.id.wb_insn != 32'h14004444)
|
185 |
|
|
&& !(xess_top.i_xess_fpga.risc.cpu.except.except_flushpipe && xess_top.i_xess_fpga.risc.cpu.except.ex_dslot))
|
186 |
266 |
lampret |
display_arch_state;
|
187 |
|
|
if (xess_top.i_xess_fpga.risc.cpu.id.ex_insn == 32'h200000cb) // small hack to stop simulation (l.sys 203)
|
188 |
|
|
caught_sys203;
|
189 |
|
|
end
|
190 |
|
|
|
191 |
|
|
endmodule
|
192 |
|
|
|
193 |
|
|
|