1 |
171 |
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 |
|
|
// Revision 1.1 2001/07/20 00:46:03 lampret
|
48 |
|
|
// Development version of RTL. Libraries are missing.
|
49 |
|
|
//
|
50 |
|
|
//
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
// Enable debug_mem task. Only affects simulation.
|
54 |
|
|
`define enable_debug_mem
|
55 |
|
|
|
56 |
|
|
// Enable display_arch_state task. Only affects simulation.
|
57 |
|
|
`define enable_display_arch_state
|
58 |
|
|
|
59 |
|
|
module monitor;
|
60 |
|
|
|
61 |
|
|
task monitortask;
|
62 |
|
|
begin
|
63 |
|
|
/*
|
64 |
|
|
$display("cpu.rfwb_op=%h vip.vipcore.risc.cpu.rf_dataw=%h vip.vipcore.risc.cpu.rf_dataa=%h vip.vipcore.risc.cpu.rf_datab=%h",
|
65 |
|
|
vip.vipcore.risc.cpu.rfwb_op, vip.vipcore.risc.cpu.rf_dataw, vip.vipcore.risc.cpu.rf_dataa, vip.vipcore.risc.cpu.rf_datab);
|
66 |
|
|
|
67 |
|
|
$display("vip.vipcore.risc.cpu.insn=%h vip.vipcore.risc.cpu.rf_addrw=%h vip.vipcore.risc.cpu.rf_addra=%h vip.vipcore.risc.cpu.rf_addrb=%h vip.vipcore.risc.cpu.simm=%h vip.vipcore.risc.cpu.alu_op=%h vip.vipcore.risc.cpu.branch_op=%h vip.vipcore.risc.cpu.sel_a=%h vip.vipcore.risc.cpu.sel_b=%h",
|
68 |
|
|
vip.vipcore.risc.cpu.insn, vip.vipcore.risc.cpu.rf_addrw, vip.vipcore.risc.cpu.rf_addra, vip.vipcore.risc.cpu.rf_addrb, vip.vipcore.risc.cpu.simm, vip.vipcore.risc.cpu.alu_op, vip.vipcore.risc.cpu.branch_op, vip.vipcore.risc.cpu.sel_a, vip.vipcore.risc.cpu.sel_b);
|
69 |
|
|
|
70 |
|
|
$display("alu.alu_op=%h alu.comp_op=%h alu.a=%h alu.b=%h alu.result=%h alu.flag_we=%b alu.flag=%b",
|
71 |
|
|
vip.vipcore.risc.cpu.alu.alu_op, vip.vipcore.risc.cpu.alu.comp_op, vip.vipcore.risc.cpu.alu.a, vip.vipcore.risc.cpu.alu.b, vip.vipcore.risc.cpu.alu.result, vip.vipcore.risc.cpu.alu.flag_we, vip.vipcore.risc.cpu.alu.flag);
|
72 |
|
|
|
73 |
|
|
$display("vip.vipcore.risc.cpu.lsu_op=%h", vip.vipcore.risc.cpu.lsu_op);
|
74 |
|
|
*/
|
75 |
|
|
$display("");
|
76 |
|
|
end
|
77 |
|
|
endtask
|
78 |
|
|
|
79 |
|
|
integer fexe;
|
80 |
|
|
reg [23:0] ref;
|
81 |
|
|
|
82 |
|
|
initial begin
|
83 |
|
|
ref = 0;
|
84 |
|
|
fexe = $fopen("executed.log");
|
85 |
|
|
$timeformat (-9, 2, " ns", 12);
|
86 |
|
|
// $shm_open("waves_nedela2.shm");
|
87 |
|
|
// $shm_probe(tb_vip, "AS");
|
88 |
|
|
// $dumpfile("tb_vip.vcd");
|
89 |
|
|
// `include "tb_vip.trace"
|
90 |
|
|
// $dumpvars(0, tb_vip);
|
91 |
|
|
// $monitor("TIME %t: dc.dclsu_addr %h", $time, vip.vipcore.risc.dc.dclsu_addr);
|
92 |
|
|
end
|
93 |
|
|
|
94 |
|
|
task finish_simulation;
|
95 |
|
|
begin
|
96 |
|
|
$fclose(fexe);
|
97 |
|
|
// display_arch_state;
|
98 |
|
|
display_memory(0, 8191);
|
99 |
|
|
$shm_save;
|
100 |
|
|
$shm_close;
|
101 |
|
|
$dumpflush;
|
102 |
|
|
$finish;
|
103 |
|
|
end
|
104 |
|
|
endtask
|
105 |
|
|
|
106 |
|
|
task caught_sys203;
|
107 |
|
|
begin
|
108 |
|
|
$display("simulation terminated due to l.sys 203");
|
109 |
|
|
finish_simulation;
|
110 |
|
|
end
|
111 |
|
|
endtask
|
112 |
|
|
|
113 |
|
|
/*
|
114 |
|
|
task display_arch_stateOLD;
|
115 |
|
|
reg [5:0] i;
|
116 |
|
|
begin
|
117 |
|
|
`ifdef enable_display_arch_state
|
118 |
|
|
$display("Last:");
|
119 |
|
|
$display("%h: %h: TIME:%t", risc.cpu.except.wb_pc, risc.cpu.id.wb_insn, $time);
|
120 |
|
|
$display("PC:");
|
121 |
|
|
$write("%h: %h: ", risc.cpu.except.ex_pc, risc.cpu.id.ex_insn);
|
122 |
|
|
$write(" SR: %h EPCR: %h ESR: %h", risc.cpu.sprs.sr, risc.cpu.except.epcr, risc.cpu.except.esr);
|
123 |
|
|
for(i = 0; i < 32; i = i + 1) begin
|
124 |
|
|
if (i % 4 == 0)
|
125 |
|
|
$display();
|
126 |
|
|
$write("GPR%d: %h ", i, risc.cpu.rf.rf_a.mem[i]);
|
127 |
|
|
end
|
128 |
|
|
$display("flag: %b", risc.cpu.alu.flag);
|
129 |
|
|
$display;
|
130 |
|
|
`endif
|
131 |
|
|
end
|
132 |
|
|
endtask
|
133 |
|
|
*/
|
134 |
|
|
|
135 |
|
|
task display_arch_state;
|
136 |
|
|
reg [5:0] i;
|
137 |
|
|
begin
|
138 |
|
|
`ifdef enable_display_arch_state
|
139 |
|
|
ref = ref + 1;
|
140 |
|
|
// if (ref == 17890) begin
|
141 |
|
|
// $dumpfile("dump.vcd");
|
142 |
|
|
// $dumpvars(20,tb_or1200);
|
143 |
|
|
// end
|
144 |
|
|
$fwrite(fexe, "\nEXECUTED(): %h: %h", tb_or1200.risc.cpu.except.wb_pc, tb_or1200.risc.cpu.id.wb_insn);
|
145 |
|
|
for(i = 0; i < 32; i = i + 1) begin
|
146 |
|
|
if (i % 4 == 0)
|
147 |
|
|
$fdisplay(fexe);
|
148 |
|
|
$fwrite(fexe, "GPR%d: %h ", i, tb_or1200.risc.cpu.rf.rf_a.mem[i]);
|
149 |
|
|
end
|
150 |
|
|
$fdisplay(fexe);
|
151 |
|
|
`endif
|
152 |
|
|
end
|
153 |
|
|
endtask
|
154 |
|
|
|
155 |
|
|
task display_memory;
|
156 |
|
|
input [31:0] from;
|
157 |
|
|
input [31:0] to;
|
158 |
|
|
integer i;
|
159 |
|
|
begin
|
160 |
|
|
// for(i = from; i < to; i = i + 4)
|
161 |
|
|
// $display("mem[%h] = %h mem[%h] = %h mem[%h] = %h mem[%h] = %h ",
|
162 |
|
|
// i, sram2.ramCore[i], i+4, sram2.ramCore[i+1], i+8, sram2.ramCore[i+2], i+12, sram2.ramCore[i+3]); //zSramX32
|
163 |
|
|
// 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
|
164 |
|
|
end
|
165 |
|
|
endtask
|
166 |
|
|
|
167 |
|
|
task debug_mem;
|
168 |
|
|
input [79:0] device;
|
169 |
|
|
input write;
|
170 |
|
|
input [31:0] addr;
|
171 |
|
|
input [31:0] data;
|
172 |
|
|
input [3:0] bs;
|
173 |
|
|
begin
|
174 |
|
|
`ifdef enable_debug_mem
|
175 |
|
|
if (write)
|
176 |
|
|
$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);
|
177 |
|
|
else
|
178 |
|
|
$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);
|
179 |
|
|
`endif
|
180 |
|
|
end
|
181 |
|
|
endtask
|
182 |
|
|
|
183 |
|
|
always @(posedge tb_or1200.risc.cpu.id.clk)
|
184 |
|
|
if (!tb_or1200.risc.cpu.id.pipeline_freeze) begin
|
185 |
|
|
#3;
|
186 |
|
|
if ((tb_or1200.risc.cpu.id.wb_insn != 32'h1500ffff) && (tb_or1200.risc.cpu.id.wb_insn != 32'h14000000))
|
187 |
|
|
display_arch_state;
|
188 |
|
|
if (tb_or1200.risc.cpu.id.ex_insn == 32'h200000cb) // small hack to stop simulation (l.sys 203)
|
189 |
|
|
caught_sys203;
|
190 |
|
|
end
|
191 |
|
|
|
192 |
|
|
endmodule
|