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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_6/] [rtl/] [verilog/] [pci_pciw_pcir_fifos.v] - Blame information for rev 88

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

powered by: WebSVN 2.1.0

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