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 108

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

powered by: WebSVN 2.1.0

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