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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_3/] [rtl/] [verilog/] [pciw_pcir_fifos.v] - Blame information for rev 154

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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