/* * b16 core: 16 bits, * inspired by c18 core from Chuck Moore * (c) 2002-2011 by Bernd Paysan * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License or any later. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This is not the source code of the program, the source code is a LyX literate programming style article. */ `include "b16-defines.v" `ifdef DEBUGGING module debugger(clk, nreset, run, addr, data, r, w, cpu_addr, cpu_r, drun, dr, dw, bp); parameter l=16, dbgaddr = 12'hFFE; input clk, nreset, run, r, cpu_r; input [1:0] w; input [l-1:1] addr; input `L data, cpu_addr; output drun, dr, dw; output `L bp; reg drun, drun1; reg `L bp; wire dsel = (addr[l-1:4] == dbgaddr); assign dr = dsel & r; assign dw = dsel & |w; always @(posedge clk or negedge nreset) if(!nreset) begin drun <= 1; drun1 <= 1; bp <= 16'hffff; end else begin if(cpu_addr == bp && cpu_r) { drun, drun1 } <= 0; else if(run) drun <= drun1; if((dr | dw) && (addr[3:1] == 3'h3)) begin drun <= !dr & dw; drun1 <= !dr & dw & data[12]; end if(dw && addr[3:1] == 3'h2) bp <= data; end endmodule `endif