| 1 |
779 |
lampret |
//////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
//// ////
|
| 3 |
|
|
//// dbg_if_model.v ////
|
| 4 |
|
|
//// ////
|
| 5 |
|
|
//// ////
|
| 6 |
|
|
//// This file is part of the OpenRISC test bench. ////
|
| 7 |
|
|
//// http://www.opencores.org/ ////
|
| 8 |
|
|
//// ////
|
| 9 |
|
|
//// ////
|
| 10 |
|
|
//// Author(s): ////
|
| 11 |
|
|
//// Damjan Lampret ////
|
| 12 |
|
|
//// lampret@opencores.org ////
|
| 13 |
|
|
//// ////
|
| 14 |
|
|
//// ////
|
| 15 |
|
|
//// All additional information is avaliable in the README.txt ////
|
| 16 |
|
|
//// file. ////
|
| 17 |
|
|
//// ////
|
| 18 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 19 |
|
|
//// ////
|
| 20 |
|
|
//// Copyright (C) 2000,2001 Authors ////
|
| 21 |
|
|
//// ////
|
| 22 |
|
|
//// This source file may be used and distributed without ////
|
| 23 |
|
|
//// restriction provided that this copyright statement is not ////
|
| 24 |
|
|
//// removed from the file and that any derivative work contains ////
|
| 25 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
| 26 |
|
|
//// ////
|
| 27 |
|
|
//// This source file is free software; you can redistribute it ////
|
| 28 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
| 29 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
| 30 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
| 31 |
|
|
//// later version. ////
|
| 32 |
|
|
//// ////
|
| 33 |
|
|
//// This source is distributed in the hope that it will be ////
|
| 34 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
| 35 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
| 36 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
| 37 |
|
|
//// details. ////
|
| 38 |
|
|
//// ////
|
| 39 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
| 40 |
|
|
//// Public License along with this source; if not, download it ////
|
| 41 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
| 42 |
|
|
//// ////
|
| 43 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 44 |
|
|
//
|
| 45 |
|
|
// CVS Revision History
|
| 46 |
|
|
//
|
| 47 |
|
|
// $Log: not supported by cvs2svn $
|
| 48 |
|
|
// Revision 1.2 2002/01/18 07:57:21 lampret
|
| 49 |
|
|
// Added test case for testing NPC read bug when doing single-step.
|
| 50 |
|
|
//
|
| 51 |
|
|
// Revision 1.1 2002/01/14 06:19:35 lampret
|
| 52 |
|
|
// Added debug model for testing du. Updated or1200_monitor.
|
| 53 |
|
|
//
|
| 54 |
|
|
//
|
| 55 |
|
|
//
|
| 56 |
|
|
|
| 57 |
|
|
`include "dbg_defines.v"
|
| 58 |
|
|
|
| 59 |
|
|
// Top module
|
| 60 |
|
|
module dbg_if_model(
|
| 61 |
|
|
// JTAG pins
|
| 62 |
|
|
tms_pad_i, tck_pad_i, trst_pad_i, tdi_pad_i, tdo_pad_o,
|
| 63 |
|
|
|
| 64 |
|
|
// Boundary Scan signals
|
| 65 |
|
|
capture_dr_o, shift_dr_o, update_dr_o, extest_selected_o, bs_chain_i,
|
| 66 |
|
|
|
| 67 |
|
|
// RISC signals
|
| 68 |
|
|
risc_clk_i, risc_addr_o, risc_data_i, risc_data_o, wp_i,
|
| 69 |
|
|
bp_i, opselect_o, lsstatus_i, istatus_i, risc_stall_o, reset_o,
|
| 70 |
|
|
|
| 71 |
|
|
// WISHBONE common signals
|
| 72 |
|
|
wb_rst_i, wb_clk_i,
|
| 73 |
|
|
|
| 74 |
|
|
// WISHBONE master interface
|
| 75 |
|
|
wb_adr_o, wb_dat_o, wb_dat_i, wb_cyc_o, wb_stb_o, wb_sel_o,
|
| 76 |
|
|
wb_we_o, wb_ack_i, wb_cab_o, wb_err_i
|
| 77 |
|
|
|
| 78 |
|
|
|
| 79 |
|
|
);
|
| 80 |
|
|
|
| 81 |
|
|
parameter Tp = 1;
|
| 82 |
|
|
|
| 83 |
|
|
// JTAG pins
|
| 84 |
|
|
input tms_pad_i; // JTAG test mode select pad
|
| 85 |
|
|
input tck_pad_i; // JTAG test clock pad
|
| 86 |
|
|
input trst_pad_i; // JTAG test reset pad
|
| 87 |
|
|
input tdi_pad_i; // JTAG test data input pad
|
| 88 |
|
|
output tdo_pad_o; // JTAG test data output pad
|
| 89 |
|
|
|
| 90 |
|
|
|
| 91 |
|
|
// Boundary Scan signals
|
| 92 |
|
|
output capture_dr_o;
|
| 93 |
|
|
output shift_dr_o;
|
| 94 |
|
|
output update_dr_o;
|
| 95 |
|
|
output extest_selected_o;
|
| 96 |
|
|
input bs_chain_i;
|
| 97 |
|
|
|
| 98 |
|
|
|
| 99 |
|
|
// RISC signals
|
| 100 |
|
|
input risc_clk_i; // Master clock (RISC clock)
|
| 101 |
|
|
input [31:0] risc_data_i; // RISC data inputs (data that is written to the RISC registers)
|
| 102 |
|
|
input [10:0] wp_i; // Watchpoint inputs
|
| 103 |
|
|
input bp_i; // Breakpoint input
|
| 104 |
|
|
input [3:0] lsstatus_i; // Load/store status inputs
|
| 105 |
|
|
input [1:0] istatus_i; // Instruction status inputs
|
| 106 |
|
|
output [31:0] risc_addr_o; // RISC address output (for adressing registers within RISC)
|
| 107 |
|
|
output [31:0] risc_data_o; // RISC data output (data read from risc registers)
|
| 108 |
|
|
output [`OPSELECTWIDTH-1:0] opselect_o; // Operation selection (selecting what kind of data is set to the risc_data_i)
|
| 109 |
|
|
output risc_stall_o; // Stalls the RISC
|
| 110 |
|
|
output reset_o; // Resets the RISC
|
| 111 |
|
|
|
| 112 |
|
|
|
| 113 |
|
|
// WISHBONE common signals
|
| 114 |
|
|
input wb_rst_i; // WISHBONE reset
|
| 115 |
|
|
input wb_clk_i; // WISHBONE clock
|
| 116 |
|
|
|
| 117 |
|
|
// WISHBONE master interface
|
| 118 |
|
|
output [31:0] wb_adr_o;
|
| 119 |
|
|
output [31:0] wb_dat_o;
|
| 120 |
|
|
input [31:0] wb_dat_i;
|
| 121 |
|
|
output wb_cyc_o;
|
| 122 |
|
|
output wb_stb_o;
|
| 123 |
|
|
output [3:0] wb_sel_o;
|
| 124 |
|
|
output wb_we_o;
|
| 125 |
|
|
input wb_ack_i;
|
| 126 |
|
|
output wb_cab_o;
|
| 127 |
|
|
input wb_err_i;
|
| 128 |
|
|
|
| 129 |
|
|
reg [31:0] risc_addr_o;
|
| 130 |
|
|
reg [31:0] risc_data_o;
|
| 131 |
|
|
reg [`OPSELECTWIDTH-1:0] opselect_o;
|
| 132 |
|
|
reg risc_stall_a;
|
| 133 |
|
|
reg risc_stall_r;
|
| 134 |
|
|
integer i, npc, ppc, r1, insn, result;
|
| 135 |
|
|
|
| 136 |
|
|
assign tdo_pad_o = 1'b0;
|
| 137 |
|
|
assign capture_dr_o = 1'b0;
|
| 138 |
|
|
assign shift_dr_o = 1'b0;
|
| 139 |
|
|
assign update_dr_o = 1'b0;
|
| 140 |
|
|
assign extest_selected_o = 1'b0;
|
| 141 |
|
|
assign reset_o = 1'b0;
|
| 142 |
|
|
assign risc_stall_o = risc_stall_r | risc_stall_a;
|
| 143 |
|
|
assign wb_cab_o = 1'b0;
|
| 144 |
|
|
|
| 145 |
|
|
always @(posedge wb_rst_i or posedge bp_i)
|
| 146 |
|
|
if (wb_rst_i)
|
| 147 |
|
|
risc_stall_r <= #1 1'b0;
|
| 148 |
|
|
else if (bp_i)
|
| 149 |
|
|
risc_stall_r <= #1 1'b1;
|
| 150 |
|
|
initial begin
|
| 151 |
|
|
risc_addr_o = 0;
|
| 152 |
|
|
risc_data_o = 0;
|
| 153 |
|
|
opselect_o = 0;
|
| 154 |
|
|
risc_stall_a = 1'b0;
|
| 155 |
|
|
#100;
|
| 156 |
|
|
while (!bp_i) @(posedge risc_clk_i);
|
| 157 |
|
|
stall;
|
| 158 |
|
|
wb_master.wr(32'h8000_0004, 32'h9c200000, 4'b1111); /* l.addi r1,r0,0x0 */
|
| 159 |
|
|
wb_master.wr(32'h8000_0008, 32'h18408008, 4'b1111); /* l.movhi r2,0x8008 */
|
| 160 |
|
|
wb_master.wr(32'h8000_000c, 32'h9c210001, 4'b1111); /* l.addi r1,r1,1 */
|
| 161 |
|
|
wb_master.wr(32'h8000_0010, 32'h9c210001, 4'b1111); /* l.addi r1,r1,1 */
|
| 162 |
|
|
wb_master.wr(32'h8000_0014, 32'hd4020800, 4'b1111); /* l.sw 0(r2),r1 */
|
| 163 |
|
|
wb_master.wr(32'h8000_0018, 32'h9c210001, 4'b1111); /* l.addi r1,r1,1 */
|
| 164 |
|
|
wb_master.wr(32'h8000_001c, 32'h84620000, 4'b1111); /* l.lwz r3,0(r2) */
|
| 165 |
|
|
wb_master.wr(32'h8000_0020, 32'h03fffffb, 4'b1111); /* l.j loop2 */
|
| 166 |
|
|
wb_master.wr(32'h8000_0024, 32'he0211800, 4'b1111); /* l.add r1,r1,r3 */
|
| 167 |
|
|
wb_master.wr(32'h8000_0028, 32'he0211800, 4'b1111); /* l.add r1,r1,r3 */
|
| 168 |
|
|
|
| 169 |
|
|
// Enable exceptions in SR
|
| 170 |
|
|
wr_reg(17, 3);
|
| 171 |
|
|
|
| 172 |
|
|
// Set trap bit in DSR
|
| 173 |
|
|
wr_reg((6 << 11) + 20, 32'h2000);
|
| 174 |
|
|
|
| 175 |
|
|
// Set NPC
|
| 176 |
|
|
wr_npc(32'h8000_0004);
|
| 177 |
|
|
|
| 178 |
|
|
// Set step-bit (DMR1[ST])
|
| 179 |
|
|
wr_reg((6 << 11) + 16, 1 << 22);
|
| 180 |
|
|
|
| 181 |
|
|
// Single-step
|
| 182 |
|
|
for (i = 1; i < 10; i = i + 1)
|
| 183 |
|
|
unstall;
|
| 184 |
|
|
|
| 185 |
|
|
// Read NPC
|
| 186 |
|
|
rd_reg((0 << 11) + 16, npc);
|
| 187 |
|
|
|
| 188 |
|
|
// Read PPC
|
| 189 |
|
|
rd_reg((0 << 11) + 18, ppc);
|
| 190 |
|
|
|
| 191 |
|
|
// Read R1
|
| 192 |
|
|
rd_reg(32'h401, r1);
|
| 193 |
|
|
|
| 194 |
|
|
$display("Read npc = %h ppc = %h r1 = %h", npc, ppc, r1);
|
| 195 |
|
|
$display("Expected npc = %h ppc = %h r1 = %h\n", 32'h8000000c, 32'h80000024, 5);
|
| 196 |
|
|
result = npc + ppc + r1;
|
| 197 |
|
|
|
| 198 |
|
|
|
| 199 |
|
|
/* Reset step bit */
|
| 200 |
|
|
wr_reg ((6 << 11) + 16, 0);
|
| 201 |
|
|
|
| 202 |
|
|
/* Set trap insn in delay slot */
|
| 203 |
|
|
wb_master.rd (32'h8000_0024, insn);
|
| 204 |
|
|
wb_master.wr (32'h8000_0024, 32'h21000001, 4'b1111);
|
| 205 |
|
|
|
| 206 |
|
|
/* Unstall */
|
| 207 |
|
|
unstall;
|
| 208 |
|
|
|
| 209 |
|
|
/* Read NPC */
|
| 210 |
|
|
rd_reg((0 << 11) + 16, npc);
|
| 211 |
|
|
|
| 212 |
|
|
/* Read PPC */
|
| 213 |
|
|
rd_reg((0 << 11) + 18, ppc);
|
| 214 |
|
|
|
| 215 |
|
|
/* Read R1 */
|
| 216 |
|
|
rd_reg(32'h401, r1);
|
| 217 |
|
|
|
| 218 |
|
|
/* Set back original insn */
|
| 219 |
|
|
wb_master.wr (32'h8000_0024, insn, 4'b1111);
|
| 220 |
|
|
|
| 221 |
|
|
$display("Read npc = %h ppc = %h r1 = %h", npc, ppc, r1);
|
| 222 |
|
|
$display("Expected npc = %h ppc = %h r1 = %h\n", 32'h8000000c, 32'h80000024, 8);
|
| 223 |
|
|
result = npc + ppc + r1 + result;
|
| 224 |
|
|
|
| 225 |
|
|
|
| 226 |
|
|
/* Set trap insn in place of branch insn */
|
| 227 |
|
|
wb_master.rd (32'h8000_0020, insn);
|
| 228 |
|
|
wb_master.wr (32'h8000_0020, 32'h21000001, 4'b1111);
|
| 229 |
|
|
|
| 230 |
|
|
/* Set PC */
|
| 231 |
|
|
wr_npc(32'h8000_000c);
|
| 232 |
|
|
|
| 233 |
|
|
/* Unstall */
|
| 234 |
|
|
unstall;
|
| 235 |
|
|
|
| 236 |
|
|
/* Read NPC */
|
| 237 |
|
|
rd_reg((0 << 11) + 16, npc);
|
| 238 |
|
|
|
| 239 |
|
|
/* Read PPC */
|
| 240 |
|
|
rd_reg((0 << 11) + 18, ppc);
|
| 241 |
|
|
|
| 242 |
|
|
/* Read R1 */
|
| 243 |
|
|
rd_reg(32'h401, r1);
|
| 244 |
|
|
|
| 245 |
|
|
/* Set back original insn */
|
| 246 |
|
|
wb_master.wr (32'h8000_0020, insn, 4'b1111);
|
| 247 |
|
|
|
| 248 |
|
|
$display("Read npc = %h ppc = %h r1 = %h", npc, ppc, r1);
|
| 249 |
|
|
$display("Expected npc = %h ppc = %h r1 = %h\n", 32'h80000024, 32'h80000020, 11);
|
| 250 |
|
|
result = npc + ppc + r1 + result;
|
| 251 |
|
|
|
| 252 |
|
|
/* Set trap insn before branch insn */
|
| 253 |
|
|
wb_master.rd (32'h8000_001c, insn);
|
| 254 |
|
|
wb_master.wr (32'h8000_001c, 32'h21000001, 4'b1111);
|
| 255 |
|
|
|
| 256 |
|
|
/* Set PC */
|
| 257 |
|
|
wr_npc(32'h8000_0020);
|
| 258 |
|
|
|
| 259 |
|
|
/* Unstall */
|
| 260 |
|
|
unstall;
|
| 261 |
|
|
|
| 262 |
|
|
/* Read NPC */
|
| 263 |
|
|
rd_reg((0 << 11) + 16, npc);
|
| 264 |
|
|
|
| 265 |
|
|
/* Read PPC */
|
| 266 |
|
|
rd_reg((0 << 11) + 18, ppc);
|
| 267 |
|
|
|
| 268 |
|
|
/* Read R1 */
|
| 269 |
|
|
rd_reg(32'h401, r1);
|
| 270 |
|
|
|
| 271 |
|
|
/* Set back original insn */
|
| 272 |
|
|
wb_master.wr (32'h8000_001c, insn, 4'b1111);
|
| 273 |
|
|
|
| 274 |
|
|
$display("Read npc = %h ppc = %h r1 = %h", npc, ppc, r1);
|
| 275 |
|
|
$display("Expected npc = %h ppc = %h r1 = %h\n", 32'h80000020, 32'h8000001c, 24);
|
| 276 |
|
|
result = npc + ppc + r1 + result;
|
| 277 |
|
|
|
| 278 |
|
|
|
| 279 |
|
|
/* Set trap insn behind lsu insn */
|
| 280 |
|
|
wb_master.rd (32'h8000_0018, insn);
|
| 281 |
|
|
wb_master.wr (32'h8000_0018, 32'h21000001, 4'b1111);
|
| 282 |
|
|
|
| 283 |
|
|
/* Set PC */
|
| 284 |
|
|
wr_npc(32'h8000_001c);
|
| 285 |
|
|
|
| 286 |
|
|
/* Unstall */
|
| 287 |
|
|
unstall;
|
| 288 |
|
|
|
| 289 |
|
|
/* Read NPC */
|
| 290 |
|
|
rd_reg((0 << 11) + 16, npc);
|
| 291 |
|
|
|
| 292 |
|
|
/* Read PPC */
|
| 293 |
|
|
rd_reg((0 << 11) + 18, ppc);
|
| 294 |
|
|
|
| 295 |
|
|
/* Read R1 */
|
| 296 |
|
|
rd_reg(32'h401, r1);
|
| 297 |
|
|
|
| 298 |
|
|
/* Set back original insn */
|
| 299 |
|
|
wb_master.wr (32'h8000_0018, insn, 4'b1111);
|
| 300 |
|
|
|
| 301 |
|
|
$display("Read npc = %h ppc = %h r1 = %h", npc, ppc, r1);
|
| 302 |
|
|
$display("Expected npc = %h ppc = %h r1 = %h\n", 32'h8000001c, 32'h80000018, 49);
|
| 303 |
|
|
result = npc + ppc + r1 + result;
|
| 304 |
|
|
|
| 305 |
|
|
/* Set trap insn very near previous one */
|
| 306 |
|
|
wb_master.rd (32'h8000_001c, insn);
|
| 307 |
|
|
wb_master.wr (32'h8000_001c, 32'h21000001, 4'b1111);
|
| 308 |
|
|
|
| 309 |
|
|
/* Set PC */
|
| 310 |
|
|
wr_npc(32'h8000_0018);
|
| 311 |
|
|
|
| 312 |
|
|
/* Unstall */
|
| 313 |
|
|
unstall;
|
| 314 |
|
|
|
| 315 |
|
|
/* Read NPC */
|
| 316 |
|
|
rd_reg((0 << 11) + 16, npc);
|
| 317 |
|
|
|
| 318 |
|
|
/* Read PPC */
|
| 319 |
|
|
rd_reg((0 << 11) + 18, ppc);
|
| 320 |
|
|
|
| 321 |
|
|
/* Read R1 */
|
| 322 |
|
|
rd_reg(32'h401, r1);
|
| 323 |
|
|
|
| 324 |
|
|
/* Set back original insn */
|
| 325 |
|
|
wb_master.wr (32'h8000_001c, insn, 4'b1111);
|
| 326 |
|
|
|
| 327 |
|
|
$display("Read npc = %h ppc = %h r1 = %h", npc, ppc, r1);
|
| 328 |
|
|
$display("Expected npc = %h ppc = %h r1 = %h\n", 32'h80000020, 32'h8000001c, 50);
|
| 329 |
|
|
result = npc + ppc + r1 + result;
|
| 330 |
|
|
|
| 331 |
|
|
/* Set trap insn to the start */
|
| 332 |
|
|
wb_master.rd (32'h8000_000c, insn);
|
| 333 |
|
|
wb_master.wr (32'h8000_000c, 32'h21000001, 4'b1111);
|
| 334 |
|
|
|
| 335 |
|
|
/* Set PC */
|
| 336 |
|
|
wr_npc(32'h8000_001c);
|
| 337 |
|
|
|
| 338 |
|
|
/* Unstall */
|
| 339 |
|
|
unstall;
|
| 340 |
|
|
|
| 341 |
|
|
/* Read NPC */
|
| 342 |
|
|
rd_reg((0 << 11) + 16, npc);
|
| 343 |
|
|
|
| 344 |
|
|
/* Read PPC */
|
| 345 |
|
|
rd_reg((0 << 11) + 18, ppc);
|
| 346 |
|
|
|
| 347 |
|
|
/* Read R1 */
|
| 348 |
|
|
rd_reg(32'h401, r1);
|
| 349 |
|
|
|
| 350 |
|
|
/* Set back original insn */
|
| 351 |
|
|
wb_master.wr (32'h8000_000c, insn, 4'b1111);
|
| 352 |
|
|
|
| 353 |
|
|
$display("Read npc = %h ppc = %h r1 = %h", npc, ppc, r1);
|
| 354 |
|
|
$display("Expected npc = %h ppc = %h r1 = %h\n", 32'h80000010, 32'h8000000c, 99);
|
| 355 |
|
|
result = npc + ppc + r1 + result;
|
| 356 |
|
|
|
| 357 |
|
|
// Set step-bit (DMR1[ST])
|
| 358 |
|
|
wr_reg((6 << 11) + 16, 1 << 22);
|
| 359 |
|
|
|
| 360 |
|
|
// Single-step
|
| 361 |
|
|
for (i = 0; i < 5; i = i + 1)
|
| 362 |
|
|
unstall;
|
| 363 |
|
|
|
| 364 |
|
|
/* Read NPC */
|
| 365 |
|
|
rd_reg((0 << 11) + 16, npc);
|
| 366 |
|
|
|
| 367 |
|
|
/* Read PPC */
|
| 368 |
|
|
rd_reg((0 << 11) + 18, ppc);
|
| 369 |
|
|
|
| 370 |
|
|
/* Read R1 */
|
| 371 |
|
|
rd_reg(32'h401, r1);
|
| 372 |
|
|
|
| 373 |
|
|
$display("Read npc = %h ppc = %h r1 = %h", npc, ppc, r1);
|
| 374 |
|
|
$display("Expected npc = %h ppc = %h r1 = %h\n", 32'h80000024, 32'h80000020, 101);
|
| 375 |
|
|
result = npc + ppc + r1 + result;
|
| 376 |
|
|
|
| 377 |
|
|
/* Set PC */
|
| 378 |
|
|
wr_npc(32'h8000_0020);
|
| 379 |
|
|
|
| 380 |
|
|
// Single-step
|
| 381 |
|
|
for (i = 0; i < 2; i = i + 1)
|
| 382 |
|
|
unstall;
|
| 383 |
|
|
|
| 384 |
|
|
/* Read NPC */
|
| 385 |
|
|
rd_reg((0 << 11) + 16, npc);
|
| 386 |
|
|
|
| 387 |
|
|
/* Read PPC */
|
| 388 |
|
|
rd_reg((0 << 11) + 18, ppc);
|
| 389 |
|
|
|
| 390 |
|
|
/* Read R1 */
|
| 391 |
|
|
rd_reg(32'h401, r1);
|
| 392 |
|
|
|
| 393 |
|
|
$display("Read npc = %h ppc = %h r1 = %h", npc, ppc, r1);
|
| 394 |
|
|
$display("Expected npc = %h ppc = %h r1 = %h\n", 32'h8000000c, 32'h80000024, 201);
|
| 395 |
|
|
result = npc + ppc + r1 + result;
|
| 396 |
|
|
|
| 397 |
|
|
$display("result = %h\n", result + 32'h5eaddaa9);
|
| 398 |
|
|
|
| 399 |
|
|
#100 $finish;
|
| 400 |
|
|
end
|
| 401 |
|
|
|
| 402 |
|
|
task stall;
|
| 403 |
|
|
begin
|
| 404 |
|
|
risc_stall_r = 1'b1;
|
| 405 |
|
|
@(posedge risc_clk_i);
|
| 406 |
|
|
@(posedge risc_clk_i);
|
| 407 |
|
|
end
|
| 408 |
|
|
endtask
|
| 409 |
|
|
|
| 410 |
|
|
task unstall;
|
| 411 |
|
|
begin
|
| 412 |
|
|
risc_stall_r = 1'b0;
|
| 413 |
|
|
@(posedge risc_clk_i);
|
| 414 |
|
|
while (!bp_i) @(posedge risc_clk_i);
|
| 415 |
|
|
end
|
| 416 |
|
|
endtask
|
| 417 |
|
|
|
| 418 |
|
|
task wr_npc;
|
| 419 |
|
|
input [31:0] npc;
|
| 420 |
|
|
begin
|
| 421 |
|
|
npc = npc - 0;
|
| 422 |
|
|
wr_reg((0 << 11) + 16, npc);
|
| 423 |
|
|
end
|
| 424 |
|
|
endtask
|
| 425 |
|
|
|
| 426 |
|
|
task wr_reg;
|
| 427 |
|
|
input [31:0] addr;
|
| 428 |
|
|
input [31:0] data;
|
| 429 |
|
|
begin
|
| 430 |
|
|
risc_stall_a = 1'b1;
|
| 431 |
|
|
@(posedge risc_clk_i);
|
| 432 |
|
|
risc_addr_o = addr;
|
| 433 |
|
|
risc_data_o = data;
|
| 434 |
|
|
opselect_o = 5;
|
| 435 |
|
|
@(posedge risc_clk_i);
|
| 436 |
|
|
risc_addr_o = 0;
|
| 437 |
|
|
risc_data_o = 0;
|
| 438 |
|
|
opselect_o = 0;
|
| 439 |
|
|
@(posedge risc_clk_i);
|
| 440 |
|
|
@(posedge risc_clk_i);
|
| 441 |
|
|
@(posedge risc_clk_i);
|
| 442 |
|
|
risc_stall_a = 1'b0;
|
| 443 |
|
|
end
|
| 444 |
|
|
endtask
|
| 445 |
|
|
|
| 446 |
|
|
task rd_reg;
|
| 447 |
|
|
input [31:0] addr;
|
| 448 |
|
|
output [31:0] data;
|
| 449 |
|
|
begin
|
| 450 |
|
|
risc_stall_a = 1'b1;
|
| 451 |
|
|
@(posedge risc_clk_i);
|
| 452 |
|
|
risc_addr_o = addr;
|
| 453 |
|
|
opselect_o = 4;
|
| 454 |
|
|
@(posedge risc_clk_i);
|
| 455 |
|
|
@(posedge risc_clk_i);
|
| 456 |
|
|
data = risc_data_i;
|
| 457 |
|
|
@(posedge risc_clk_i);
|
| 458 |
|
|
risc_addr_o = 0;
|
| 459 |
|
|
risc_data_o = 0;
|
| 460 |
|
|
opselect_o = 0;
|
| 461 |
|
|
@(posedge risc_clk_i);
|
| 462 |
|
|
@(posedge risc_clk_i);
|
| 463 |
|
|
@(posedge risc_clk_i);
|
| 464 |
|
|
risc_stall_a = 1'b0;
|
| 465 |
|
|
end
|
| 466 |
|
|
endtask
|
| 467 |
|
|
|
| 468 |
|
|
//
|
| 469 |
|
|
// Instantiation of Master WISHBONE BFM
|
| 470 |
|
|
//
|
| 471 |
|
|
wb_master wb_master(
|
| 472 |
|
|
// WISHBONE Interface
|
| 473 |
|
|
.CLK_I(wb_clk_i),
|
| 474 |
|
|
.RST_I(wb_rst_i),
|
| 475 |
|
|
.CYC_O(wb_cyc_o),
|
| 476 |
|
|
.ADR_O(wb_adr_o),
|
| 477 |
|
|
.DAT_O(wb_dat_o),
|
| 478 |
|
|
.SEL_O(wb_sel_o),
|
| 479 |
|
|
.WE_O(wb_we_o),
|
| 480 |
|
|
.STB_O(wb_stb_o),
|
| 481 |
|
|
.DAT_I(wb_dat_i),
|
| 482 |
|
|
.ACK_I(wb_ack_i),
|
| 483 |
|
|
.ERR_I(wb_err_i),
|
| 484 |
|
|
.RTY_I(1'b0),
|
| 485 |
|
|
.TAG_I(4'b0),
|
| 486 |
|
|
.TAG_O()
|
| 487 |
|
|
);
|
| 488 |
|
|
|
| 489 |
|
|
endmodule
|