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

Subversion Repositories pci

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

powered by: WebSVN 2.1.0

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