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 81

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

powered by: WebSVN 2.1.0

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