OpenCores
URL https://opencores.org/ocsvn/ao486/ao486/trunk

Subversion Repositories ao486

[/] [ao486/] [trunk/] [rtl/] [ao486/] [pipeline/] [read_debug.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
/*
2
 * Copyright (c) 2014, Aleksander Osman
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * * Redistributions of source code must retain the above copyright notice, this
9
 *   list of conditions and the following disclaimer.
10
 *
11
 * * Redistributions in binary form must reproduce the above copyright notice,
12
 *   this list of conditions and the following disclaimer in the documentation
13
 *   and/or other materials provided with the distribution.
14
 *
15
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
 
27
`include "defines.v"
28
 
29
module read_debug(
30
    input               clk,
31
    input               rst_n,
32
 
33
    input       [31:0]  dr0,
34
    input       [31:0]  dr1,
35
    input       [31:0]  dr2,
36
    input       [31:0]  dr3,
37
    input       [31:0]  dr7,
38
 
39
    input       [2:0]   debug_len0,
40
    input       [2:0]   debug_len1,
41
    input       [2:0]   debug_len2,
42
    input       [2:0]   debug_len3,
43
 
44
    input               rd_ready,
45
 
46
    input               read_do,
47
    input       [31:0]  read_address,
48
    input       [3:0]   read_length,
49
 
50
    output      [3:0]   rd_debug_read
51
);
52
 
53
 
54
//------------------------------------------------------------------------------
55
 
56
wire        rd_debug_trigger;
57
wire [31:0] rd_debug_linear;
58
wire [3:0]  rd_debug_length;
59
 
60
wire [31:0] rd_debug_linear_last;
61
 
62
wire        rd_debug_b0_trigger;
63
wire        rd_debug_b1_trigger;
64
wire        rd_debug_b2_trigger;
65
wire        rd_debug_b3_trigger;
66
 
67
//------------------------------------------------------------------------------
68
 
69
reg rd_debug_b0_reg;
70
reg rd_debug_b1_reg;
71
reg rd_debug_b2_reg;
72
reg rd_debug_b3_reg;
73
 
74
//------------------------------------------------------------------------------
75
 
76
assign rd_debug_trigger = read_do; //can be many cycles
77
assign rd_debug_linear  = read_address;
78
assign rd_debug_length  = read_length;
79
 
80
assign rd_debug_linear_last = rd_debug_linear + { 28'd0, rd_debug_length } - 32'd1;
81
 
82
assign rd_debug_read = {
83
    rd_debug_b3_trigger | rd_debug_b3_reg, rd_debug_b2_trigger | rd_debug_b2_reg,
84
    rd_debug_b1_trigger | rd_debug_b1_reg, rd_debug_b0_trigger | rd_debug_b0_reg };
85
 
86
//------------------------------------------------------------------------------ breakpoint 0
87
assign rd_debug_b0_trigger =
88
    rd_debug_trigger && dr7[17:16] == 2'b11 && // RW bits = read or write
89
    ( rd_debug_linear      <= { dr0[31:3], dr0[2:0] | ~(debug_len0)} ) &&
90
    ( rd_debug_linear_last >= { dr0[31:3], dr0[2:0] &   debug_len0 } );
91
 
92
always @(posedge clk or negedge rst_n) begin
93
    if(rst_n == 1'b0)               rd_debug_b0_reg <= `FALSE;
94
    else if(rd_ready)               rd_debug_b0_reg <= `FALSE;
95
    else if(rd_debug_b0_trigger)    rd_debug_b0_reg <= `TRUE;
96
end
97
 
98
//------------------------------------------------------------------------------ breakpoint 1
99
assign rd_debug_b1_trigger =
100
    rd_debug_trigger && dr7[21:20] == 2'b11 && // RW bits = read or write
101
    ( rd_debug_linear      <= { dr1[31:3], dr1[2:0] | ~(debug_len1)} ) &&
102
    ( rd_debug_linear_last >= { dr1[31:3], dr1[2:0] &   debug_len1 } );
103
 
104
always @(posedge clk or negedge rst_n) begin
105
    if(rst_n == 1'b0)               rd_debug_b1_reg <= `FALSE;
106
    else if(rd_ready)               rd_debug_b1_reg <= `FALSE;
107
    else if(rd_debug_b1_trigger)    rd_debug_b1_reg <= `TRUE;
108
end
109
 
110
//------------------------------------------------------------------------------ breakpoint 2
111
assign rd_debug_b2_trigger =
112
    rd_debug_trigger && dr7[25:24] == 2'b11 && // RW bits = read or write
113
    ( rd_debug_linear      <= { dr2[31:3], dr2[2:0] | ~(debug_len2)} ) &&
114
    ( rd_debug_linear_last >= { dr2[31:3], dr2[2:0] &   debug_len2 } );
115
 
116
always @(posedge clk or negedge rst_n) begin
117
    if(rst_n == 1'b0)               rd_debug_b2_reg <= `FALSE;
118
    else if(rd_ready)               rd_debug_b2_reg <= `FALSE;
119
    else if(rd_debug_b2_trigger)    rd_debug_b2_reg <= `TRUE;
120
end
121
 
122
//------------------------------------------------------------------------------ breakpoint 3
123
assign rd_debug_b3_trigger =
124
    rd_debug_trigger && dr7[29:28] == 2'b11 && // RW bits = read or write
125
    ( rd_debug_linear      <= { dr3[31:3], dr3[2:0] | ~(debug_len3)} ) &&
126
    ( rd_debug_linear_last >= { dr3[31:3], dr3[2:0] &   debug_len3 } );
127
 
128
always @(posedge clk or negedge rst_n) begin
129
    if(rst_n == 1'b0)               rd_debug_b3_reg <= `FALSE;
130
    else if(rd_ready)               rd_debug_b3_reg <= `FALSE;
131
    else if(rd_debug_b3_trigger)    rd_debug_b3_reg <= `TRUE;
132
end
133
 
134
//------------------------------------------------------------------------------
135
 
136
// synthesis translate_off
137
wire _unused_ok = &{ 1'b0, dr7[31:30], dr7[27:26], dr7[23:22], dr7[19:18], dr7[15:0], 1'b0 };
138
// synthesis translate_on
139
 
140
//------------------------------------------------------------------------------
141
 
142
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.