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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_10/] [rtl/] [verilog/] [pci_wbw_wbr_fifos.v] - Blame information for rev 154

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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