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

Subversion Repositories pci

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

powered by: WebSVN 2.1.0

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