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

Subversion Repositories pci

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

powered by: WebSVN 2.1.0

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