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 |
618 |
lampret |
// Revision 1.7 2002/01/19 14:10:39 lampret
|
48 |
|
|
// Fixed OR1200_XILINX_RAM32X1D.
|
49 |
|
|
//
|
50 |
597 |
lampret |
// Revision 1.6 2002/01/18 07:57:56 lampret
|
51 |
|
|
// Added support for reading XILINX_RAM32X1D register file.
|
52 |
|
|
//
|
53 |
591 |
lampret |
// Revision 1.5 2002/01/14 06:19:35 lampret
|
54 |
|
|
// Added debug model for testing du. Updated or1200_monitor.
|
55 |
|
|
//
|
56 |
563 |
lampret |
// Revision 1.4 2002/01/03 08:40:15 lampret
|
57 |
|
|
// Added second clock as RISC main clock. Updated or120_monitor.
|
58 |
|
|
//
|
59 |
506 |
lampret |
// Revision 1.3 2001/11/23 08:50:35 lampret
|
60 |
|
|
// Typos.
|
61 |
|
|
//
|
62 |
368 |
lampret |
// Revision 1.2 2001/11/10 04:22:55 lampret
|
63 |
|
|
// Modified monitor tu support exceptions.
|
64 |
|
|
//
|
65 |
318 |
lampret |
// Revision 1.1.1.1 2001/11/04 18:51:07 lampret
|
66 |
|
|
// First import.
|
67 |
|
|
//
|
68 |
266 |
lampret |
// Revision 1.1 2001/08/20 18:17:52 damjan
|
69 |
|
|
// Initial revision
|
70 |
|
|
//
|
71 |
|
|
// Revision 1.1 2001/08/13 03:37:07 lampret
|
72 |
|
|
// Added monitor.v and timescale.v
|
73 |
|
|
//
|
74 |
|
|
// Revision 1.1 2001/07/20 00:46:03 lampret
|
75 |
|
|
// Development version of RTL. Libraries are missing.
|
76 |
|
|
//
|
77 |
|
|
//
|
78 |
|
|
|
79 |
506 |
lampret |
`include "or1200_defines.v"
|
80 |
266 |
lampret |
|
81 |
506 |
lampret |
//
|
82 |
|
|
// Top of OR1200 inside test bench
|
83 |
|
|
//
|
84 |
|
|
`define OR1200_TOP xess_top.i_xess_fpga.risc
|
85 |
368 |
lampret |
|
86 |
506 |
lampret |
//
|
87 |
|
|
// Enable display_arch_state task
|
88 |
|
|
//
|
89 |
|
|
`define OR1200_DISPLAY_ARCH_STATE
|
90 |
266 |
lampret |
|
91 |
|
|
module or1200_monitor;
|
92 |
|
|
|
93 |
|
|
integer fexe;
|
94 |
|
|
reg [23:0] ref;
|
95 |
506 |
lampret |
integer fspr;
|
96 |
563 |
lampret |
integer fnop;
|
97 |
|
|
integer r3;
|
98 |
266 |
lampret |
|
99 |
506 |
lampret |
//
|
100 |
|
|
// Initialization
|
101 |
|
|
//
|
102 |
266 |
lampret |
initial begin
|
103 |
|
|
ref = 0;
|
104 |
|
|
fexe = $fopen("executed.log");
|
105 |
|
|
$timeformat (-9, 2, " ns", 12);
|
106 |
506 |
lampret |
fspr = $fopen("sprs.log");
|
107 |
563 |
lampret |
fnop = $fopen("nop.log");
|
108 |
266 |
lampret |
end
|
109 |
|
|
|
110 |
506 |
lampret |
//
|
111 |
563 |
lampret |
// Get GPR
|
112 |
|
|
//
|
113 |
|
|
task get_gpr;
|
114 |
|
|
input [4:0] gpr_no;
|
115 |
|
|
output [31:0] gpr;
|
116 |
|
|
integer j;
|
117 |
|
|
begin
|
118 |
591 |
lampret |
`ifdef OR1200_XILINX_RAM32X1D
|
119 |
597 |
lampret |
gpr[0] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_0.mem[gpr_no];
|
120 |
|
|
gpr[1] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_1.mem[gpr_no];
|
121 |
|
|
gpr[2] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_2.mem[gpr_no];
|
122 |
|
|
gpr[3] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_3.mem[gpr_no];
|
123 |
|
|
gpr[4] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_4.mem[gpr_no];
|
124 |
|
|
gpr[5] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_5.mem[gpr_no];
|
125 |
|
|
gpr[6] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_6.mem[gpr_no];
|
126 |
|
|
gpr[7] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_0.ram32x1d_7.mem[gpr_no];
|
127 |
|
|
gpr[8] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_0.mem[gpr_no];
|
128 |
|
|
gpr[9] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_1.mem[gpr_no];
|
129 |
|
|
gpr[10] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_2.mem[gpr_no];
|
130 |
|
|
gpr[11] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_3.mem[gpr_no];
|
131 |
|
|
gpr[12] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_4.mem[gpr_no];
|
132 |
|
|
gpr[13] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_5.mem[gpr_no];
|
133 |
|
|
gpr[14] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_6.mem[gpr_no];
|
134 |
|
|
gpr[15] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_1.ram32x1d_7.mem[gpr_no];
|
135 |
|
|
gpr[16] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_0.mem[gpr_no];
|
136 |
|
|
gpr[17] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_1.mem[gpr_no];
|
137 |
|
|
gpr[18] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_2.mem[gpr_no];
|
138 |
|
|
gpr[19] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_3.mem[gpr_no];
|
139 |
|
|
gpr[20] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_4.mem[gpr_no];
|
140 |
|
|
gpr[21] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_5.mem[gpr_no];
|
141 |
|
|
gpr[22] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_6.mem[gpr_no];
|
142 |
|
|
gpr[23] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_2.ram32x1d_7.mem[gpr_no];
|
143 |
|
|
gpr[24] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_0.mem[gpr_no];
|
144 |
|
|
gpr[25] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_1.mem[gpr_no];
|
145 |
|
|
gpr[26] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_2.mem[gpr_no];
|
146 |
|
|
gpr[27] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_3.mem[gpr_no];
|
147 |
|
|
gpr[28] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_4.mem[gpr_no];
|
148 |
|
|
gpr[29] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_5.mem[gpr_no];
|
149 |
|
|
gpr[30] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_6.mem[gpr_no];
|
150 |
|
|
gpr[31] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.xcv_ram32x8d_3.ram32x1d_7.mem[gpr_no];
|
151 |
591 |
lampret |
`else
|
152 |
563 |
lampret |
`ifdef OR1200_XILINX_RAMB4
|
153 |
|
|
for(j = 0; j < 16; j = j + 1) begin
|
154 |
|
|
gpr[j] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.ramb4_s16_0.mem[gpr_no*16+j];
|
155 |
|
|
end
|
156 |
|
|
for(j = 0; j < 16; j = j + 1) begin
|
157 |
|
|
gpr[j+16] = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.ramb4_s16_1.mem[gpr_no*16+j];
|
158 |
|
|
end
|
159 |
|
|
`else
|
160 |
|
|
`ifdef OR1200_ARTISAN_SDP
|
161 |
|
|
`else
|
162 |
597 |
lampret |
gpr = `OR1200_TOP.or1200_cpu.or1200_rf.rf_a.mem[gpr_no];
|
163 |
563 |
lampret |
`endif
|
164 |
|
|
`endif
|
165 |
|
|
`endif
|
166 |
|
|
end
|
167 |
|
|
endtask
|
168 |
|
|
|
169 |
|
|
//
|
170 |
506 |
lampret |
// Write state of the OR1200 registers into a file
|
171 |
|
|
//
|
172 |
|
|
// Limitation: only a small subset of register file RAMs
|
173 |
|
|
// are supported
|
174 |
|
|
//
|
175 |
266 |
lampret |
task display_arch_state;
|
176 |
|
|
reg [5:0] i;
|
177 |
|
|
reg [31:0] r;
|
178 |
|
|
integer j;
|
179 |
|
|
begin
|
180 |
506 |
lampret |
`ifdef OR1200_DISPLAY_ARCH_STATE
|
181 |
266 |
lampret |
ref = ref + 1;
|
182 |
506 |
lampret |
$fwrite(fexe, "\nEXECUTED(): %h: %h", `OR1200_TOP.or1200_cpu.or1200_except.wb_pc, `OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn);
|
183 |
266 |
lampret |
for(i = 0; i < 32; i = i + 1) begin
|
184 |
|
|
if (i % 4 == 0)
|
185 |
|
|
$fdisplay(fexe);
|
186 |
563 |
lampret |
get_gpr(i, r);
|
187 |
266 |
lampret |
$fwrite(fexe, "GPR%d: %h ", i, r);
|
188 |
|
|
end
|
189 |
|
|
$fdisplay(fexe);
|
190 |
506 |
lampret |
r = `OR1200_TOP.or1200_cpu.or1200_sprs.sr;
|
191 |
266 |
lampret |
$fwrite(fexe, "SR : %h ", r);
|
192 |
506 |
lampret |
r = `OR1200_TOP.or1200_cpu.or1200_sprs.epcr;
|
193 |
266 |
lampret |
$fwrite(fexe, "EPCR0: %h ", r);
|
194 |
506 |
lampret |
r = `OR1200_TOP.or1200_cpu.or1200_sprs.eear;
|
195 |
266 |
lampret |
$fwrite(fexe, "EEAR0: %h ", r);
|
196 |
506 |
lampret |
r = `OR1200_TOP.or1200_cpu.or1200_sprs.esr;
|
197 |
266 |
lampret |
$fdisplay(fexe, "ESR0 : %h", r);
|
198 |
|
|
`endif
|
199 |
|
|
end
|
200 |
|
|
endtask
|
201 |
|
|
|
202 |
506 |
lampret |
//
|
203 |
|
|
// Hooks for:
|
204 |
|
|
// - displaying registers
|
205 |
|
|
// - end of simulation
|
206 |
|
|
// - access to SPRs
|
207 |
|
|
//
|
208 |
|
|
always @(posedge `OR1200_TOP.or1200_cpu.or1200_ctrl.clk)
|
209 |
|
|
if (!`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_freeze) begin
|
210 |
266 |
lampret |
#2;
|
211 |
618 |
lampret |
if (((`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn[31:26] != `OR1200_OR32_NOP) || !`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn[16])
|
212 |
506 |
lampret |
&& !(`OR1200_TOP.or1200_cpu.or1200_except.except_flushpipe && `OR1200_TOP.or1200_cpu.or1200_except.ex_dslot))
|
213 |
266 |
lampret |
display_arch_state;
|
214 |
563 |
lampret |
if (`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn == 32'h1500_0001) begin // small hack to stop simulation (l.nop 1)
|
215 |
|
|
get_gpr(3, r3);
|
216 |
|
|
$fdisplay(fnop, "%t: l.nop exit (%h)", $time, r3);
|
217 |
368 |
lampret |
$finish;
|
218 |
563 |
lampret |
end
|
219 |
|
|
if (`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn == 32'h1500_0002) begin // simulation reports (l.nop 2)
|
220 |
|
|
get_gpr(3, r3);
|
221 |
|
|
$fdisplay(fnop, "%t: l.nop report (%h)", $time, r3);
|
222 |
|
|
end
|
223 |
|
|
if (`OR1200_TOP.or1200_cpu.or1200_ctrl.wb_insn == 32'h1500_0003) begin // simulation printfs (l.nop 3)
|
224 |
|
|
get_gpr(3, r3);
|
225 |
|
|
$fdisplay(fnop, "%t: l.nop printf (%h)", $time, r3);
|
226 |
|
|
end
|
227 |
506 |
lampret |
if (`OR1200_TOP.or1200_cpu.or1200_sprs.sprs_op == `OR1200_ALUOP_MTSR) // l.mtspr
|
228 |
|
|
$fdisplay(fspr, "%t: Write to SPR : [%h] <- %h", $time,
|
229 |
|
|
`OR1200_TOP.or1200_cpu.or1200_sprs.spr_addr, `OR1200_TOP.or1200_cpu.or1200_sprs.spr_dataout);
|
230 |
|
|
if (`OR1200_TOP.or1200_cpu.or1200_sprs.sprs_op == `OR1200_ALUOP_MFSR) // l.mfspr
|
231 |
|
|
$fdisplay(fspr, "%t: Read from SPR: [%h] -> %h", $time,
|
232 |
|
|
`OR1200_TOP.or1200_cpu.or1200_sprs.spr_addr, `OR1200_TOP.or1200_cpu.or1200_sprs.to_wbmux);
|
233 |
266 |
lampret |
end
|
234 |
|
|
|
235 |
|
|
endmodule
|