1 |
2 |
tobil |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// OR1200's WISHBONE BIU ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the OpenRISC 1200 project ////
|
6 |
|
|
//// http://www.opencores.org/cores/or1k/ ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Description ////
|
9 |
|
|
//// Implements WISHBONE interface ////
|
10 |
|
|
//// ////
|
11 |
|
|
//// To Do: ////
|
12 |
|
|
//// - if biu_cyc/stb are deasserted and wb_ack_i is asserted ////
|
13 |
|
|
//// and this happens even before aborted_r is asssrted, ////
|
14 |
|
|
//// wb_ack_i will be delivered even though transfer is ////
|
15 |
|
|
//// internally considered already aborted. However most ////
|
16 |
|
|
//// wb_ack_i are externally registered and delayed. Normally ////
|
17 |
|
|
//// this shouldn't cause any problems. ////
|
18 |
|
|
//// ////
|
19 |
|
|
//// Author(s): ////
|
20 |
|
|
//// - Damjan Lampret, lampret@opencores.org ////
|
21 |
|
|
//// ////
|
22 |
|
|
//////////////////////////////////////////////////////////////////////
|
23 |
|
|
//// ////
|
24 |
|
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
25 |
|
|
//// ////
|
26 |
|
|
//// This source file may be used and distributed without ////
|
27 |
|
|
//// restriction provided that this copyright statement is not ////
|
28 |
|
|
//// removed from the file and that any derivative work contains ////
|
29 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
30 |
|
|
//// ////
|
31 |
|
|
//// This source file is free software; you can redistribute it ////
|
32 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
33 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
34 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
35 |
|
|
//// later version. ////
|
36 |
|
|
//// ////
|
37 |
|
|
//// This source is distributed in the hope that it will be ////
|
38 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
39 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
40 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
41 |
|
|
//// details. ////
|
42 |
|
|
//// ////
|
43 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
44 |
|
|
//// Public License along with this source; if not, download it ////
|
45 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
46 |
|
|
//// ////
|
47 |
|
|
//////////////////////////////////////////////////////////////////////
|
48 |
|
|
//
|
49 |
|
|
// CVS Revision History
|
50 |
|
|
//
|
51 |
|
|
// $Log: not supported by cvs2svn $
|
52 |
|
|
// Revision 1.1 2003/12/05 00:12:08 lampret
|
53 |
|
|
// New wb_biu for iwb interface.
|
54 |
|
|
//
|
55 |
|
|
// Revision 1.6.4.1 2003/07/08 15:36:37 lampret
|
56 |
|
|
// Added embedded memory QMEM.
|
57 |
|
|
//
|
58 |
|
|
// Revision 1.6 2003/04/07 20:57:46 lampret
|
59 |
|
|
// Fixed OR1200_CLKDIV_x_SUPPORTED defines. Fixed order of ifdefs.
|
60 |
|
|
//
|
61 |
|
|
// Revision 1.5 2002/12/08 08:57:56 lampret
|
62 |
|
|
// Added optional support for WB B3 specification (xwb_cti_o, xwb_bte_o). Made xwb_cab_o optional.
|
63 |
|
|
//
|
64 |
|
|
// Revision 1.4 2002/09/16 03:09:16 lampret
|
65 |
|
|
// Fixed a combinational loop.
|
66 |
|
|
//
|
67 |
|
|
// Revision 1.3 2002/08/12 05:31:37 lampret
|
68 |
|
|
// Added optional retry counter for wb_rty_i. Added graceful termination for aborted transfers.
|
69 |
|
|
//
|
70 |
|
|
// Revision 1.2 2002/07/14 22:17:17 lampret
|
71 |
|
|
// Added simple trace buffer [only for Xilinx Virtex target]. Fixed instruction fetch abort when new exception is recognized.
|
72 |
|
|
//
|
73 |
|
|
// Revision 1.1 2002/01/03 08:16:15 lampret
|
74 |
|
|
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
|
75 |
|
|
//
|
76 |
|
|
// Revision 1.12 2001/11/22 13:42:51 lampret
|
77 |
|
|
// Added wb_cyc_o assignment after it was removed by accident.
|
78 |
|
|
//
|
79 |
|
|
// Revision 1.11 2001/11/20 21:28:10 lampret
|
80 |
|
|
// Added optional sampling of inputs.
|
81 |
|
|
//
|
82 |
|
|
// Revision 1.10 2001/11/18 11:32:00 lampret
|
83 |
|
|
// OR1200_REGISTERED_OUTPUTS can now be enabled.
|
84 |
|
|
//
|
85 |
|
|
// Revision 1.9 2001/10/21 17:57:16 lampret
|
86 |
|
|
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
|
87 |
|
|
//
|
88 |
|
|
// Revision 1.8 2001/10/14 13:12:10 lampret
|
89 |
|
|
// MP3 version.
|
90 |
|
|
//
|
91 |
|
|
// Revision 1.1.1.1 2001/10/06 10:18:35 igorm
|
92 |
|
|
// no message
|
93 |
|
|
//
|
94 |
|
|
// Revision 1.3 2001/08/09 13:39:33 lampret
|
95 |
|
|
// Major clean-up.
|
96 |
|
|
//
|
97 |
|
|
// Revision 1.2 2001/07/22 03:31:54 lampret
|
98 |
|
|
// Fixed RAM's oen bug. Cache bypass under development.
|
99 |
|
|
//
|
100 |
|
|
// Revision 1.1 2001/07/20 00:46:23 lampret
|
101 |
|
|
// Development version of RTL. Libraries are missing.
|
102 |
|
|
//
|
103 |
|
|
//
|
104 |
|
|
|
105 |
|
|
// synopsys translate_off
|
106 |
|
|
`include "timescale.v"
|
107 |
|
|
// synopsys translate_on
|
108 |
|
|
`include "or1200_defines.v"
|
109 |
|
|
|
110 |
|
|
module or1200_iwb_biu_cm3(
|
111 |
|
|
clk_i_cml_1,
|
112 |
|
|
clk_i_cml_2,
|
113 |
|
|
|
114 |
|
|
// RISC clock, reset and clock control
|
115 |
|
|
clk, rst, clmode,
|
116 |
|
|
|
117 |
|
|
// WISHBONE interface
|
118 |
|
|
wb_clk_i, wb_rst_i, wb_ack_i, wb_err_i, wb_rty_i, wb_dat_i,
|
119 |
|
|
wb_cyc_o, wb_adr_o, wb_stb_o, wb_we_o, wb_sel_o, wb_dat_o,
|
120 |
|
|
`ifdef OR1200_WB_CAB
|
121 |
|
|
wb_cab_o,
|
122 |
|
|
`endif
|
123 |
|
|
`ifdef OR1200_WB_B3
|
124 |
|
|
wb_cti_o, wb_bte_o,
|
125 |
|
|
`endif
|
126 |
|
|
|
127 |
|
|
// Internal RISC bus
|
128 |
|
|
biu_dat_i, biu_adr_i, biu_cyc_i, biu_stb_i, biu_we_i, biu_sel_i, biu_cab_i,
|
129 |
|
|
biu_dat_o, biu_ack_o, biu_err_o
|
130 |
|
|
);
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
input clk_i_cml_1;
|
134 |
|
|
input clk_i_cml_2;
|
135 |
|
|
reg wb_ack_i_cml_2;
|
136 |
|
|
reg wb_ack_i_cml_1;
|
137 |
|
|
reg wb_err_i_cml_2;
|
138 |
|
|
reg wb_err_i_cml_1;
|
139 |
|
|
reg [ 32 - 1 : 0 ] wb_dat_i_cml_2;
|
140 |
|
|
reg [ 32 - 1 : 0 ] wb_dat_i_cml_1;
|
141 |
|
|
reg wb_cyc_o_cml_2;
|
142 |
|
|
reg wb_cyc_o_cml_1;
|
143 |
|
|
reg [ 32 - 1 : 0 ] wb_adr_o_cml_2;
|
144 |
|
|
reg [ 32 - 1 : 0 ] wb_adr_o_cml_1;
|
145 |
|
|
reg wb_stb_o_cml_2;
|
146 |
|
|
reg wb_stb_o_cml_1;
|
147 |
|
|
reg wb_we_o_cml_2;
|
148 |
|
|
reg wb_we_o_cml_1;
|
149 |
|
|
reg [ 3 : 0 ] wb_sel_o_cml_2;
|
150 |
|
|
reg [ 3 : 0 ] wb_sel_o_cml_1;
|
151 |
|
|
reg [ 32 - 1 : 0 ] wb_dat_o_cml_2;
|
152 |
|
|
reg [ 32 - 1 : 0 ] wb_dat_o_cml_1;
|
153 |
|
|
reg wb_cab_o_cml_2;
|
154 |
|
|
reg wb_cab_o_cml_1;
|
155 |
|
|
reg biu_ack_o_cml_2;
|
156 |
|
|
reg biu_ack_o_cml_1;
|
157 |
|
|
reg [ 1 : 0 ] valid_div_cml_2;
|
158 |
|
|
reg [ 1 : 0 ] valid_div_cml_1;
|
159 |
|
|
reg aborted_r_cml_2;
|
160 |
|
|
reg aborted_r_cml_1;
|
161 |
|
|
reg previous_complete_cml_2;
|
162 |
|
|
reg previous_complete_cml_1;
|
163 |
|
|
reg repeated_access_ack_cml_2;
|
164 |
|
|
reg repeated_access_ack_cml_1;
|
165 |
|
|
reg [ 32 - 1 : 0 ] wb_dat_r_cml_2;
|
166 |
|
|
reg [ 32 - 1 : 0 ] wb_dat_r_cml_1;
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
parameter dw = `OR1200_OPERAND_WIDTH;
|
171 |
|
|
parameter aw = `OR1200_OPERAND_WIDTH;
|
172 |
|
|
|
173 |
|
|
//
|
174 |
|
|
// RISC clock, reset and clock control
|
175 |
|
|
//
|
176 |
|
|
input clk; // RISC clock
|
177 |
|
|
input rst; // RISC reset
|
178 |
|
|
input [1:0] clmode; // 00 WB=RISC, 01 WB=RISC/2, 10 N/A, 11 WB=RISC/4
|
179 |
|
|
|
180 |
|
|
//
|
181 |
|
|
// WISHBONE interface
|
182 |
|
|
//
|
183 |
|
|
input wb_clk_i; // clock input
|
184 |
|
|
input wb_rst_i; // reset input
|
185 |
|
|
input wb_ack_i; // normal termination
|
186 |
|
|
input wb_err_i; // termination w/ error
|
187 |
|
|
input wb_rty_i; // termination w/ retry
|
188 |
|
|
input [dw-1:0] wb_dat_i; // input data bus
|
189 |
|
|
output wb_cyc_o; // cycle valid output
|
190 |
|
|
output [aw-1:0] wb_adr_o; // address bus outputs
|
191 |
|
|
output wb_stb_o; // strobe output
|
192 |
|
|
output wb_we_o; // indicates write transfer
|
193 |
|
|
output [3:0] wb_sel_o; // byte select outputs
|
194 |
|
|
output [dw-1:0] wb_dat_o; // output data bus
|
195 |
|
|
`ifdef OR1200_WB_CAB
|
196 |
|
|
output wb_cab_o; // consecutive address burst
|
197 |
|
|
`endif
|
198 |
|
|
`ifdef OR1200_WB_B3
|
199 |
|
|
output [2:0] wb_cti_o; // cycle type identifier
|
200 |
|
|
output [1:0] wb_bte_o; // burst type extension
|
201 |
|
|
`endif
|
202 |
|
|
|
203 |
|
|
//
|
204 |
|
|
// Internal RISC interface
|
205 |
|
|
//
|
206 |
|
|
input [dw-1:0] biu_dat_i; // input data bus
|
207 |
|
|
input [aw-1:0] biu_adr_i; // address bus
|
208 |
|
|
input biu_cyc_i; // WB cycle
|
209 |
|
|
input biu_stb_i; // WB strobe
|
210 |
|
|
input biu_we_i; // WB write enable
|
211 |
|
|
input biu_cab_i; // CAB input
|
212 |
|
|
input [3:0] biu_sel_i; // byte selects
|
213 |
|
|
output [31:0] biu_dat_o; // output data bus
|
214 |
|
|
output biu_ack_o; // ack output
|
215 |
|
|
output biu_err_o; // err output
|
216 |
|
|
|
217 |
|
|
//
|
218 |
|
|
// Registers
|
219 |
|
|
//
|
220 |
|
|
reg [1:0] valid_div; // Used for synchronization
|
221 |
|
|
`ifdef OR1200_REGISTERED_OUTPUTS
|
222 |
|
|
reg [aw-1:0] wb_adr_o; // address bus outputs
|
223 |
|
|
reg wb_cyc_o; // cycle output
|
224 |
|
|
reg wb_stb_o; // strobe output
|
225 |
|
|
reg wb_we_o; // indicates write transfer
|
226 |
|
|
reg [3:0] wb_sel_o; // byte select outputs
|
227 |
|
|
`ifdef OR1200_WB_CAB
|
228 |
|
|
reg wb_cab_o; // CAB output
|
229 |
|
|
`endif
|
230 |
|
|
`ifdef OR1200_WB_B3
|
231 |
|
|
reg [1:0] burst_len; // burst counter
|
232 |
|
|
reg [2:0] wb_cti_o; // cycle type identifier
|
233 |
|
|
`endif
|
234 |
|
|
reg [dw-1:0] wb_dat_o; // output data bus
|
235 |
|
|
`endif
|
236 |
|
|
`ifdef OR1200_REGISTERED_INPUTS
|
237 |
|
|
reg long_ack_o; // normal termination
|
238 |
|
|
reg long_err_o; // error termination
|
239 |
|
|
reg [dw-1:0] biu_dat_o; // output data bus
|
240 |
|
|
`else
|
241 |
|
|
wire long_ack_o; // normal termination
|
242 |
|
|
wire long_err_o; // error termination
|
243 |
|
|
`endif
|
244 |
|
|
wire aborted; // Graceful abort
|
245 |
|
|
reg aborted_r; // Graceful abort
|
246 |
|
|
wire retry; // Retry
|
247 |
|
|
`ifdef OR1200_WB_RETRY
|
248 |
|
|
reg [`OR1200_WB_RETRY-1:0] retry_cntr; // Retry counter
|
249 |
|
|
`endif
|
250 |
|
|
reg previous_complete;
|
251 |
|
|
wire same_addr;
|
252 |
|
|
wire repeated_access;
|
253 |
|
|
reg repeated_access_ack;
|
254 |
|
|
reg [dw-1:0] wb_dat_r; // saved previous data read
|
255 |
|
|
|
256 |
|
|
//
|
257 |
|
|
// WISHBONE I/F <-> Internal RISC I/F conversion
|
258 |
|
|
//
|
259 |
|
|
|
260 |
|
|
//
|
261 |
|
|
// Address bus
|
262 |
|
|
//
|
263 |
|
|
`ifdef OR1200_REGISTERED_OUTPUTS
|
264 |
|
|
|
265 |
|
|
// SynEDA CoreMultiplier
|
266 |
|
|
// assignment(s): wb_adr_o
|
267 |
|
|
// replace(s): wb_ack_i, wb_adr_o, wb_stb_o, biu_ack_o, previous_complete
|
268 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
269 |
|
|
if (wb_rst_i)
|
270 |
|
|
wb_adr_o <= #1 {aw{1'b0}};
|
271 |
|
|
else begin wb_adr_o <= wb_adr_o_cml_2; if ((biu_cyc_i & biu_stb_i) & ~wb_ack_i_cml_2 & ~aborted & ~(wb_stb_o_cml_2 & ~wb_ack_i_cml_2) | biu_cab_i & (previous_complete_cml_2 | biu_ack_o_cml_2))
|
272 |
|
|
wb_adr_o <= #1 biu_adr_i; end
|
273 |
|
|
`else
|
274 |
|
|
assign wb_adr_o = biu_adr_i;
|
275 |
|
|
`endif
|
276 |
|
|
|
277 |
|
|
//
|
278 |
|
|
// Same access as previous one, store previous read data
|
279 |
|
|
//
|
280 |
|
|
|
281 |
|
|
// SynEDA CoreMultiplier
|
282 |
|
|
// assignment(s): same_addr
|
283 |
|
|
// replace(s): wb_adr_o
|
284 |
|
|
assign same_addr = wb_adr_o_cml_2 == biu_adr_i;
|
285 |
|
|
|
286 |
|
|
// SynEDA CoreMultiplier
|
287 |
|
|
// assignment(s): repeated_access
|
288 |
|
|
// replace(s): previous_complete
|
289 |
|
|
assign repeated_access = same_addr & previous_complete_cml_2;
|
290 |
|
|
|
291 |
|
|
// SynEDA CoreMultiplier
|
292 |
|
|
// assignment(s): wb_dat_r
|
293 |
|
|
// replace(s): wb_ack_i, wb_dat_i, wb_dat_r
|
294 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
295 |
|
|
if (wb_rst_i)
|
296 |
|
|
wb_dat_r <= #1 32'h0000_0000;
|
297 |
|
|
else begin wb_dat_r <= wb_dat_r_cml_2; if (wb_ack_i_cml_2)
|
298 |
|
|
wb_dat_r <= #1 wb_dat_i_cml_2; end
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
// SynEDA CoreMultiplier
|
302 |
|
|
// assignment(s): repeated_access_ack
|
303 |
|
|
// replace(s): repeated_access_ack
|
304 |
|
|
always @(posedge clk or posedge rst)
|
305 |
|
|
if (rst)
|
306 |
|
|
repeated_access_ack <= #1 1'b0;
|
307 |
|
|
else begin repeated_access_ack <= repeated_access_ack_cml_2; if (repeated_access & biu_cyc_i & biu_stb_i)
|
308 |
|
|
repeated_access_ack <= #1 1'b1;
|
309 |
|
|
else
|
310 |
|
|
repeated_access_ack <= #1 1'b0; end
|
311 |
|
|
|
312 |
|
|
//
|
313 |
|
|
// Previous access completed
|
314 |
|
|
//
|
315 |
|
|
|
316 |
|
|
// SynEDA CoreMultiplier
|
317 |
|
|
// assignment(s): previous_complete
|
318 |
|
|
// replace(s): wb_ack_i, wb_stb_o, previous_complete
|
319 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
320 |
|
|
if (wb_rst_i)
|
321 |
|
|
previous_complete <= #1 1'b1;
|
322 |
|
|
else begin previous_complete <= previous_complete_cml_2; if (wb_ack_i_cml_2 & biu_cyc_i & biu_stb_i)
|
323 |
|
|
previous_complete <= #1 1'b1;
|
324 |
|
|
else if ((biu_cyc_i & biu_stb_i) & ~wb_ack_i_cml_2 & ~aborted & ~(wb_stb_o_cml_2 & ~wb_ack_i_cml_2))
|
325 |
|
|
previous_complete <= #1 1'b0; end
|
326 |
|
|
|
327 |
|
|
//
|
328 |
|
|
// Input data bus
|
329 |
|
|
//
|
330 |
|
|
`ifdef OR1200_REGISTERED_INPUTS
|
331 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
332 |
|
|
if (wb_rst_i)
|
333 |
|
|
biu_dat_o <= #1 32'h0000_0000;
|
334 |
|
|
else if (wb_ack_i)
|
335 |
|
|
biu_dat_o <= #1 wb_dat_i_cml_2;
|
336 |
|
|
`else
|
337 |
|
|
|
338 |
|
|
// SynEDA CoreMultiplier
|
339 |
|
|
// assignment(s): biu_dat_o
|
340 |
|
|
// replace(s): wb_dat_i, repeated_access_ack, wb_dat_r
|
341 |
|
|
assign biu_dat_o = repeated_access_ack_cml_2 ? wb_dat_r_cml_2 : wb_dat_i_cml_2;
|
342 |
|
|
`endif
|
343 |
|
|
|
344 |
|
|
//
|
345 |
|
|
// Output data bus
|
346 |
|
|
//
|
347 |
|
|
`ifdef OR1200_REGISTERED_OUTPUTS
|
348 |
|
|
|
349 |
|
|
// SynEDA CoreMultiplier
|
350 |
|
|
// assignment(s): wb_dat_o
|
351 |
|
|
// replace(s): wb_ack_i, wb_dat_o
|
352 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
353 |
|
|
if (wb_rst_i)
|
354 |
|
|
wb_dat_o <= #1 {dw{1'b0}};
|
355 |
|
|
else begin wb_dat_o <= wb_dat_o_cml_2; if ((biu_cyc_i & biu_stb_i) & ~wb_ack_i_cml_2 & ~aborted)
|
356 |
|
|
wb_dat_o <= #1 biu_dat_i; end
|
357 |
|
|
`else
|
358 |
|
|
assign wb_dat_o = biu_dat_i;
|
359 |
|
|
`endif
|
360 |
|
|
|
361 |
|
|
//
|
362 |
|
|
// Valid_div counts RISC clock cycles by modulo 4
|
363 |
|
|
// and is used to synchronize external WB i/f to
|
364 |
|
|
// RISC clock
|
365 |
|
|
//
|
366 |
|
|
|
367 |
|
|
// SynEDA CoreMultiplier
|
368 |
|
|
// assignment(s): valid_div
|
369 |
|
|
// replace(s): valid_div
|
370 |
|
|
always @(posedge clk or posedge rst)
|
371 |
|
|
if (rst)
|
372 |
|
|
valid_div <= #1 2'b0;
|
373 |
|
|
else begin valid_div <= valid_div_cml_2;
|
374 |
|
|
valid_div <= #1 valid_div_cml_2 + 1'd1; end
|
375 |
|
|
|
376 |
|
|
//
|
377 |
|
|
// biu_ack_o is one RISC clock cycle long long_ack_o.
|
378 |
|
|
// long_ack_o is one, two or four RISC clock cycles long because
|
379 |
|
|
// WISHBONE can work at 1, 1/2 or 1/4 RISC clock.
|
380 |
|
|
//
|
381 |
|
|
assign biu_ack_o = (repeated_access_ack | long_ack_o) & ~aborted_r
|
382 |
|
|
`ifdef OR1200_CLKDIV_2_SUPPORTED
|
383 |
|
|
& (valid_div[0] | ~clmode[0])
|
384 |
|
|
`ifdef OR1200_CLKDIV_4_SUPPORTED
|
385 |
|
|
& (valid_div[1] | ~clmode[1])
|
386 |
|
|
`endif
|
387 |
|
|
`endif
|
388 |
|
|
;
|
389 |
|
|
|
390 |
|
|
//
|
391 |
|
|
// Acknowledgment of the data to the RISC
|
392 |
|
|
//
|
393 |
|
|
// long_ack_o
|
394 |
|
|
//
|
395 |
|
|
`ifdef OR1200_REGISTERED_INPUTS
|
396 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
397 |
|
|
if (wb_rst_i)
|
398 |
|
|
long_ack_o <= #1 1'b0;
|
399 |
|
|
else
|
400 |
|
|
long_ack_o <= #1 wb_ack_i & ~aborted;
|
401 |
|
|
`else
|
402 |
|
|
assign long_ack_o = wb_ack_i;
|
403 |
|
|
`endif
|
404 |
|
|
|
405 |
|
|
//
|
406 |
|
|
// biu_err_o is one RISC clock cycle long long_err_o.
|
407 |
|
|
// long_err_o is one, two or four RISC clock cycles long because
|
408 |
|
|
// WISHBONE can work at 1, 1/2 or 1/4 RISC clock.
|
409 |
|
|
//
|
410 |
|
|
assign biu_err_o = long_err_o
|
411 |
|
|
`ifdef OR1200_CLKDIV_2_SUPPORTED
|
412 |
|
|
& (valid_div[0] | ~clmode[0])
|
413 |
|
|
`ifdef OR1200_CLKDIV_4_SUPPORTED
|
414 |
|
|
& (valid_div[1] | ~clmode[1])
|
415 |
|
|
`endif
|
416 |
|
|
`endif
|
417 |
|
|
;
|
418 |
|
|
|
419 |
|
|
//
|
420 |
|
|
// Error termination
|
421 |
|
|
//
|
422 |
|
|
// long_err_o
|
423 |
|
|
//
|
424 |
|
|
`ifdef OR1200_REGISTERED_INPUTS
|
425 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
426 |
|
|
if (wb_rst_i)
|
427 |
|
|
long_err_o <= #1 1'b0;
|
428 |
|
|
else
|
429 |
|
|
long_err_o <= #1 wb_err_i & ~aborted;
|
430 |
|
|
`else
|
431 |
|
|
assign long_err_o = wb_err_i & ~aborted_r;
|
432 |
|
|
`endif
|
433 |
|
|
|
434 |
|
|
//
|
435 |
|
|
// Retry counter
|
436 |
|
|
//
|
437 |
|
|
// Assert 'retry' when 'wb_rty_i' is sampled high and keep it high
|
438 |
|
|
// until retry counter doesn't expire
|
439 |
|
|
//
|
440 |
|
|
`ifdef OR1200_WB_RETRY
|
441 |
|
|
assign retry = wb_rty_i | (|retry_cntr);
|
442 |
|
|
`else
|
443 |
|
|
assign retry = 1'b0;
|
444 |
|
|
`endif
|
445 |
|
|
`ifdef OR1200_WB_RETRY
|
446 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
447 |
|
|
if (wb_rst_i)
|
448 |
|
|
retry_cntr <= #1 1'b0;
|
449 |
|
|
else if (wb_rty_i)
|
450 |
|
|
retry_cntr <= #1 {`OR1200_WB_RETRY{1'b1}};
|
451 |
|
|
else if (retry_cntr)
|
452 |
|
|
retry_cntr <= #1 retry_cntr - 7'd1;
|
453 |
|
|
`endif
|
454 |
|
|
|
455 |
|
|
//
|
456 |
|
|
// Graceful completion of aborted transfers
|
457 |
|
|
//
|
458 |
|
|
// Assert 'aborted' when 1) current transfer is in progress (wb_stb_o; which
|
459 |
|
|
// we know is only asserted together with wb_cyc_o) 2) and in next WB clock cycle
|
460 |
|
|
// wb_stb_o would be deasserted (biu_cyc_i and biu_stb_i are low) 3) and
|
461 |
|
|
// there is no termination of current transfer in this WB clock cycle (wb_ack_i
|
462 |
|
|
// and wb_err_i are low).
|
463 |
|
|
// 'aborted_r' is registered 'aborted' and extended until this "aborted" transfer
|
464 |
|
|
// is properly terminated with wb_ack_i/wb_err_i.
|
465 |
|
|
//
|
466 |
|
|
|
467 |
|
|
// SynEDA CoreMultiplier
|
468 |
|
|
// assignment(s): aborted
|
469 |
|
|
// replace(s): wb_ack_i, wb_err_i, wb_stb_o
|
470 |
|
|
assign aborted = wb_stb_o_cml_2 & ~(biu_cyc_i & biu_stb_i) & ~(wb_ack_i_cml_2 | wb_err_i_cml_2);
|
471 |
|
|
|
472 |
|
|
// SynEDA CoreMultiplier
|
473 |
|
|
// assignment(s): aborted_r
|
474 |
|
|
// replace(s): wb_ack_i, wb_err_i, aborted_r
|
475 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
476 |
|
|
if (wb_rst_i)
|
477 |
|
|
aborted_r <= #1 1'b0;
|
478 |
|
|
else begin aborted_r <= aborted_r_cml_2; if (wb_ack_i_cml_2 | wb_err_i_cml_2)
|
479 |
|
|
aborted_r <= #1 1'b0;
|
480 |
|
|
else if (aborted)
|
481 |
|
|
aborted_r <= #1 1'b1; end
|
482 |
|
|
|
483 |
|
|
//
|
484 |
|
|
// WB cyc_o
|
485 |
|
|
//
|
486 |
|
|
// Either 1) normal transfer initiated by biu_cyc_i (and biu_cab_i if
|
487 |
|
|
// bursts are enabled) and possibly suspended by 'retry'
|
488 |
|
|
// or 2) extended "aborted" transfer
|
489 |
|
|
//
|
490 |
|
|
`ifdef OR1200_REGISTERED_OUTPUTS
|
491 |
|
|
|
492 |
|
|
// SynEDA CoreMultiplier
|
493 |
|
|
// assignment(s): wb_cyc_o
|
494 |
|
|
// replace(s): wb_ack_i, wb_cyc_o
|
495 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
496 |
|
|
if (wb_rst_i)
|
497 |
|
|
wb_cyc_o <= #1 1'b0;
|
498 |
|
|
else begin wb_cyc_o <= wb_cyc_o_cml_2;
|
499 |
|
|
`ifdef OR1200_NO_BURSTS
|
500 |
|
|
wb_cyc_o <= #1 biu_cyc_i & ~wb_ack_i_cml_2 & ~retry & ~repeated_access | aborted & ~wb_ack_i_cml_2;
|
501 |
|
|
`else
|
502 |
|
|
wb_cyc_o <= #1 biu_cyc_i & ~wb_ack_i_cml_2 & ~retry & ~repeated_access | biu_cab_i | aborted & ~wb_ack_i_cml_2; end
|
503 |
|
|
`endif
|
504 |
|
|
`else
|
505 |
|
|
`ifdef OR1200_NO_BURSTS
|
506 |
|
|
assign wb_cyc_o = biu_cyc_i & ~retry;
|
507 |
|
|
`else
|
508 |
|
|
assign wb_cyc_o = biu_cyc_i | biu_cab_i & ~retry;
|
509 |
|
|
`endif
|
510 |
|
|
`endif
|
511 |
|
|
|
512 |
|
|
//
|
513 |
|
|
// WB stb_o
|
514 |
|
|
//
|
515 |
|
|
`ifdef OR1200_REGISTERED_OUTPUTS
|
516 |
|
|
|
517 |
|
|
// SynEDA CoreMultiplier
|
518 |
|
|
// assignment(s): wb_stb_o
|
519 |
|
|
// replace(s): wb_ack_i, wb_stb_o
|
520 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
521 |
|
|
if (wb_rst_i)
|
522 |
|
|
wb_stb_o <= #1 1'b0;
|
523 |
|
|
else begin wb_stb_o <= wb_stb_o_cml_2;
|
524 |
|
|
wb_stb_o <= #1 (biu_cyc_i & biu_stb_i) & ~wb_ack_i_cml_2 & ~retry & ~repeated_access | aborted & ~wb_ack_i_cml_2; end
|
525 |
|
|
`else
|
526 |
|
|
assign wb_stb_o = biu_cyc_i & biu_stb_i;
|
527 |
|
|
`endif
|
528 |
|
|
|
529 |
|
|
//
|
530 |
|
|
// WB we_o
|
531 |
|
|
//
|
532 |
|
|
`ifdef OR1200_REGISTERED_OUTPUTS
|
533 |
|
|
|
534 |
|
|
// SynEDA CoreMultiplier
|
535 |
|
|
// assignment(s): wb_we_o
|
536 |
|
|
// replace(s): wb_we_o
|
537 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
538 |
|
|
if (wb_rst_i)
|
539 |
|
|
wb_we_o <= #1 1'b0;
|
540 |
|
|
else begin wb_we_o <= wb_we_o_cml_2;
|
541 |
|
|
wb_we_o <= #1 biu_cyc_i & biu_stb_i & biu_we_i | aborted & wb_we_o_cml_2; end
|
542 |
|
|
`else
|
543 |
|
|
assign wb_we_o = biu_cyc_i & biu_stb_i & biu_we_i;
|
544 |
|
|
`endif
|
545 |
|
|
|
546 |
|
|
//
|
547 |
|
|
// WB sel_o
|
548 |
|
|
//
|
549 |
|
|
`ifdef OR1200_REGISTERED_OUTPUTS
|
550 |
|
|
|
551 |
|
|
// SynEDA CoreMultiplier
|
552 |
|
|
// assignment(s): wb_sel_o
|
553 |
|
|
// replace(s): wb_sel_o
|
554 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
555 |
|
|
if (wb_rst_i)
|
556 |
|
|
wb_sel_o <= #1 4'b0000;
|
557 |
|
|
else begin wb_sel_o <= wb_sel_o_cml_2;
|
558 |
|
|
wb_sel_o <= #1 biu_sel_i; end
|
559 |
|
|
`else
|
560 |
|
|
assign wb_sel_o = biu_sel_i;
|
561 |
|
|
`endif
|
562 |
|
|
|
563 |
|
|
`ifdef OR1200_WB_CAB
|
564 |
|
|
//
|
565 |
|
|
// WB cab_o
|
566 |
|
|
//
|
567 |
|
|
`ifdef OR1200_REGISTERED_OUTPUTS
|
568 |
|
|
|
569 |
|
|
// SynEDA CoreMultiplier
|
570 |
|
|
// assignment(s): wb_cab_o
|
571 |
|
|
// replace(s): wb_cab_o
|
572 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
573 |
|
|
if (wb_rst_i)
|
574 |
|
|
wb_cab_o <= #1 1'b0;
|
575 |
|
|
else begin wb_cab_o <= wb_cab_o_cml_2;
|
576 |
|
|
wb_cab_o <= #1 biu_cab_i; end
|
577 |
|
|
`else
|
578 |
|
|
assign wb_cab_o = biu_cab_i;
|
579 |
|
|
`endif
|
580 |
|
|
`endif
|
581 |
|
|
|
582 |
|
|
`ifdef OR1200_WB_B3
|
583 |
|
|
//
|
584 |
|
|
// Count burst beats
|
585 |
|
|
//
|
586 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
587 |
|
|
if (wb_rst_i)
|
588 |
|
|
burst_len <= #1 2'b00;
|
589 |
|
|
else if (biu_cab_i && burst_len && wb_ack_i)
|
590 |
|
|
burst_len <= #1 burst_len - 1'b1;
|
591 |
|
|
else if (~biu_cab_i)
|
592 |
|
|
burst_len <= #1 2'b11;
|
593 |
|
|
|
594 |
|
|
//
|
595 |
|
|
// WB cti_o
|
596 |
|
|
//
|
597 |
|
|
`ifdef OR1200_REGISTERED_OUTPUTS
|
598 |
|
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
599 |
|
|
if (wb_rst_i)
|
600 |
|
|
wb_cti_o <= #1 3'b000; // classic cycle
|
601 |
|
|
`ifdef OR1200_NO_BURSTS
|
602 |
|
|
else
|
603 |
|
|
wb_cti_o <= #1 3'b111; // end-of-burst
|
604 |
|
|
`else
|
605 |
|
|
else if (biu_cab_i && burst_len[1])
|
606 |
|
|
wb_cti_o <= #1 3'b010; // incrementing burst cycle
|
607 |
|
|
else if (biu_cab_i && wb_ack_i)
|
608 |
|
|
wb_cti_o <= #1 3'b111; // end-of-burst
|
609 |
|
|
`endif // OR1200_NO_BURSTS
|
610 |
|
|
`else
|
611 |
|
|
Unsupported !!!;
|
612 |
|
|
`endif
|
613 |
|
|
|
614 |
|
|
//
|
615 |
|
|
// WB bte_o
|
616 |
|
|
//
|
617 |
|
|
assign wb_bte_o = 2'b01; // 4-beat wrap burst
|
618 |
|
|
|
619 |
|
|
`endif // OR1200_WB_B3
|
620 |
|
|
|
621 |
|
|
|
622 |
|
|
always @ (posedge clk_i_cml_1) begin
|
623 |
|
|
wb_ack_i_cml_1 <= wb_ack_i;
|
624 |
|
|
wb_err_i_cml_1 <= wb_err_i;
|
625 |
|
|
wb_dat_i_cml_1 <= wb_dat_i;
|
626 |
|
|
wb_cyc_o_cml_1 <= wb_cyc_o;
|
627 |
|
|
wb_adr_o_cml_1 <= wb_adr_o;
|
628 |
|
|
wb_stb_o_cml_1 <= wb_stb_o;
|
629 |
|
|
wb_we_o_cml_1 <= wb_we_o;
|
630 |
|
|
wb_sel_o_cml_1 <= wb_sel_o;
|
631 |
|
|
wb_dat_o_cml_1 <= wb_dat_o;
|
632 |
|
|
wb_cab_o_cml_1 <= wb_cab_o;
|
633 |
|
|
biu_ack_o_cml_1 <= biu_ack_o;
|
634 |
|
|
valid_div_cml_1 <= valid_div;
|
635 |
|
|
aborted_r_cml_1 <= aborted_r;
|
636 |
|
|
previous_complete_cml_1 <= previous_complete;
|
637 |
|
|
repeated_access_ack_cml_1 <= repeated_access_ack;
|
638 |
|
|
wb_dat_r_cml_1 <= wb_dat_r;
|
639 |
|
|
end
|
640 |
|
|
always @ (posedge clk_i_cml_2) begin
|
641 |
|
|
wb_ack_i_cml_2 <= wb_ack_i_cml_1;
|
642 |
|
|
wb_err_i_cml_2 <= wb_err_i_cml_1;
|
643 |
|
|
wb_dat_i_cml_2 <= wb_dat_i_cml_1;
|
644 |
|
|
wb_cyc_o_cml_2 <= wb_cyc_o_cml_1;
|
645 |
|
|
wb_adr_o_cml_2 <= wb_adr_o_cml_1;
|
646 |
|
|
wb_stb_o_cml_2 <= wb_stb_o_cml_1;
|
647 |
|
|
wb_we_o_cml_2 <= wb_we_o_cml_1;
|
648 |
|
|
wb_sel_o_cml_2 <= wb_sel_o_cml_1;
|
649 |
|
|
wb_dat_o_cml_2 <= wb_dat_o_cml_1;
|
650 |
|
|
wb_cab_o_cml_2 <= wb_cab_o_cml_1;
|
651 |
|
|
biu_ack_o_cml_2 <= biu_ack_o_cml_1;
|
652 |
|
|
valid_div_cml_2 <= valid_div_cml_1;
|
653 |
|
|
aborted_r_cml_2 <= aborted_r_cml_1;
|
654 |
|
|
previous_complete_cml_2 <= previous_complete_cml_1;
|
655 |
|
|
repeated_access_ack_cml_2 <= repeated_access_ack_cml_1;
|
656 |
|
|
wb_dat_r_cml_2 <= wb_dat_r_cml_1;
|
657 |
|
|
end
|
658 |
|
|
endmodule
|
659 |
|
|
|