]> cvs.zerfleddert.de Git - raggedstone/blame - ethernet/source/pci/pci_pciw_pcir_fifos.v
white space; fixme
[raggedstone] / ethernet / source / pci / pci_pciw_pcir_fifos.v
CommitLineData
40a1f26c 1//////////////////////////////////////////////////////////////////////
2//// ////
3//// File name "pciw_pcir_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) 2000 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: pci_pciw_pcir_fifos.v,v $
45// Revision 1.1 2007-03-20 17:50:56 sithglan
46// add shit
47//
48// Revision 1.6 2003/10/17 09:11:52 markom
49// mbist signals updated according to newest convention
50//
51// Revision 1.5 2003/08/14 13:06:03 simons
52// synchronizer_flop replaced with pci_synchronizer_flop, artisan ram instance updated.
53//
54// Revision 1.4 2003/08/08 16:36:33 tadejm
55// Added 'three_left_out' to pci_pciw_fifo signaling three locations before full. Added comparison between current registered cbe and next unregistered cbe to signal wb_master whether it is allowed to performe burst or not. Due to this, I needed 'three_left_out' so that writing to pci_pciw_fifo can be registered, otherwise timing problems would occure.
56//
57// Revision 1.3 2003/03/26 13:16:18 mihad
58// Added the reset value parameter to the synchronizer flop module.
59// Added resets to all synchronizer flop instances.
60// Repaired initial sync value in fifos.
61//
62// Revision 1.2 2003/01/30 22:01:08 mihad
63// Updated synchronization in top level fifo modules.
64//
65// Revision 1.1 2003/01/27 16:49:31 mihad
66// Changed module and file names. Updated scripts accordingly. FIFO synchronizations changed.
67//
68// Revision 1.10 2002/10/18 03:36:37 tadejm
69// Changed wrong signal name mbist_sen into mbist_ctrl_i.
70//
71// Revision 1.9 2002/10/17 22:51:08 tadejm
72// Changed BIST signals for RAMs.
73//
74// Revision 1.8 2002/10/11 10:09:01 mihad
75// Added additional testcase and changed rst name in BIST to trst
76//
77// Revision 1.7 2002/10/08 17:17:06 mihad
78// Added BIST signals for RAMs.
79//
80// Revision 1.6 2002/09/30 16:03:04 mihad
81// Added meta flop module for easier meta stable FF identification during synthesis
82//
83// Revision 1.5 2002/09/25 15:53:52 mihad
84// Removed all logic from asynchronous reset network
85//
86// Revision 1.4 2002/03/05 11:53:47 mihad
87// Added some testcases, removed un-needed fifo signals
88//
89// Revision 1.3 2002/02/01 15:25:13 mihad
90// Repaired a few bugs, updated specification, added test bench files and design document
91//
92// Revision 1.2 2001/10/05 08:14:30 mihad
93// Updated all files with inclusion of timescale file for simulation purposes.
94//
95// Revision 1.1.1.1 2001/10/02 15:33:47 mihad
96// New project directory structure
97//
98//
99
100`include "pci_constants.v"
101
102// synopsys translate_off
103`include "timescale.v"
104// synopsys translate_on
105
106module pci_pciw_pcir_fifos
107(
108 wb_clock_in,
109 pci_clock_in,
110 reset_in,
111 pciw_wenable_in,
112 pciw_addr_data_in,
113 pciw_cbe_in,
114 pciw_control_in,
115 pciw_renable_in,
116 pciw_addr_data_out,
117 pciw_cbe_out,
118 pciw_control_out,
119// pciw_flush_in, // not used
120 pciw_three_left_out,
121 pciw_two_left_out,
122 pciw_almost_full_out,
123 pciw_full_out,
124 pciw_almost_empty_out,
125 pciw_empty_out,
126 pciw_transaction_ready_out,
127 pcir_wenable_in,
128 pcir_data_in,
129 pcir_be_in,
130 pcir_control_in,
131 pcir_renable_in,
132 pcir_data_out,
133 pcir_be_out,
134 pcir_control_out,
135 pcir_flush_in,
136 pcir_full_out,
137 pcir_almost_empty_out,
138 pcir_empty_out,
139 pcir_transaction_ready_out
140
141`ifdef PCI_BIST
142 ,
143 // debug chain signals
144 mbist_si_i, // bist scan serial in
145 mbist_so_o, // bist scan serial out
146 mbist_ctrl_i // bist chain shift control
147`endif
148) ;
149
150/*-----------------------------------------------------------------------------------------------------------
151System inputs:
152wb_clock_in - WISHBONE bus clock
153pci_clock_in - PCI bus clock
154reset_in - reset from control logic
155-------------------------------------------------------------------------------------------------------------*/
156input wb_clock_in, pci_clock_in, reset_in ;
157
158/*-----------------------------------------------------------------------------------------------------------
159PCI WRITE FIFO interface signals prefixed with pciw_ - FIFO is used for posted writes initiated by external
160PCI master through PCI target interface, traveling through FIFO and are completed on WISHBONE by
161WISHBONE master interface
162
163write enable signal:
164pciw_wenable_in = write enable input for PCIW_FIFO - driven by PCI TARGET interface
165
166data input signals:
167pciw_addr_data_in = data input - data from PCI bus - first entry of transaction is address others are data entries
168pciw_cbe_in = bus command/byte enable(~#BE[3:0]) input - first entry of transaction is bus command, other are byte enables
169pciw_control_in = control input - encoded control bus input
170
171read enable signal:
172pciw_renable_in = read enable input driven by WISHBONE master interface
173
174data output signals:
175pciw_addr_data_out = data output - data from PCI bus - first entry of transaction is address, others are data entries
176pciw_cbe_out = bus command/byte enable output - first entry of transaction is bus command, others are byte enables
177pciw_control_out = control input - encoded control bus input
178
179status signals - monitored by various resources in the core
180pciw_flush_in = flush signal input for PCIW_FIFO - when asserted, fifo is flushed(emptied)
181pciw_almost_full_out = almost full output from PCIW_FIFO
182pciw_full_out = full output from PCIW_FIFO
183pciw_almost_empty_out = almost empty output from PCIW_FIFO
184pciw_empty_out = empty output from PCIW_FIFO
185pciw_transaction_ready_out = output indicating that one complete transaction is waiting in PCIW_FIFO
186-----------------------------------------------------------------------------------------------------------*/
187// input control and data
188input pciw_wenable_in ;
189input [31:0] pciw_addr_data_in ;
190input [3:0] pciw_cbe_in ;
191input [3:0] pciw_control_in ;
192
193// output control and data
194input pciw_renable_in ;
195output [31:0] pciw_addr_data_out ;
196output [3:0] pciw_cbe_out ;
197output [3:0] pciw_control_out ;
198
199// flush input
200//input pciw_flush_in ; // not used
201
202// status outputs
203output pciw_three_left_out ;
204output pciw_two_left_out ;
205output pciw_almost_full_out ;
206output pciw_full_out ;
207output pciw_almost_empty_out ;
208output pciw_empty_out ;
209output pciw_transaction_ready_out ;
210
211/*-----------------------------------------------------------------------------------------------------------
212PCI READ FIFO interface signals prefixed with pcir_ - FIFO is used for holding delayed read completions
213initiated by master on PCI bus and completed on WISHBONE bus,
214
215write enable signal:
216pcir_wenable_in = write enable input for PCIR_FIFO - driven by WISHBONE master interface
217
218data input signals:
219pcir_data_in = data input - data from WISHBONE bus - there is no address entry here, since address is stored in separate register
220pcir_be_in = byte enable(~SEL[3:0]) input - byte enables - same through one transaction
221pcir_control_in = control input - encoded control bus input
222
223read enable signal:
224pcir_renable_in = read enable input driven by PCI target interface
225
226data output signals:
227pcir_data_out = data output - data from WISHBONE bus
228pcir_be_out = byte enable output(~SEL)
229pcir_control_out = control output - encoded control bus output
230
231status signals - monitored by various resources in the core
232pcir_flush_in = flush signal input for PCIR_FIFO - when asserted, fifo is flushed(emptied)
233pcir full_out = full output from PCIR_FIFO
234pcir_almost_empty_out = almost empty output from PCIR_FIFO
235pcir_empty_out = empty output from PCIR_FIFO
236pcir_transaction_ready_out = output indicating that one complete transaction is waiting in PCIR_FIFO
237-----------------------------------------------------------------------------------------------------------*/
238// input control and data
239input pcir_wenable_in ;
240input [31:0] pcir_data_in ;
241input [3:0] pcir_be_in ;
242input [3:0] pcir_control_in ;
243
244// output control and data
245input pcir_renable_in ;
246output [31:0] pcir_data_out ;
247output [3:0] pcir_be_out ;
248output [3:0] pcir_control_out ;
249
250// flush input
251input pcir_flush_in ;
252
253// status outputs
254output pcir_full_out ;
255output pcir_almost_empty_out ;
256output pcir_empty_out ;
257output pcir_transaction_ready_out ;
258
259`ifdef PCI_BIST
260/*-----------------------------------------------------
261BIST debug chain port signals
262-----------------------------------------------------*/
263input mbist_si_i; // bist scan serial in
264output mbist_so_o; // bist scan serial out
265input [`PCI_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i; // bist chain shift control
266`endif
267
268/*-----------------------------------------------------------------------------------------------------------
269Address length parameters:
270PCIW_DEPTH = defines PCIW_FIFO depth
271PCIR_DEPTH = defines PCIR_FIFO depth
272PCIW_ADDR_LENGTH = defines PCIW_FIFO's location address length - log2(PCIW_DEPTH)
273PCIR_ADDR_LENGTH = defines PCIR_FIFO's location address length - log2(PCIR_DEPTH)
274-----------------------------------------------------------------------------------------------------------*/
275parameter PCIW_DEPTH = `PCIW_DEPTH ;
276parameter PCIW_ADDR_LENGTH = `PCIW_ADDR_LENGTH ;
277parameter PCIR_DEPTH = `PCIR_DEPTH ;
278parameter PCIR_ADDR_LENGTH = `PCIR_ADDR_LENGTH ;
279
280/*-----------------------------------------------------------------------------------------------------------
281pciw_wallow = PCIW_FIFO write allow wire - writes to FIFO are allowed when FIFO isn't full and write enable is 1
282pciw_rallow = PCIW_FIFO read allow wire - reads from FIFO are allowed when FIFO isn't empty and read enable is 1
283-----------------------------------------------------------------------------------------------------------*/
284wire pciw_wallow ;
285wire pciw_rallow ;
286
287/*-----------------------------------------------------------------------------------------------------------
288pcir_wallow = PCIR_FIFO write allow wire - writes to FIFO are allowed when FIFO isn't full and write enable is 1
289pcir_rallow = PCIR_FIFO read allow wire - reads from FIFO are allowed when FIFO isn't empty and read enable is 1
290-----------------------------------------------------------------------------------------------------------*/
291wire pcir_wallow ;
292wire pcir_rallow ;
293
294/*-----------------------------------------------------------------------------------------------------------
295wires for address port conections from PCIW_FIFO control logic to RAM blocks used for PCIW_FIFO
296-----------------------------------------------------------------------------------------------------------*/
297wire [(PCIW_ADDR_LENGTH - 1):0] pciw_raddr ;
298wire [(PCIW_ADDR_LENGTH - 1):0] pciw_waddr ;
299
300/*-----------------------------------------------------------------------------------------------------------
301wires for address port conections from PCIR_FIFO control logic to RAM blocks used for PCIR_FIFO
302-----------------------------------------------------------------------------------------------------------*/
303wire [(PCIR_ADDR_LENGTH - 1):0] pcir_raddr ;
304wire [(PCIR_ADDR_LENGTH - 1):0] pcir_waddr ;
305
306/*-----------------------------------------------------------------------------------------------------------
307PCIW_FIFO transaction counters: used to count incoming transactions and outgoing transactions. When number of
308input transactions is equal to number of output transactions, it means that there isn't any complete transaction
309currently present in the FIFO.
310-----------------------------------------------------------------------------------------------------------*/
311reg [(PCIW_ADDR_LENGTH - 1):0] pciw_inTransactionCount ;
312reg [(PCIW_ADDR_LENGTH - 1):0] pciw_outTransactionCount ;
313
314/*-----------------------------------------------------------------------------------------------------------
315FlipFlops for indicating if complete delayed read completion is present in the FIFO
316-----------------------------------------------------------------------------------------------------------*/
317/*reg pcir_inTransactionCount ;
318reg pcir_outTransactionCount ;*/
319/*-----------------------------------------------------------------------------------------------------------
320wires monitoring control bus. When control bus on a write transaction has a value of `LAST, it means that
321complete transaction is in the FIFO. When control bus on a read transaction has a value of `LAST,
322it means that there was one complete transaction taken out of FIFO.
323-----------------------------------------------------------------------------------------------------------*/
324wire pciw_last_in = pciw_control_in[`LAST_CTRL_BIT] ;
325wire pciw_last_out = pciw_control_out[`LAST_CTRL_BIT] ;
326
327/*wire pcir_last_in = pcir_wallow && (pcir_control_in == `LAST) ;
328wire pcir_last_out = pcir_rallow && (pcir_control_out == `LAST) ;*/
329
330wire pciw_empty ;
331wire pcir_empty ;
332
333assign pciw_empty_out = pciw_empty ;
334assign pcir_empty_out = pcir_empty ;
335
336// clear wires for clearing FFs and registers
337wire pciw_clear = reset_in /*|| pciw_flush_in*/ ; // PCIW_FIFO's clear signal - flush not used
338wire pcir_clear = reset_in /*|| pcir_flush_in*/ ; // PCIR_FIFO's clear signal - flush changed to synchronous op.
339
340/*-----------------------------------------------------------------------------------------------------------
341Definitions of wires for connecting RAM instances
342-----------------------------------------------------------------------------------------------------------*/
343wire [39:0] dpram_portA_output ;
344wire [39:0] dpram_portB_output ;
345
346wire [39:0] dpram_portA_input = {pciw_control_in, pciw_cbe_in, pciw_addr_data_in} ;
347wire [39:0] dpram_portB_input = {pcir_control_in, pcir_be_in, pcir_data_in} ;
348
349/*-----------------------------------------------------------------------------------------------------------
350Fifo output assignments - each ram port provides data for different fifo
351-----------------------------------------------------------------------------------------------------------*/
352assign pciw_control_out = dpram_portB_output[39:36] ;
353assign pcir_control_out = dpram_portA_output[39:36] ;
354
355assign pciw_cbe_out = dpram_portB_output[35:32] ;
356assign pcir_be_out = dpram_portA_output[35:32] ;
357
358assign pciw_addr_data_out = dpram_portB_output[31:0] ;
359assign pcir_data_out = dpram_portA_output[31:0] ;
360
361`ifdef PCI_RAM_DONT_SHARE
362
363 /*-----------------------------------------------------------------------------------------------------------
364 Piece of code in this ifdef section is used in applications which can provide enough RAM instances to
365 accomodate four fifos - each occupying its own instance of ram. Ports are connected in such a way,
366 that instances of RAMs can be changed from two port to dual port ( async read/write port ). In that case,
367 write port is always port a and read port is port b.
368 -----------------------------------------------------------------------------------------------------------*/
369
370 /*-----------------------------------------------------------------------------------------------------------
371 Pad redundant address lines with zeros. This may seem stupid, but it comes in perfect for FPGA impl.
372 -----------------------------------------------------------------------------------------------------------*/
373 /*
374 wire [(`PCIW_FIFO_RAM_ADDR_LENGTH - PCIW_ADDR_LENGTH - 1):0] pciw_addr_prefix = {( `PCIW_FIFO_RAM_ADDR_LENGTH - PCIW_ADDR_LENGTH){1'b0}} ;
375 wire [(`PCIR_FIFO_RAM_ADDR_LENGTH - PCIR_ADDR_LENGTH - 1):0] pcir_addr_prefix = {( `PCIR_FIFO_RAM_ADDR_LENGTH - PCIR_ADDR_LENGTH){1'b0}} ;
376 */
377
378 // compose complete port addresses
379 wire [(`PCI_FIFO_RAM_ADDR_LENGTH-1):0] pciw_whole_waddr = pciw_waddr ;
380 wire [(`PCI_FIFO_RAM_ADDR_LENGTH-1):0] pciw_whole_raddr = pciw_raddr ;
381
382 wire [(`PCI_FIFO_RAM_ADDR_LENGTH-1):0] pcir_whole_waddr = pcir_waddr ;
383 wire [(`PCI_FIFO_RAM_ADDR_LENGTH-1):0] pcir_whole_raddr = pcir_raddr ;
384
385 wire pciw_read_enable = 1'b1 ;
386 wire pcir_read_enable = 1'b1 ;
387
388 `ifdef PCI_BIST
389 wire mbist_so_o_internal ; // wires for connection of debug ports on two rams
390 wire mbist_si_i_internal = mbist_so_o_internal ;
391 `endif
392
393 // instantiate and connect two generic rams - one for pci write fifo and one for pci read fifo
394 pci_pci_tpram #(`PCI_FIFO_RAM_ADDR_LENGTH, 40) pciw_fifo_storage
395 (
396 // Generic synchronous two-port RAM interface
397 .clk_a(pci_clock_in),
398 .rst_a(reset_in),
399 .ce_a(1'b1),
400 .we_a(pciw_wallow),
401 .oe_a(1'b1),
402 .addr_a(pciw_whole_waddr),
403 .di_a(dpram_portA_input),
404 .do_a(),
405
406 .clk_b(wb_clock_in),
407 .rst_b(reset_in),
408 .ce_b(pciw_read_enable),
409 .we_b(1'b0),
410 .oe_b(1'b1),
411 .addr_b(pciw_whole_raddr),
412 .di_b(40'h00_0000_0000),
413 .do_b(dpram_portB_output)
414
415 `ifdef PCI_BIST
416 ,
417 .mbist_si_i (mbist_si_i),
418 .mbist_so_o (mbist_so_o_internal),
419 .mbist_ctrl_i (mbist_ctrl_i)
420 `endif
421 );
422
423 pci_pci_tpram #(`PCI_FIFO_RAM_ADDR_LENGTH, 40) pcir_fifo_storage
424 (
425 // Generic synchronous two-port RAM interface
426 .clk_a(wb_clock_in),
427 .rst_a(reset_in),
428 .ce_a(1'b1),
429 .we_a(pcir_wallow),
430 .oe_a(1'b1),
431 .addr_a(pcir_whole_waddr),
432 .di_a(dpram_portB_input),
433 .do_a(),
434
435 .clk_b(pci_clock_in),
436 .rst_b(reset_in),
437 .ce_b(pcir_read_enable),
438 .we_b(1'b0),
439 .oe_b(1'b1),
440 .addr_b(pcir_whole_raddr),
441 .di_b(40'h00_0000_0000),
442 .do_b(dpram_portA_output)
443
444 `ifdef PCI_BIST
445 ,
446 .mbist_si_i (mbist_si_i_internal),
447 .mbist_so_o (mbist_so_o),
448 .mbist_ctrl_i (mbist_ctrl_i)
449 `endif
450 );
451
452`else // RAM blocks sharing between two fifos
453
454 /*-----------------------------------------------------------------------------------------------------------
455 Code section under this ifdef is used for implementation where RAM instances are too expensive. In this
456 case one RAM instance is used for both - pci read and pci write fifo.
457 -----------------------------------------------------------------------------------------------------------*/
458 /*-----------------------------------------------------------------------------------------------------------
459 Address prefix definition - since both FIFOs reside in same RAM instance, storage is separated by MSB
460 addresses. pci write fifo addresses are padded with zeros on the MSB side ( at least one address line
461 must be used for this ), pci read fifo addresses are padded with ones on the right ( at least one ).
462 -----------------------------------------------------------------------------------------------------------*/
463 wire [(`PCI_FIFO_RAM_ADDR_LENGTH - PCIW_ADDR_LENGTH - 1):0] pciw_addr_prefix = {( `PCI_FIFO_RAM_ADDR_LENGTH - PCIW_ADDR_LENGTH){1'b0}} ;
464 wire [(`PCI_FIFO_RAM_ADDR_LENGTH - PCIR_ADDR_LENGTH - 1):0] pcir_addr_prefix = {( `PCI_FIFO_RAM_ADDR_LENGTH - PCIR_ADDR_LENGTH){1'b1}} ;
465
466 /*-----------------------------------------------------------------------------------------------------------
467 Port A address generation for RAM instance. RAM instance must be full two port RAM - read and write capability
468 on both sides.
469 Port A is clocked by PCI clock, DIA is input for pciw_fifo, DOA is output for pcir_fifo.
470 Address is multiplexed so operation can be switched between fifos. Default is a read on port.
471 -----------------------------------------------------------------------------------------------------------*/
472 wire [(`PCI_FIFO_RAM_ADDR_LENGTH-1):0] portA_addr = pciw_wallow ? {pciw_addr_prefix, pciw_waddr} : {pcir_addr_prefix, pcir_raddr} ;
473
474 /*-----------------------------------------------------------------------------------------------------------
475 Port B is clocked by WISHBONE clock, DIB is input for pcir_fifo, DOB is output for pciw_fifo.
476 Address is multiplexed so operation can be switched between fifos. Default is a read on port.
477 -----------------------------------------------------------------------------------------------------------*/
478 wire [(`PCI_FIFO_RAM_ADDR_LENGTH-1):0] portB_addr = pcir_wallow ? {pcir_addr_prefix, pcir_waddr} : {pciw_addr_prefix, pciw_raddr} ;
479
480 wire portA_enable = 1'b1 ;
481
482 wire portB_enable = 1'b1 ;
483
484 // instantiate RAM for these two fifos
485 pci_pci_tpram #(`PCI_FIFO_RAM_ADDR_LENGTH, 40) pciu_fifo_storage
486 (
487 // Generic synchronous two-port RAM interface
488 .clk_a(pci_clock_in),
489 .rst_a(reset_in),
490 .ce_a(portA_enable),
491 .we_a(pciw_wallow),
492 .oe_a(1'b1),
493 .addr_a(portA_addr),
494 .di_a(dpram_portA_input),
495 .do_a(dpram_portA_output),
496 .clk_b(wb_clock_in),
497 .rst_b(reset_in),
498 .ce_b(portB_enable),
499 .we_b(pcir_wallow),
500 .oe_b(1'b1),
501 .addr_b(portB_addr),
502 .di_b(dpram_portB_input),
503 .do_b(dpram_portB_output)
504
505 `ifdef PCI_BIST
506 ,
507 .mbist_si_i (mbist_si_i),
508 .mbist_so_o (mbist_so_o),
509 .mbist_ctrl_i (mbist_ctrl_i)
510 `endif
511 );
512
513`endif
514
515/*-----------------------------------------------------------------------------------------------------------
516Instantiation of two control logic modules - one for PCIW_FIFO and one for PCIR_FIFO
517-----------------------------------------------------------------------------------------------------------*/
518pci_pciw_fifo_control #(PCIW_ADDR_LENGTH) pciw_fifo_ctrl
519(
520 .rclock_in(wb_clock_in),
521 .wclock_in(pci_clock_in),
522 .renable_in(pciw_renable_in),
523 .wenable_in(pciw_wenable_in),
524 .reset_in(reset_in),
525// .flush_in(pciw_flush_in), // flush not used
526 .three_left_out(pciw_three_left_out),
527 .two_left_out(pciw_two_left_out),
528 .almost_full_out(pciw_almost_full_out),
529 .full_out(pciw_full_out),
530 .almost_empty_out(pciw_almost_empty_out),
531 .empty_out(pciw_empty),
532 .waddr_out(pciw_waddr),
533 .raddr_out(pciw_raddr),
534 .rallow_out(pciw_rallow),
535 .wallow_out(pciw_wallow)
536);
537
538pci_pcir_fifo_control #(PCIR_ADDR_LENGTH) pcir_fifo_ctrl
539(
540 .rclock_in(pci_clock_in),
541 .wclock_in(wb_clock_in),
542 .renable_in(pcir_renable_in),
543 .wenable_in(pcir_wenable_in),
544 .reset_in(reset_in),
545 .flush_in(pcir_flush_in),
546 .full_out(pcir_full_out),
547 .almost_empty_out(pcir_almost_empty_out),
548 .empty_out(pcir_empty),
549 .waddr_out(pcir_waddr),
550 .raddr_out(pcir_raddr),
551 .rallow_out(pcir_rallow),
552 .wallow_out(pcir_wallow)
553);
554
555
556// in and out transaction counters and grey codes
557reg [(PCIW_ADDR_LENGTH-2):0] inGreyCount ;
558reg [(PCIW_ADDR_LENGTH-2):0] outGreyCount ;
559wire [(PCIW_ADDR_LENGTH-2):0] inNextGreyCount = {pciw_inTransactionCount[(PCIW_ADDR_LENGTH-2)], pciw_inTransactionCount[(PCIW_ADDR_LENGTH-2):1] ^ pciw_inTransactionCount[(PCIW_ADDR_LENGTH-3):0]} ;
560wire [(PCIW_ADDR_LENGTH-2):0] outNextGreyCount = {pciw_outTransactionCount[(PCIW_ADDR_LENGTH-2)], pciw_outTransactionCount[(PCIW_ADDR_LENGTH-2):1] ^ pciw_outTransactionCount[(PCIW_ADDR_LENGTH-3):0]} ;
561
562// input transaction counter is incremented when whole transaction is written to fifo. This is indicated by last control bit written to last transaction location
563wire in_count_en = pciw_wallow && pciw_last_in ;
564
565// output transaction counter is incremented when whole transaction is pulled out of fifo. This is indicated when location with last control bit set is read
566wire out_count_en = pciw_rallow && pciw_last_out ;
567
568always@(posedge pci_clock_in or posedge pciw_clear)
569begin
570 if (pciw_clear)
571 begin
572 inGreyCount <= 0 ;
573 end
574 else
575 if (in_count_en)
576 inGreyCount <= #`FF_DELAY inNextGreyCount ;
577end
578
579wire [(PCIW_ADDR_LENGTH-2):0] wb_clk_sync_inGreyCount ;
580reg [(PCIW_ADDR_LENGTH-2):0] wb_clk_inGreyCount ;
581pci_synchronizer_flop #((PCIW_ADDR_LENGTH - 1), 0) i_synchronizer_reg_inGreyCount
582(
583 .data_in (inGreyCount),
584 .clk_out (wb_clock_in),
585 .sync_data_out (wb_clk_sync_inGreyCount),
586 .async_reset (pciw_clear)
587) ;
588
589always@(posedge wb_clock_in or posedge pciw_clear)
590begin
591 if (pciw_clear)
592 wb_clk_inGreyCount <= #`FF_DELAY 0 ;
593 else
594 wb_clk_inGreyCount <= # `FF_DELAY wb_clk_sync_inGreyCount ;
595end
596
597always@(posedge wb_clock_in or posedge pciw_clear)
598begin
599 if (pciw_clear)
600 begin
601 outGreyCount <= #`FF_DELAY 0 ;
602 end
603 else
604 if (out_count_en)
605 outGreyCount <= #`FF_DELAY outNextGreyCount ;
606end
607
608always@(posedge pci_clock_in or posedge pciw_clear)
609begin
610 if (pciw_clear)
611 pciw_inTransactionCount <= #`FF_DELAY 1 ;
612 else
613 if (in_count_en)
614 pciw_inTransactionCount <= #`FF_DELAY pciw_inTransactionCount + 1'b1 ;
615end
616
617always@(posedge wb_clock_in or posedge pciw_clear)
618begin
619 if (pciw_clear)
620 pciw_outTransactionCount <= #`FF_DELAY 1 ;
621 else
622 if (out_count_en)
623 pciw_outTransactionCount <= #`FF_DELAY pciw_outTransactionCount + 1'b1 ;
624end
625
626assign pciw_transaction_ready_out = wb_clk_inGreyCount != outGreyCount ;
627
628assign pcir_transaction_ready_out = 1'b0 ;
629
630endmodule
631
Impressum, Datenschutz