1 |
77 |
mihad |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// File name "wbw_wbr_fifos.v" ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the "PCI bridge" project ////
|
6 |
|
|
//// http://www.opencores.org/cores/pci/ ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Author(s): ////
|
9 |
|
|
//// - Miha Dolenc (mihad@opencores.org) ////
|
10 |
|
|
//// ////
|
11 |
|
|
//// All additional information is avaliable in the README ////
|
12 |
|
|
//// file. ////
|
13 |
|
|
//// ////
|
14 |
|
|
//// ////
|
15 |
|
|
//////////////////////////////////////////////////////////////////////
|
16 |
|
|
//// ////
|
17 |
|
|
//// Copyright (C) 2001 Miha Dolenc, mihad@opencores.org ////
|
18 |
|
|
//// ////
|
19 |
|
|
//// This source file may be used and distributed without ////
|
20 |
|
|
//// restriction provided that this copyright statement is not ////
|
21 |
|
|
//// removed from the file and that any derivative work contains ////
|
22 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
23 |
|
|
//// ////
|
24 |
|
|
//// This source file is free software; you can redistribute it ////
|
25 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
26 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
27 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
28 |
|
|
//// later version. ////
|
29 |
|
|
//// ////
|
30 |
|
|
//// This source is distributed in the hope that it will be ////
|
31 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
32 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
33 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
34 |
|
|
//// details. ////
|
35 |
|
|
//// ////
|
36 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
37 |
|
|
//// Public License along with this source; if not, download it ////
|
38 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
39 |
|
|
//// ////
|
40 |
|
|
//////////////////////////////////////////////////////////////////////
|
41 |
|
|
//
|
42 |
|
|
// CVS Revision History
|
43 |
|
|
//
|
44 |
|
|
// $Log: not supported by cvs2svn $
|
45 |
132 |
mihad |
// Revision 1.5 2003/10/17 09:11:52 markom
|
46 |
|
|
// mbist signals updated according to newest convention
|
47 |
|
|
//
|
48 |
122 |
markom |
// Revision 1.4 2003/08/14 13:06:03 simons
|
49 |
|
|
// synchronizer_flop replaced with pci_synchronizer_flop, artisan ram instance updated.
|
50 |
|
|
//
|
51 |
111 |
simons |
// Revision 1.3 2003/03/26 13:16:18 mihad
|
52 |
|
|
// Added the reset value parameter to the synchronizer flop module.
|
53 |
|
|
// Added resets to all synchronizer flop instances.
|
54 |
|
|
// Repaired initial sync value in fifos.
|
55 |
|
|
//
|
56 |
88 |
mihad |
// Revision 1.2 2003/01/30 22:01:09 mihad
|
57 |
|
|
// Updated synchronization in top level fifo modules.
|
58 |
|
|
//
|
59 |
81 |
mihad |
// Revision 1.1 2003/01/27 16:49:31 mihad
|
60 |
|
|
// Changed module and file names. Updated scripts accordingly. FIFO synchronizations changed.
|
61 |
|
|
//
|
62 |
77 |
mihad |
// Revision 1.9 2002/10/18 03:36:37 tadejm
|
63 |
122 |
markom |
// Changed wrong signal name mbist_sen into mbist_ctrl_i.
|
64 |
77 |
mihad |
//
|
65 |
|
|
// Revision 1.8 2002/10/17 22:49:22 tadejm
|
66 |
|
|
// Changed BIST signals for RAMs.
|
67 |
|
|
//
|
68 |
|
|
// Revision 1.7 2002/10/11 10:09:01 mihad
|
69 |
|
|
// Added additional testcase and changed rst name in BIST to trst
|
70 |
|
|
//
|
71 |
|
|
// Revision 1.6 2002/10/08 17:17:06 mihad
|
72 |
|
|
// Added BIST signals for RAMs.
|
73 |
|
|
//
|
74 |
|
|
// Revision 1.5 2002/09/30 16:03:04 mihad
|
75 |
|
|
// Added meta flop module for easier meta stable FF identification during synthesis
|
76 |
|
|
//
|
77 |
|
|
// Revision 1.4 2002/09/25 15:53:52 mihad
|
78 |
|
|
// Removed all logic from asynchronous reset network
|
79 |
|
|
//
|
80 |
|
|
// Revision 1.3 2002/02/01 15:25:14 mihad
|
81 |
|
|
// Repaired a few bugs, updated specification, added test bench files and design document
|
82 |
|
|
//
|
83 |
|
|
// Revision 1.2 2001/10/05 08:20:12 mihad
|
84 |
|
|
// Updated all files with inclusion of timescale file for simulation purposes.
|
85 |
|
|
//
|
86 |
|
|
// Revision 1.1.1.1 2001/10/02 15:33:47 mihad
|
87 |
|
|
// New project directory structure
|
88 |
|
|
//
|
89 |
|
|
//
|
90 |
|
|
|
91 |
|
|
`include "pci_constants.v"
|
92 |
|
|
|
93 |
|
|
// synopsys translate_off
|
94 |
|
|
`include "timescale.v"
|
95 |
|
|
// synopsys translate_on
|
96 |
|
|
|
97 |
|
|
module pci_wbw_wbr_fifos
|
98 |
|
|
(
|
99 |
|
|
wb_clock_in,
|
100 |
|
|
pci_clock_in,
|
101 |
|
|
reset_in,
|
102 |
|
|
wbw_wenable_in,
|
103 |
|
|
wbw_addr_data_in,
|
104 |
|
|
wbw_cbe_in,
|
105 |
|
|
wbw_control_in,
|
106 |
|
|
wbw_renable_in,
|
107 |
|
|
wbw_addr_data_out,
|
108 |
|
|
wbw_cbe_out,
|
109 |
|
|
wbw_control_out,
|
110 |
|
|
// wbw_flush_in, write fifo flush not used
|
111 |
|
|
wbw_almost_full_out,
|
112 |
|
|
wbw_full_out,
|
113 |
|
|
wbw_empty_out,
|
114 |
|
|
wbw_transaction_ready_out,
|
115 |
|
|
wbr_wenable_in,
|
116 |
|
|
wbr_data_in,
|
117 |
|
|
wbr_be_in,
|
118 |
|
|
wbr_control_in,
|
119 |
|
|
wbr_renable_in,
|
120 |
|
|
wbr_data_out,
|
121 |
|
|
wbr_be_out,
|
122 |
|
|
wbr_control_out,
|
123 |
|
|
wbr_flush_in,
|
124 |
|
|
wbr_empty_out
|
125 |
|
|
|
126 |
|
|
`ifdef PCI_BIST
|
127 |
|
|
,
|
128 |
|
|
// debug chain signals
|
129 |
122 |
markom |
mbist_si_i, // bist scan serial in
|
130 |
|
|
mbist_so_o, // bist scan serial out
|
131 |
|
|
mbist_ctrl_i // bist chain shift control
|
132 |
77 |
mihad |
`endif
|
133 |
|
|
) ;
|
134 |
|
|
|
135 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
136 |
|
|
System inputs:
|
137 |
|
|
wb_clock_in - WISHBONE bus clock
|
138 |
|
|
pci_clock_in - PCI bus clock
|
139 |
|
|
reset_in - reset from control logic
|
140 |
|
|
-------------------------------------------------------------------------------------------------------------*/
|
141 |
|
|
input wb_clock_in, pci_clock_in, reset_in ;
|
142 |
|
|
|
143 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
144 |
|
|
WISHBONE WRITE FIFO interface signals prefixed with wbw_ - FIFO is used for posted writes initiated by
|
145 |
|
|
WISHBONE master, traveling through FIFO and are completed on PCI by PCI master interface
|
146 |
|
|
|
147 |
|
|
write enable signal:
|
148 |
|
|
wbw_wenable_in = write enable input for WBW_FIFO - driven by WISHBONE slave interface
|
149 |
|
|
|
150 |
|
|
data input signals:
|
151 |
|
|
wbw_addr_data_in = data input - data from WISHBONE bus - first entry of transaction is address others are data entries
|
152 |
|
|
wbw_cbe_in = bus command/byte enable(~SEL[3:0]) input - first entry of transaction is bus command, other are byte enables
|
153 |
|
|
wbw_control_in = control input - encoded control bus input
|
154 |
|
|
|
155 |
|
|
read enable signal:
|
156 |
|
|
wbw_renable_in = read enable input driven by PCI master interface
|
157 |
|
|
|
158 |
|
|
data output signals:
|
159 |
|
|
wbw_addr_data_out = data output - data from WISHBONE bus - first entry of transaction is address, others are data entries
|
160 |
|
|
wbw_cbe_out = bus command/byte enable output - first entry of transaction is bus command, others are byte enables
|
161 |
|
|
wbw_control_out = control input - encoded control bus input
|
162 |
|
|
|
163 |
|
|
status signals - monitored by various resources in the core
|
164 |
|
|
wbw_flush_in = flush signal input for WBW_FIFO - when asserted, fifo is flushed(emptied)
|
165 |
|
|
wbw_almost_full_out = almost full output from WBW_FIFO
|
166 |
|
|
wbw_full_out = full output from WBW_FIFO
|
167 |
|
|
wbw_empty_out = empty output from WBW_FIFO
|
168 |
|
|
wbw_transaction_ready_out = output indicating that one complete transaction is waiting in WBW_FIFO
|
169 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
170 |
|
|
// input control and data
|
171 |
|
|
input wbw_wenable_in ;
|
172 |
|
|
input [31:0] wbw_addr_data_in ;
|
173 |
|
|
input [3:0] wbw_cbe_in ;
|
174 |
|
|
input [3:0] wbw_control_in ;
|
175 |
|
|
|
176 |
|
|
// output control and data
|
177 |
|
|
input wbw_renable_in ;
|
178 |
|
|
output [31:0] wbw_addr_data_out ;
|
179 |
|
|
output [3:0] wbw_cbe_out ;
|
180 |
|
|
output [3:0] wbw_control_out ;
|
181 |
|
|
|
182 |
|
|
// flush input
|
183 |
|
|
// input wbw_flush_in ; // not used
|
184 |
|
|
|
185 |
|
|
// status outputs
|
186 |
|
|
output wbw_almost_full_out ;
|
187 |
|
|
output wbw_full_out ;
|
188 |
|
|
output wbw_empty_out ;
|
189 |
|
|
output wbw_transaction_ready_out ;
|
190 |
|
|
|
191 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
192 |
|
|
WISHBONE READ FIFO interface signals prefixed with wbr_ - FIFO is used for holding delayed read completions
|
193 |
|
|
initiated by master on WISHBONE bus and completed on PCI bus,
|
194 |
|
|
|
195 |
|
|
write enable signal:
|
196 |
|
|
wbr_wenable_in = write enable input for WBR_FIFO - driven by PCI master interface
|
197 |
|
|
|
198 |
|
|
data input signals:
|
199 |
|
|
wbr_data_in = data input - data from PCI bus - there is no address entry here, since address is stored in separate register
|
200 |
|
|
wbr_be_in = byte enable(~BE#[3:0]) input - byte enables - same through one transaction
|
201 |
|
|
wbr_control_in = control input - encoded control bus input
|
202 |
|
|
|
203 |
|
|
read enable signal:
|
204 |
|
|
wbr_renable_in = read enable input driven by WISHBONE slave interface
|
205 |
|
|
|
206 |
|
|
data output signals:
|
207 |
|
|
wbr_data_out = data output - data from PCI bus
|
208 |
|
|
wbr_be_out = byte enable output(~#BE)
|
209 |
|
|
wbr_control_out = control output - encoded control bus output
|
210 |
|
|
|
211 |
|
|
status signals - monitored by various resources in the core
|
212 |
|
|
wbr_flush_in = flush signal input for WBR_FIFO - when asserted, fifo is flushed(emptied)
|
213 |
|
|
wbr full_out = full output from WBR_FIFO
|
214 |
|
|
wbr_empty_out = empty output from WBR_FIFO
|
215 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
216 |
|
|
// input control and data
|
217 |
|
|
input wbr_wenable_in ;
|
218 |
|
|
input [31:0] wbr_data_in ;
|
219 |
|
|
input [3:0] wbr_be_in ;
|
220 |
|
|
input [3:0] wbr_control_in ;
|
221 |
|
|
|
222 |
|
|
// output control and data
|
223 |
|
|
input wbr_renable_in ;
|
224 |
|
|
output [31:0] wbr_data_out ;
|
225 |
|
|
output [3:0] wbr_be_out ;
|
226 |
|
|
output [3:0] wbr_control_out ;
|
227 |
|
|
|
228 |
|
|
// flush input
|
229 |
|
|
input wbr_flush_in ;
|
230 |
|
|
|
231 |
|
|
output wbr_empty_out ;
|
232 |
|
|
|
233 |
|
|
`ifdef PCI_BIST
|
234 |
|
|
/*-----------------------------------------------------
|
235 |
|
|
BIST debug chain port signals
|
236 |
|
|
-----------------------------------------------------*/
|
237 |
122 |
markom |
input mbist_si_i; // bist scan serial in
|
238 |
|
|
output mbist_so_o; // bist scan serial out
|
239 |
|
|
input [`PCI_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i; // bist chain shift control
|
240 |
77 |
mihad |
`endif
|
241 |
|
|
|
242 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
243 |
|
|
FIFO depth parameters:
|
244 |
|
|
WBW_DEPTH = defines WBW_FIFO depth
|
245 |
|
|
WBR_DEPTH = defines WBR_FIFO depth
|
246 |
|
|
WBW_ADDR_LENGTH = defines WBW_FIFO's location address length = log2(WBW_DEPTH)
|
247 |
|
|
WBR_ADDR_LENGTH = defines WBR_FIFO's location address length = log2(WBR_DEPTH)
|
248 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
249 |
|
|
parameter WBW_DEPTH = `WBW_DEPTH ;
|
250 |
|
|
parameter WBW_ADDR_LENGTH = `WBW_ADDR_LENGTH ;
|
251 |
|
|
parameter WBR_DEPTH = `WBR_DEPTH ;
|
252 |
|
|
parameter WBR_ADDR_LENGTH = `WBR_ADDR_LENGTH ;
|
253 |
|
|
|
254 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
255 |
|
|
wbw_wallow = WBW_FIFO write allow wire - writes to FIFO are allowed when FIFO isn't full and write enable is 1
|
256 |
|
|
wbw_rallow = WBW_FIFO read allow wire - reads from FIFO are allowed when FIFO isn't empty and read enable is 1
|
257 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
258 |
|
|
wire wbw_wallow ;
|
259 |
|
|
wire wbw_rallow ;
|
260 |
|
|
|
261 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
262 |
|
|
wbr_wallow = WBR_FIFO write allow wire - writes to FIFO are allowed when FIFO isn't full and write enable is 1
|
263 |
|
|
wbr_rallow = WBR_FIFO read allow wire - reads from FIFO are allowed when FIFO isn't empty and read enable is 1
|
264 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
265 |
|
|
wire wbr_wallow ;
|
266 |
|
|
wire wbr_rallow ;
|
267 |
|
|
|
268 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
269 |
|
|
wires for address port conections from WBW_FIFO control logic to RAM blocks used for WBW_FIFO
|
270 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
271 |
|
|
wire [(WBW_ADDR_LENGTH - 1):0] wbw_raddr ;
|
272 |
|
|
wire [(WBW_ADDR_LENGTH - 1):0] wbw_waddr ;
|
273 |
|
|
|
274 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
275 |
|
|
wires for address port conections from WBR_FIFO control logic to RAM blocks used for WBR_FIFO
|
276 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
277 |
|
|
wire [(WBR_ADDR_LENGTH - 1):0] wbr_raddr ;
|
278 |
|
|
wire [(WBR_ADDR_LENGTH - 1):0] wbr_waddr ;
|
279 |
|
|
|
280 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
281 |
|
|
WBW_FIFO transaction counters: used to count incoming transactions and outgoing transactions. When number of
|
282 |
|
|
input transactions is equal to number of output transactions, it means that there isn't any complete transaction
|
283 |
|
|
currently present in the FIFO.
|
284 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
285 |
|
|
reg [(WBW_ADDR_LENGTH - 2):0] wbw_inTransactionCount ;
|
286 |
|
|
reg [(WBW_ADDR_LENGTH - 2):0] wbw_outTransactionCount ;
|
287 |
|
|
|
288 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
289 |
|
|
wires monitoring control bus. When control bus on a write transaction has a value of `LAST, it means that
|
290 |
|
|
complete transaction is in the FIFO. When control bus on a read transaction has a value of `LAST,
|
291 |
|
|
it means that there was one complete transaction taken out of FIFO.
|
292 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
293 |
|
|
wire wbw_last_in = wbw_control_in[`LAST_CTRL_BIT] ;
|
294 |
|
|
wire wbw_last_out = wbw_control_out[`LAST_CTRL_BIT] ;
|
295 |
|
|
|
296 |
|
|
wire wbw_empty ;
|
297 |
|
|
wire wbr_empty ;
|
298 |
|
|
|
299 |
|
|
assign wbw_empty_out = wbw_empty ;
|
300 |
|
|
assign wbr_empty_out = wbr_empty ;
|
301 |
|
|
|
302 |
|
|
// clear wires for fifos
|
303 |
|
|
wire wbw_clear = reset_in /*|| wbw_flush_in*/ ; // WBW_FIFO clear flush not used
|
304 |
|
|
wire wbr_clear = reset_in /*|| wbr_flush_in*/ ; // WBR_FIFO clear - flush changed from asynchronous to synchronous
|
305 |
|
|
|
306 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
307 |
|
|
Definitions of wires for connecting RAM instances
|
308 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
309 |
|
|
wire [39:0] dpram_portA_output ;
|
310 |
|
|
wire [39:0] dpram_portB_output ;
|
311 |
|
|
|
312 |
|
|
wire [39:0] dpram_portA_input = {wbw_control_in, wbw_cbe_in, wbw_addr_data_in} ;
|
313 |
|
|
wire [39:0] dpram_portB_input = {wbr_control_in, wbr_be_in, wbr_data_in} ;
|
314 |
|
|
|
315 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
316 |
|
|
Fifo output assignments - each ram port provides data for different fifo
|
317 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
318 |
|
|
assign wbw_control_out = dpram_portB_output[39:36] ;
|
319 |
|
|
assign wbr_control_out = dpram_portA_output[39:36] ;
|
320 |
|
|
|
321 |
|
|
assign wbw_cbe_out = dpram_portB_output[35:32] ;
|
322 |
|
|
assign wbr_be_out = dpram_portA_output[35:32] ;
|
323 |
|
|
|
324 |
|
|
assign wbw_addr_data_out = dpram_portB_output[31:0] ;
|
325 |
|
|
assign wbr_data_out = dpram_portA_output[31:0] ;
|
326 |
|
|
|
327 |
|
|
`ifdef WB_RAM_DONT_SHARE
|
328 |
|
|
|
329 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
330 |
|
|
Piece of code in this ifdef section is used in applications which can provide enough RAM instances to
|
331 |
|
|
accomodate four fifos - each occupying its own instance of ram. Ports are connected in such a way,
|
332 |
|
|
that instances of RAMs can be changed from two port to dual port ( async read/write port ). In that case,
|
333 |
|
|
write port is always port a and read port is port b.
|
334 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
335 |
|
|
|
336 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
337 |
|
|
Pad redundant address lines with zeros. This may seem stupid, but it comes in perfect for FPGA impl.
|
338 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
339 |
|
|
/*
|
340 |
|
|
wire [(`WBW_FIFO_RAM_ADDR_LENGTH - WBW_ADDR_LENGTH - 1):0] wbw_addr_prefix = {( `WBW_FIFO_RAM_ADDR_LENGTH - WBW_ADDR_LENGTH){1'b0}} ;
|
341 |
|
|
wire [(`WBR_FIFO_RAM_ADDR_LENGTH - WBR_ADDR_LENGTH - 1):0] wbr_addr_prefix = {( `WBR_FIFO_RAM_ADDR_LENGTH - WBR_ADDR_LENGTH){1'b0}} ;
|
342 |
|
|
*/
|
343 |
|
|
|
344 |
|
|
// compose complete port addresses
|
345 |
|
|
wire [(`WB_FIFO_RAM_ADDR_LENGTH-1):0] wbw_whole_waddr = wbw_waddr ;
|
346 |
|
|
wire [(`WB_FIFO_RAM_ADDR_LENGTH-1):0] wbw_whole_raddr = wbw_raddr ;
|
347 |
|
|
|
348 |
|
|
wire [(`WB_FIFO_RAM_ADDR_LENGTH-1):0] wbr_whole_waddr = wbr_waddr ;
|
349 |
|
|
wire [(`WB_FIFO_RAM_ADDR_LENGTH-1):0] wbr_whole_raddr = wbr_raddr ;
|
350 |
|
|
|
351 |
|
|
wire wbw_read_enable = 1'b1 ;
|
352 |
|
|
wire wbr_read_enable = 1'b1 ;
|
353 |
|
|
|
354 |
|
|
`ifdef PCI_BIST
|
355 |
122 |
markom |
wire mbist_so_o_internal ; // wires for connection of debug ports on two rams
|
356 |
|
|
wire mbist_si_i_internal = mbist_so_o_internal ;
|
357 |
77 |
mihad |
`endif
|
358 |
|
|
|
359 |
|
|
// instantiate and connect two generic rams - one for wishbone write fifo and one for wishbone read fifo
|
360 |
|
|
pci_wb_tpram #(`WB_FIFO_RAM_ADDR_LENGTH, 40) wbw_fifo_storage
|
361 |
|
|
(
|
362 |
|
|
// Generic synchronous two-port RAM interface
|
363 |
|
|
.clk_a(wb_clock_in),
|
364 |
|
|
.rst_a(reset_in),
|
365 |
|
|
.ce_a(1'b1),
|
366 |
|
|
.we_a(wbw_wallow),
|
367 |
|
|
.oe_a(1'b1),
|
368 |
|
|
.addr_a(wbw_whole_waddr),
|
369 |
|
|
.di_a(dpram_portA_input),
|
370 |
|
|
.do_a(),
|
371 |
|
|
|
372 |
|
|
.clk_b(pci_clock_in),
|
373 |
|
|
.rst_b(reset_in),
|
374 |
|
|
.ce_b(wbw_read_enable),
|
375 |
|
|
.we_b(1'b0),
|
376 |
|
|
.oe_b(1'b1),
|
377 |
|
|
.addr_b(wbw_whole_raddr),
|
378 |
|
|
.di_b(40'h00_0000_0000),
|
379 |
|
|
.do_b(dpram_portB_output)
|
380 |
|
|
|
381 |
|
|
`ifdef PCI_BIST
|
382 |
|
|
,
|
383 |
122 |
markom |
.mbist_si_i (mbist_si_i),
|
384 |
|
|
.mbist_so_o (mbist_so_o_internal),
|
385 |
|
|
.mbist_ctrl_i (mbist_ctrl_i)
|
386 |
77 |
mihad |
`endif
|
387 |
|
|
);
|
388 |
|
|
|
389 |
|
|
pci_wb_tpram #(`WB_FIFO_RAM_ADDR_LENGTH, 40) wbr_fifo_storage
|
390 |
|
|
(
|
391 |
|
|
// Generic synchronous two-port RAM interface
|
392 |
|
|
.clk_a(pci_clock_in),
|
393 |
|
|
.rst_a(reset_in),
|
394 |
|
|
.ce_a(1'b1),
|
395 |
|
|
.we_a(wbr_wallow),
|
396 |
|
|
.oe_a(1'b1),
|
397 |
|
|
.addr_a(wbr_whole_waddr),
|
398 |
|
|
.di_a(dpram_portB_input),
|
399 |
|
|
.do_a(),
|
400 |
|
|
|
401 |
|
|
.clk_b(wb_clock_in),
|
402 |
|
|
.rst_b(reset_in),
|
403 |
|
|
.ce_b(wbr_read_enable),
|
404 |
|
|
.we_b(1'b0),
|
405 |
|
|
.oe_b(1'b1),
|
406 |
|
|
.addr_b(wbr_whole_raddr),
|
407 |
|
|
.di_b(40'h00_0000_0000),
|
408 |
|
|
.do_b(dpram_portA_output)
|
409 |
|
|
|
410 |
|
|
`ifdef PCI_BIST
|
411 |
|
|
,
|
412 |
122 |
markom |
.mbist_si_i (mbist_si_i_internal),
|
413 |
|
|
.mbist_so_o (mbist_so_o),
|
414 |
|
|
.mbist_ctrl_i (mbist_ctrl_i)
|
415 |
77 |
mihad |
`endif
|
416 |
|
|
);
|
417 |
|
|
|
418 |
|
|
`else // RAM blocks sharing between two fifos
|
419 |
|
|
|
420 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
421 |
|
|
Code section under this ifdef is used for implementation where RAM instances are too expensive. In this
|
422 |
|
|
case one RAM instance is used for both - WISHBONE read and WISHBONE write fifo.
|
423 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
424 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
425 |
|
|
Address prefix definition - since both FIFOs reside in same RAM instance, storage is separated by MSB
|
426 |
|
|
addresses. WISHBONE write fifo addresses are padded with zeros on the MSB side ( at least one address line
|
427 |
|
|
must be used for this ), WISHBONE read fifo addresses are padded with ones on the right ( at least one ).
|
428 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
429 |
|
|
wire [(`WB_FIFO_RAM_ADDR_LENGTH - WBW_ADDR_LENGTH - 1):0] wbw_addr_prefix = {( `WB_FIFO_RAM_ADDR_LENGTH - WBW_ADDR_LENGTH){1'b0}} ;
|
430 |
|
|
wire [(`WB_FIFO_RAM_ADDR_LENGTH - WBR_ADDR_LENGTH - 1):0] wbr_addr_prefix = {( `WB_FIFO_RAM_ADDR_LENGTH - WBR_ADDR_LENGTH){1'b1}} ;
|
431 |
|
|
|
432 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
433 |
|
|
Port A address generation for RAM instance. RAM instance must be full two port RAM - read and write capability
|
434 |
|
|
on both sides.
|
435 |
|
|
Port A is clocked by WISHBONE clock, DIA is input for wbw_fifo, DOA is output for wbr_fifo.
|
436 |
|
|
Address is multiplexed so operation can be switched between fifos. Default is a read on port.
|
437 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
438 |
|
|
wire [(`WB_FIFO_RAM_ADDR_LENGTH-1):0] portA_addr = wbw_wallow ? {wbw_addr_prefix, wbw_waddr} : {wbr_addr_prefix, wbr_raddr} ;
|
439 |
|
|
|
440 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
441 |
|
|
Port B is clocked by PCI clock, DIB is input for wbr_fifo, DOB is output for wbw_fifo.
|
442 |
|
|
Address is multiplexed so operation can be switched between fifos. Default is a read on port.
|
443 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
444 |
|
|
wire [(`WB_FIFO_RAM_ADDR_LENGTH-1):0] portB_addr = wbr_wallow ? {wbr_addr_prefix, wbr_waddr} : {wbw_addr_prefix, wbw_raddr} ;
|
445 |
|
|
|
446 |
|
|
wire portA_enable = 1'b1 ;
|
447 |
|
|
|
448 |
|
|
wire portB_enable = 1'b1 ;
|
449 |
|
|
|
450 |
|
|
// instantiate RAM for these two fifos
|
451 |
|
|
pci_wb_tpram #(`WB_FIFO_RAM_ADDR_LENGTH, 40) wbu_fifo_storage
|
452 |
|
|
(
|
453 |
|
|
// Generic synchronous two-port RAM interface
|
454 |
|
|
.clk_a(wb_clock_in),
|
455 |
|
|
.rst_a(reset_in),
|
456 |
|
|
.ce_a(portA_enable),
|
457 |
|
|
.we_a(wbw_wallow),
|
458 |
|
|
.oe_a(1'b1),
|
459 |
|
|
.addr_a(portA_addr),
|
460 |
|
|
.di_a(dpram_portA_input),
|
461 |
|
|
.do_a(dpram_portA_output),
|
462 |
|
|
.clk_b(pci_clock_in),
|
463 |
|
|
.rst_b(reset_in),
|
464 |
|
|
.ce_b(portB_enable),
|
465 |
|
|
.we_b(wbr_wallow),
|
466 |
|
|
.oe_b(1'b1),
|
467 |
|
|
.addr_b(portB_addr),
|
468 |
|
|
.di_b(dpram_portB_input),
|
469 |
|
|
.do_b(dpram_portB_output)
|
470 |
|
|
|
471 |
|
|
`ifdef PCI_BIST
|
472 |
|
|
,
|
473 |
122 |
markom |
.mbist_si_i (mbist_si_i),
|
474 |
|
|
.mbist_so_o (mbist_so_o),
|
475 |
|
|
.mbist_ctrl_i (mbist_ctrl_i)
|
476 |
77 |
mihad |
`endif
|
477 |
|
|
);
|
478 |
|
|
|
479 |
|
|
`endif
|
480 |
|
|
|
481 |
|
|
/*-----------------------------------------------------------------------------------------------------------
|
482 |
|
|
Instantiation of two control logic modules - one for WBW_FIFO and one for WBR_FIFO
|
483 |
|
|
-----------------------------------------------------------------------------------------------------------*/
|
484 |
|
|
pci_wbw_fifo_control #(WBW_ADDR_LENGTH) wbw_fifo_ctrl
|
485 |
|
|
(
|
486 |
|
|
.rclock_in(pci_clock_in),
|
487 |
|
|
.wclock_in(wb_clock_in),
|
488 |
|
|
.renable_in(wbw_renable_in),
|
489 |
|
|
.wenable_in(wbw_wenable_in),
|
490 |
|
|
.reset_in(reset_in),
|
491 |
|
|
// .flush_in(wbw_flush_in),
|
492 |
|
|
.almost_full_out(wbw_almost_full_out),
|
493 |
|
|
.full_out(wbw_full_out),
|
494 |
|
|
.empty_out(wbw_empty),
|
495 |
|
|
.waddr_out(wbw_waddr),
|
496 |
|
|
.raddr_out(wbw_raddr),
|
497 |
|
|
.rallow_out(wbw_rallow),
|
498 |
|
|
.wallow_out(wbw_wallow)
|
499 |
|
|
);
|
500 |
|
|
|
501 |
|
|
pci_wbr_fifo_control #(WBR_ADDR_LENGTH) wbr_fifo_ctrl
|
502 |
|
|
( .rclock_in(wb_clock_in),
|
503 |
|
|
.wclock_in(pci_clock_in),
|
504 |
|
|
.renable_in(wbr_renable_in),
|
505 |
|
|
.wenable_in(wbr_wenable_in),
|
506 |
|
|
.reset_in(reset_in),
|
507 |
|
|
.flush_in(wbr_flush_in),
|
508 |
|
|
.empty_out(wbr_empty),
|
509 |
|
|
.waddr_out(wbr_waddr),
|
510 |
|
|
.raddr_out(wbr_raddr),
|
511 |
|
|
.rallow_out(wbr_rallow),
|
512 |
|
|
.wallow_out(wbr_wallow)
|
513 |
|
|
);
|
514 |
|
|
|
515 |
|
|
|
516 |
|
|
// in and out transaction counters and grey codes
|
517 |
|
|
reg [(WBW_ADDR_LENGTH-2):0] inGreyCount ;
|
518 |
|
|
reg [(WBW_ADDR_LENGTH-2):0] outGreyCount ;
|
519 |
|
|
wire [(WBW_ADDR_LENGTH-2):0] inNextGreyCount = {wbw_inTransactionCount[(WBW_ADDR_LENGTH-2)], wbw_inTransactionCount[(WBW_ADDR_LENGTH-2):1] ^ wbw_inTransactionCount[(WBW_ADDR_LENGTH-3):0]} ;
|
520 |
|
|
wire [(WBW_ADDR_LENGTH-2):0] outNextGreyCount = {wbw_outTransactionCount[(WBW_ADDR_LENGTH-2)], wbw_outTransactionCount[(WBW_ADDR_LENGTH-2):1] ^ wbw_outTransactionCount[(WBW_ADDR_LENGTH-3):0]} ;
|
521 |
|
|
|
522 |
|
|
// input transaction counter increment - when last data of transaction is written to fifo
|
523 |
|
|
wire in_count_en = wbw_wallow && wbw_last_in ;
|
524 |
|
|
|
525 |
|
|
// output transaction counter increment - when last data is on top of fifo and read from it
|
526 |
|
|
wire out_count_en = wbw_renable_in && wbw_last_out ;
|
527 |
|
|
|
528 |
|
|
// register holding grey coded count of incoming transactions
|
529 |
|
|
always@(posedge wb_clock_in or posedge wbw_clear)
|
530 |
|
|
begin
|
531 |
|
|
if (wbw_clear)
|
532 |
|
|
begin
|
533 |
132 |
mihad |
inGreyCount <= #3 0 ;
|
534 |
77 |
mihad |
end
|
535 |
|
|
else
|
536 |
|
|
if (in_count_en)
|
537 |
132 |
mihad |
inGreyCount <= #3 inNextGreyCount ;
|
538 |
77 |
mihad |
end
|
539 |
|
|
|
540 |
81 |
mihad |
wire [(WBW_ADDR_LENGTH-2):0] pci_clk_sync_inGreyCount ;
|
541 |
|
|
reg [(WBW_ADDR_LENGTH-2):0] pci_clk_inGreyCount ;
|
542 |
111 |
simons |
pci_synchronizer_flop #((WBW_ADDR_LENGTH - 1), 0) i_synchronizer_reg_inGreyCount
|
543 |
81 |
mihad |
(
|
544 |
|
|
.data_in (inGreyCount),
|
545 |
|
|
.clk_out (pci_clock_in),
|
546 |
|
|
.sync_data_out (pci_clk_sync_inGreyCount),
|
547 |
88 |
mihad |
.async_reset (wbw_clear)
|
548 |
81 |
mihad |
) ;
|
549 |
|
|
|
550 |
|
|
always@(posedge pci_clock_in or posedge wbw_clear)
|
551 |
|
|
begin
|
552 |
|
|
if (wbw_clear)
|
553 |
88 |
mihad |
pci_clk_inGreyCount <= #`FF_DELAY 0 ;
|
554 |
81 |
mihad |
else
|
555 |
|
|
pci_clk_inGreyCount <= # `FF_DELAY pci_clk_sync_inGreyCount ;
|
556 |
|
|
end
|
557 |
|
|
|
558 |
77 |
mihad |
// register holding grey coded count of outgoing transactions
|
559 |
|
|
always@(posedge pci_clock_in or posedge wbw_clear)
|
560 |
|
|
begin
|
561 |
|
|
if (wbw_clear)
|
562 |
|
|
begin
|
563 |
88 |
mihad |
outGreyCount <= #`FF_DELAY 0 ;
|
564 |
77 |
mihad |
end
|
565 |
|
|
else
|
566 |
|
|
if (out_count_en)
|
567 |
|
|
outGreyCount <= #`FF_DELAY outNextGreyCount ;
|
568 |
|
|
end
|
569 |
|
|
|
570 |
|
|
// incoming transactions counter
|
571 |
|
|
always@(posedge wb_clock_in or posedge wbw_clear)
|
572 |
|
|
begin
|
573 |
|
|
if (wbw_clear)
|
574 |
88 |
mihad |
wbw_inTransactionCount <= #`FF_DELAY 1 ;
|
575 |
77 |
mihad |
else
|
576 |
|
|
if (in_count_en)
|
577 |
|
|
wbw_inTransactionCount <= #`FF_DELAY wbw_inTransactionCount + 1'b1 ;
|
578 |
|
|
end
|
579 |
|
|
|
580 |
|
|
// outgoing transactions counter
|
581 |
|
|
always@(posedge pci_clock_in or posedge wbw_clear)
|
582 |
|
|
begin
|
583 |
|
|
if (wbw_clear)
|
584 |
88 |
mihad |
wbw_outTransactionCount <= 1 ;
|
585 |
77 |
mihad |
else
|
586 |
|
|
if (out_count_en)
|
587 |
|
|
wbw_outTransactionCount <= #`FF_DELAY wbw_outTransactionCount + 1'b1 ;
|
588 |
|
|
end
|
589 |
|
|
|
590 |
81 |
mihad |
assign wbw_transaction_ready_out = pci_clk_inGreyCount != outGreyCount ;
|
591 |
77 |
mihad |
|
592 |
|
|
endmodule
|
593 |
|
|
|