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

Subversion Repositories pci

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

powered by: WebSVN 2.1.0

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