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 81

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

powered by: WebSVN 2.1.0

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