-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebugger.v
More file actions
55 lines (50 loc) · 1.49 KB
/
debugger.v
File metadata and controls
55 lines (50 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* 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