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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [soc/] [rtl/] [adv_debug_sys/] [Hardware/] [adv_dbg_if/] [rtl/] [verilog/] [adbg_or1k_status_reg.v] - Blame information for rev 21

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 xianfeng
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  adbg_or1k_status_reg.v                                      ////
4
////                                                              ////
5
////                                                              ////
6
////  This file is part of the SoC Debug Interface.               ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////       Igor Mohor (igorm@opencores.org)                       ////
10
////                                                              ////
11
////                                                              ////
12
////                                                              ////
13
//////////////////////////////////////////////////////////////////////
14
////                                                              ////
15
//// Copyright (C) 2000 - 2010 Authors                            ////
16
////                                                              ////
17
//// This source file may be used and distributed without         ////
18
//// restriction provided that this copyright statement is not    ////
19
//// removed from the file and that any derivative work contains  ////
20
//// the original copyright notice and the associated disclaimer. ////
21
////                                                              ////
22
//// This source file is free software; you can redistribute it   ////
23
//// and/or modify it under the terms of the GNU Lesser General   ////
24
//// Public License as published by the Free Software Foundation; ////
25
//// either version 2.1 of the License, or (at your option) any   ////
26
//// later version.                                               ////
27
////                                                              ////
28
//// This source is distributed in the hope that it will be       ////
29
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
30
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
31
//// PURPOSE.  See the GNU Lesser General Public License for more ////
32
//// details.                                                     ////
33
////                                                              ////
34
//// You should have received a copy of the GNU Lesser General    ////
35
//// Public License along with this source; if not, download it   ////
36
//// from http://www.opencores.org/lgpl.shtml                     ////
37
////                                                              ////
38
//////////////////////////////////////////////////////////////////////
39
//
40
// CVS Revision History
41
//
42
// $Log: adbg_or1k_status_reg.v,v $
43
// Revision 1.2  2010-01-10 22:54:10  Nathan
44
// Update copyright dates
45
//
46
// Revision 1.1  2008/07/22 20:28:31  Nathan
47
// Changed names of all files and modules (prefixed an a, for advanced).  Cleanup, indenting.  No functional changes.
48
//
49
// Revision 1.3  2008/07/06 20:02:54  Nathan
50
// Fixes for synthesis with Xilinx ISE (also synthesizable with 
51
// Quartus II 7.0).  Ran through dos2unix.
52
//
53
// Revision 1.2  2008/06/26 20:52:32  Nathan
54
// OR1K module tested and working.  Added copyright / license info 
55
// to _define files.  Other cleanup.
56
//
57
//
58
//
59
//
60
 
61
`include "adbg_or1k_defines.v"
62
 
63
module adbg_or1k_status_reg  (
64
                              data_i,
65
                              we_i,
66
                              tck_i,
67
                              bp_i,
68
                              rst_i,
69
                              cpu_clk_i,
70
                              ctrl_reg_o,
71
                              cpu_stall_o,
72
                              cpu_rst_o
73
                              );
74
 
75
 
76
   input  [`DBG_OR1K_STATUS_LEN - 1:0] data_i;
77
   input                               we_i;
78
   input                               tck_i;
79
   input                               bp_i;
80
   input                               rst_i;
81
   input                               cpu_clk_i;
82
 
83
   output [`DBG_OR1K_STATUS_LEN - 1:0] ctrl_reg_o;
84
   output                              cpu_stall_o;
85
   output                              cpu_rst_o;
86
 
87
   reg                                 cpu_reset;
88
   wire [2:1]                          cpu_op_out;
89
 
90
   reg                                 stall_bp, stall_bp_csff, stall_bp_tck;
91
   reg                                 stall_reg, stall_reg_csff, stall_reg_cpu;
92
   reg                                 cpu_reset_csff;
93
   reg                                 cpu_rst_o;
94
 
95
 
96
 
97
   // Breakpoint is latched and synchronized. Stall is set and latched.
98
   // This is done in the CPU clock domain, because the JTAG clock (TCK) is
99
   // irregular.  By only allowing bp_i to set (but not reset) the stall_bp
100
   // signal, we insure that the CPU will remain in the stalled state until
101
   // the debug host can read the state.
102
   always @ (posedge cpu_clk_i or posedge rst_i)
103
     begin
104
        if(rst_i)
105
          stall_bp <= #1 1'b0;
106
        else if(bp_i)
107
          stall_bp <= #1 1'b1;
108
        else if(stall_reg_cpu)
109
          stall_bp <= #1 1'b0;
110
     end
111
 
112
 
113
   // Synchronizing
114
   always @ (posedge tck_i or posedge rst_i)
115
     begin
116
        if (rst_i)
117
          begin
118
             stall_bp_csff <= #1 1'b0;
119
             stall_bp_tck  <= #1 1'b0;
120
          end
121
        else
122
          begin
123
             stall_bp_csff <= #1 stall_bp;
124
             stall_bp_tck  <= #1 stall_bp_csff;
125
          end
126
     end
127
 
128
 
129
   always @ (posedge cpu_clk_i or posedge rst_i)
130
     begin
131
        if (rst_i)
132
          begin
133
             stall_reg_csff <= #1 1'b0;
134
             stall_reg_cpu  <= #1 1'b0;
135
          end
136
        else
137
          begin
138
             stall_reg_csff <= #1 stall_reg;
139
             stall_reg_cpu  <= #1 stall_reg_csff;
140
          end
141
     end
142
 
143
   // bp_i forces a stall immediately on a breakpoint
144
   // stall_bp holds the stall until the debug host acts
145
   // stall_reg_cpu allows the debug host to control a stall.
146
   assign cpu_stall_o = bp_i | stall_bp | stall_reg_cpu;
147
 
148
 
149
   // Writing data to the control registers (stall)
150
   // This can be set either by the debug host, or by
151
   // a CPU breakpoint.  It can only be cleared by the host.
152
   always @ (posedge tck_i or posedge rst_i)
153
     begin
154
        if (rst_i)
155
          stall_reg <= #1 1'b0;
156
        else if (stall_bp_tck)
157
          stall_reg <= #1 1'b1;
158
        else if (we_i)
159
          stall_reg <= #1 data_i[0];
160
     end
161
 
162
 
163
   // Writing data to the control registers (reset)
164
   always @ (posedge tck_i or posedge rst_i)
165
     begin
166
        if (rst_i)
167
          cpu_reset  <= #1 1'b0;
168
        else if(we_i)
169
          cpu_reset  <= #1 data_i[1];
170
     end
171
 
172
 
173
   // Synchronizing signals from registers
174
   always @ (posedge cpu_clk_i or posedge rst_i)
175
     begin
176
        if (rst_i)
177
          begin
178
             cpu_reset_csff      <= #1 1'b0;
179
             cpu_rst_o           <= #1 1'b0;
180
          end
181
        else
182
          begin
183
             cpu_reset_csff      <= #1 cpu_reset;
184
             cpu_rst_o           <= #1 cpu_reset_csff;
185
          end
186
     end
187
 
188
 
189
 
190
   // Value for read back
191
   assign ctrl_reg_o = {cpu_reset, stall_reg};
192
 
193
 
194
endmodule
195
 

powered by: WebSVN 2.1.0

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