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

Subversion Repositories dbg_interface

[/] [dbg_interface/] [tags/] [rel_15/] [rtl/] [verilog/] [dbg_cpu_registers.v] - Blame information for rev 158

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 100 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  dbg_cpu_registers.v                                         ////
4
////                                                              ////
5
////                                                              ////
6
////  This file is part of the SoC/OpenRISC Development Interface ////
7
////  http://www.opencores.org/projects/DebugInterface/           ////
8
////                                                              ////
9
////  Author(s):                                                  ////
10
////       Igor Mohor (igorm@opencores.org)                       ////
11
////                                                              ////
12
////                                                              ////
13
////  All additional information is avaliable in the README.txt   ////
14
////  file.                                                       ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2000 - 2004 Authors                            ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
//
43
// CVS Revision History
44
//
45
// $Log: not supported by cvs2svn $
46 101 mohor
// Revision 1.1  2004/01/16 14:53:33  mohor
47
// *** empty log message ***
48 100 mohor
//
49
//
50 101 mohor
//
51 100 mohor
 
52
// synopsys translate_off
53
`include "timescale.v"
54
// synopsys translate_on
55
`include "dbg_cpu_defines.v"
56
 
57
module dbg_cpu_registers  (
58 101 mohor
                            data_i,
59
                            data_o,
60
                            addr_i,
61
                            we_i,
62
                            en_i,
63
                            clk_i,
64
                            bp_i,
65
                            rst_i,
66
                            cpu_clk_i,
67
                            cpu_stall_o,
68
                            cpu_stall_all_o,
69
                            cpu_sel_o,
70
                            cpu_rst_o
71 100 mohor
                          );
72
 
73
 
74 101 mohor
input            [7:0]  data_i;
75
input            [1:0]  addr_i;
76 100 mohor
 
77 101 mohor
input                   we_i;
78
input                   en_i;
79
input                   clk_i;
80
input                   bp_i;
81
input                   rst_i;
82
input                   cpu_clk_i;
83 100 mohor
 
84 101 mohor
output           [7:0]  data_o;
85
reg              [7:0]  data_o;
86 100 mohor
 
87 101 mohor
output                  cpu_stall_o;
88
output                  cpu_stall_all_o;
89
output [`CPU_NUM -1:0]  cpu_sel_o;
90
output                  cpu_rst_o;
91 100 mohor
 
92 101 mohor
wire                    cpu_stall;
93
wire                    cpu_stall_all;
94
wire                    cpu_reset;
95 100 mohor
wire             [2:1]  cpu_op_out;
96
wire   [`CPU_NUM -1:0]  cpu_sel_out;
97
 
98
wire                    cpuop_wr;
99
wire                    cpusel_wr;
100
 
101 101 mohor
reg                     cpusel_wr_sync;
102
reg                     cpusel_wr_cpu;
103 100 mohor
reg                     cpu_stall_bp;
104 101 mohor
reg                     cpu_stall_sync;
105
reg                     cpu_stall_o;
106
reg                     cpu_stall_all_sync;
107
reg                     cpu_stall_all_o;
108
reg                     cpu_reset_sync;
109
reg                     cpu_rst_o;
110 100 mohor
 
111
 
112
 
113
 
114 101 mohor
assign cpuop_wr      = en_i & we_i & (addr_i == `CPU_OP_ADR);
115
assign cpusel_wr     = en_i & we_i & (addr_i == `CPU_SEL_ADR);
116 100 mohor
 
117
 
118 101 mohor
// Synchronising we for cpu_sel register that works in cpu_clk clock domain
119
always @ (posedge cpu_clk_i)
120 100 mohor
begin
121 101 mohor
  cpusel_wr_sync <= #1 cpusel_wr;
122
  cpusel_wr_cpu  <= #1 cpusel_wr_sync;
123
end
124
 
125
 
126
 
127
always @(posedge clk_i or posedge rst_i)
128
begin
129
  if(rst_i)
130 100 mohor
    cpu_stall_bp <= 1'b0;
131 101 mohor
  else if(bp_i)                     // Breakpoint sets bit
132 100 mohor
    cpu_stall_bp <= 1'b1;
133
  else if(cpuop_wr)               // Register access can set or clear bit
134 101 mohor
    cpu_stall_bp <= data_i[0];
135 100 mohor
end
136
 
137
 
138 101 mohor
dbg_register #(2, 0)          CPUOP  (.data_in(data_i[2:1]),           .data_out(cpu_op_out[2:1]), .write(cpuop_wr),   .clk(clk_i), .reset(rst_i));
139
dbg_register #(`CPU_NUM, 0)   CPUSEL (.data_in(data_i[`CPU_NUM-1:0]),  .data_out(cpu_sel_out),     .write(cpusel_wr_cpu),  .clk(cpu_clk_i), .reset(rst_i)); // cpu_cli_i
140 100 mohor
 
141
 
142 101 mohor
always @ (posedge clk_i)
143 100 mohor
begin
144 101 mohor
  case (addr_i)         // Synthesis parallel_case
145
    `CPU_OP_ADR  : data_o <= #1 {5'h0, cpu_op_out[2:1], cpu_stall};
146
    `CPU_SEL_ADR : data_o <= #1 {{(8-`CPU_NUM){1'b0}}, cpu_sel_out};
147
    default      : data_o <= #1 8'h0;
148 100 mohor
  endcase
149
end
150
 
151
 
152 101 mohor
assign cpu_stall          = bp_i | cpu_stall_bp;   // bp asynchronously sets the cpu_stall, then cpu_stall_bp (from register) holds it active
153 100 mohor
assign cpu_stall_all      = cpu_op_out[2];       // this signal is used to stall all the cpus except the one that is selected in cpusel register
154 101 mohor
assign cpu_sel_o          = cpu_sel_out;
155 100 mohor
assign cpu_reset          = cpu_op_out[1];
156
 
157 101 mohor
 
158
 
159
 
160
// Synchronizing signals from registers
161
always @ (posedge cpu_clk_i)
162
begin
163
  cpu_stall_sync      <= #1 cpu_stall;
164
  cpu_stall_o         <= #1 cpu_stall_sync;
165
  cpu_stall_all_sync  <= #1 cpu_stall_all;
166
  cpu_stall_all_o     <= #1 cpu_stall_all_sync;
167
  cpu_reset_sync      <= #1 cpu_reset;
168
  cpu_rst_o           <= #1 cpu_reset_sync;
169
end
170
 
171
 
172
 
173 100 mohor
endmodule
174
 

powered by: WebSVN 2.1.0

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