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

Subversion Repositories pci

[/] [pci/] [tags/] [working_demo/] [old_stuff/] [FIFOs/] [wbw_wbr_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 "wbw_wbr_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
////      - mihad@opencores.org                                   ////
10
////      - Miha Dolenc                                           ////
11
////                                                              ////
12
////  All additional information is avaliable in the README.pdf   ////
13
////  file.                                                       ////
14
////                                                              ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2000 Miha Dolenc, mihad@opencores.org          ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
//
43
// CVS Revision History
44
//
45
// $Log: not supported by cvs2svn $
46
// Revision 1.4  2001/06/12 11:13:34  mihad
47
// Changed module parameters
48
//
49
//
50
 
51
`include "constants.v"
52
`include "fifo_control.v"
53
`include "dp_sram.v"
54
`include "dp_async_ram.v"
55
 
56
module WBW_WBR_FIFOS( wb_clock_in, pci_clock_in, reset_in,
57
                      wbw_wenable_in, wbw_addr_data_in,
58
                      wbw_cbe_in, wbw_control_in,
59
                      wbw_renable_in, wbw_addr_data_out,
60
                      wbw_cbe_out, wbw_control_out,
61
                      wbw_flush_in, wbw_almost_full_out, wbw_full_out,
62
                      wbw_almost_empty_out, wbw_empty_out, wbw_transaction_ready_out,
63
                      wbr_wenable_in, wbr_data_in,
64
                      wbr_be_in, wbr_control_in,
65
                      wbr_renable_in, wbr_data_out,
66
                      wbr_be_out, wbr_control_out,
67
                      wbr_flush_in, wbr_almost_full_out, wbr_full_out,
68
                      wbr_almost_empty_out, wbr_empty_out, wbr_transaction_ready_out) ;
69
 
70
/*-----------------------------------------------------------------------------------------------------------
71
System inputs:
72
wb_clock_in - WISHBONE bus clock
73
pci_clock_in - PCI bus clock
74
reset_in - reset from control logic
75
-------------------------------------------------------------------------------------------------------------*/
76
input wb_clock_in, pci_clock_in, reset_in ;
77
 
78
/*-----------------------------------------------------------------------------------------------------------
79
WISHBONE WRITE FIFO interface signals prefixed with wbw_ - FIFO is used for posted writes initiated by
80
WISHBONE master, traveling through FIFO and are completed on PCI by PCI master interface
81
 
82
write enable signal:
83
wbw_wenable_in = write enable input for WBW_FIFO - driven by WISHBONE slave interface
84
 
85
data input signals:
86
wbw_addr_data_in = data input - data from WISHBONE bus - first entry of transaction is address others are data entries
87
wbw_cbe_in       = bus command/byte enable(~SEL[3:0]) input - first entry of transaction is bus command, other are byte enables
88
wbw_control_in   = control input - encoded control bus input
89
 
90
read enable signal:
91
wbw_renable_in = read enable input driven by PCI master interface
92
 
93
data output signals:
94
wbw_addr_data_out = data output - data from WISHBONE bus - first entry of transaction is address, others are data entries
95
wbw_cbe_out      = bus command/byte enable output - first entry of transaction is bus command, others are byte enables
96
wbw_control_out = control input - encoded control bus input
97
 
98
status signals - monitored by various resources in the core
99
wbw_flush_in = flush signal input for WBW_FIFO - when asserted, fifo is flushed(emptied)
100
wbw_almost_full_out = almost full output from WBW_FIFO
101
wbw_full_out = full output from WBW_FIFO
102
wbw_almost_empty_out = almost empty output from WBW_FIFO
103
wbw_empty_out = empty output from WBW_FIFO
104
wbw_transaction_ready_out = output indicating that one complete transaction is waiting in WBW_FIFO
105
-----------------------------------------------------------------------------------------------------------*/
106
// input control and data
107
input        wbw_wenable_in ;
108
input [31:0] wbw_addr_data_in ;
109
input [3:0]  wbw_cbe_in ;
110
input [3:0]  wbw_control_in ;
111
 
112
// output control and data
113
input         wbw_renable_in ;
114
output [31:0] wbw_addr_data_out ;
115
output [3:0]  wbw_cbe_out ;
116
output [3:0]  wbw_control_out ;
117
 
118
// flush input
119
input wbw_flush_in ;
120
 
121
// status outputs
122
output wbw_almost_full_out ;
123
output wbw_full_out ;
124
output wbw_almost_empty_out ;
125
output wbw_empty_out ;
126
output wbw_transaction_ready_out ;
127
 
128
/*-----------------------------------------------------------------------------------------------------------
129
WISHBONE READ FIFO interface signals prefixed with wbr_ - FIFO is used for holding delayed read completions
130
initiated by master on WISHBONE bus and completed on PCI bus,
131
 
132
write enable signal:
133
wbr_wenable_in = write enable input for WBR_FIFO - driven by PCI master interface
134
 
135
data input signals:
136
wbr_data_in      = data input - data from PCI bus - there is no address entry here, since address is stored in separate register
137
wbr_be_in        = byte enable(~BE#[3:0]) input - byte enables - same through one transaction
138
wbr_control_in   = control input - encoded control bus input
139
 
140
read enable signal:
141
wbr_renable_in = read enable input driven by WISHBONE slave interface
142
 
143
data output signals:
144
wbr_data_out = data output - data from PCI bus
145
wbr_be_out      = byte enable output(~#BE)
146
wbr_control_out = control output - encoded control bus output
147
 
148
status signals - monitored by various resources in the core
149
wbr_flush_in = flush signal input for WBR_FIFO - when asserted, fifo is flushed(emptied)
150
wbr_almost_full_out = almost full output from WBR_FIFO
151
wbr full_out = full output from WBR_FIFO
152
wbr_almost_empty_out = almost empty output from WBR_FIFO
153
wbr_empty_out = empty output from WBR_FIFO
154
wbr_transaction_ready_out = output indicating that one complete transaction is waiting in WBR_FIFO
155
-----------------------------------------------------------------------------------------------------------*/
156
// input control and data
157
input        wbr_wenable_in ;
158
input [31:0] wbr_data_in ;
159
input [3:0]  wbr_be_in ;
160
input [3:0]  wbr_control_in ;
161
 
162
// output control and data
163
input         wbr_renable_in ;
164
output [31:0] wbr_data_out ;
165
output [3:0]  wbr_be_out ;
166
output [3:0]  wbr_control_out ;
167
 
168
// flush input
169
input wbr_flush_in ;
170
 
171
// status outputs
172
output wbr_almost_full_out ;
173
output wbr_full_out ;
174
output wbr_almost_empty_out ;
175
output wbr_empty_out ;
176
output wbr_transaction_ready_out ;
177
 
178
/*-----------------------------------------------------------------------------------------------------------
179
FIFO depth parameters:
180
WBW_DEPTH = defines WBW_FIFO depth
181
WBR_DEPTH = defines WBR_FIFO depth
182
WBW_ADDR_LENGTH = defines WBW_FIFO's location address length = log2(WBW_DEPTH)
183
WBR_ADDR_LENGTH = defines WBR_FIFO's location address length = log2(WBR_DEPTH)
184
-----------------------------------------------------------------------------------------------------------*/
185
parameter WBW_DEPTH = `WBW_DEPTH ;
186
parameter WBW_ADDR_LENGTH = `WBW_ADDR_LENGTH ;
187
parameter WBR_DEPTH = `WBR_DEPTH ;
188
parameter WBR_ADDR_LENGTH = `WBR_ADDR_LENGTH ;
189
 
190
// obvious
191
wire vcc = 1'b1 ;
192
wire gnd = 1'b0 ;
193
 
194
/*-----------------------------------------------------------------------------------------------------------
195
wbw_wallow = WBW_FIFO write allow wire - writes to FIFO are allowed when FIFO isn't full and write enable is 1
196
wbw_rallow = WBW_FIFO read allow wire - reads from FIFO are allowed when FIFO isn't empty and read enable is 1
197
-----------------------------------------------------------------------------------------------------------*/
198
wire wbw_wallow ;
199
wire wbw_rallow ;
200
 
201
/*-----------------------------------------------------------------------------------------------------------
202
wbr_wallow = WBR_FIFO write allow wire - writes to FIFO are allowed when FIFO isn't full and write enable is 1
203
wbr_rallow = WBR_FIFO read allow wire - reads from FIFO are allowed when FIFO isn't empty and read enable is 1
204
-----------------------------------------------------------------------------------------------------------*/
205
wire wbr_wallow ;
206
wire wbr_rallow ;
207
 
208
/*-----------------------------------------------------------------------------------------------------------
209
wires for address port conections from WBW_FIFO control logic to RAM blocks used for WBW_FIFO
210
-----------------------------------------------------------------------------------------------------------*/
211
wire [(WBW_ADDR_LENGTH - 1):0] wbw_raddr ;
212
wire [(WBW_ADDR_LENGTH - 1):0] wbw_waddr ;
213
 
214
/*-----------------------------------------------------------------------------------------------------------
215
wires for address port conections from WBR_FIFO control logic to RAM blocks used for WBR_FIFO
216
-----------------------------------------------------------------------------------------------------------*/
217
wire [(WBR_ADDR_LENGTH - 1):0] wbr_raddr ;
218
wire [(WBR_ADDR_LENGTH - 1):0] wbr_waddr ;
219
 
220
/*-----------------------------------------------------------------------------------------------------------
221
WBW_FIFO transaction counters: used to count incoming transactions and outgoing transactions. When number of
222
input transactions is equal to number of output transactions, it means that there isn't any complete transaction
223
currently present in the FIFO.
224
-----------------------------------------------------------------------------------------------------------*/
225
reg [(WBW_ADDR_LENGTH - 1):0] wbw_inTransactionCount ;
226
reg [(WBW_ADDR_LENGTH - 1):0] wbw_outTransactionCount ;
227
 
228
/*-----------------------------------------------------------------------------------------------------------
229
FlipFlops for indicating if complete delayed read completion is present in the FIFO
230
-----------------------------------------------------------------------------------------------------------*/
231
reg wbr_inTransactionCount ;
232
reg wbr_outTransactionCount ;
233
/*-----------------------------------------------------------------------------------------------------------
234
wires monitoring control bus. When control bus on a write transaction has a value of `LAST, it means that
235
complete transaction is in the FIFO. When control bus on a read transaction has a value of `LAST,
236
it means that there was one complete transaction taken out of FIFO.
237
-----------------------------------------------------------------------------------------------------------*/
238
wire wbw_last_in  = wbw_wallow && (wbw_control_in == `LAST) ;
239
wire wbw_last_out = wbw_rallow && (wbw_control_out == `LAST) ;
240
 
241
wire wbr_last_in  = wbr_wallow && (wbr_control_in == `LAST) ;
242
wire wbr_last_out = wbr_rallow && (wbr_control_out == `LAST) ;
243
 
244
wire wbw_empty ;
245
wire wbr_empty ;
246
 
247
assign wbw_empty_out = wbw_empty ;
248
assign wbr_empty_out = wbr_empty ;
249
 
250
// clear wires for fifos
251
wire wbw_clear = reset_in || wbw_flush_in ; // WBW_FIFO clear
252
wire wbr_clear = reset_in || wbr_flush_in ; // WBR_FIFO clear
253
 
254
`ifdef FPGA
255
/*-----------------------------------------------------------------------------------------------------------
256
this code is included only for FPGA core usage - somewhat different logic because of sharing
257
one block selectRAM+ between two FIFOs
258
-----------------------------------------------------------------------------------------------------------*/
259
    `ifdef BIG
260
        /*-----------------------------------------------------------------------------------------------------------
261
        Big FPGAs
262
        WBW_FIFO and WBR_FIFO address prefixes - used for extending read and write addresses because of varible
263
        FIFO depth and fixed SelectRAM+ size. Addresses are zero paded on the left to form long enough address
264
        -----------------------------------------------------------------------------------------------------------*/
265
        wire [(7 - WBW_ADDR_LENGTH):0] wbw_addr_prefix = {( 8 - WBW_ADDR_LENGTH){1'b0}} ;
266
        wire [(7 - WBR_ADDR_LENGTH):0] wbr_addr_prefix = {( 8 - WBR_ADDR_LENGTH){1'b0}} ;
267
 
268
        // compose addresses
269
        wire [7:0] wbw_whole_waddr = {wbw_addr_prefix, wbw_waddr} ;
270
        wire [7:0] wbw_whole_raddr = {wbw_addr_prefix, wbw_raddr} ;
271
 
272
        wire [7:0] wbr_whole_waddr = {wbr_addr_prefix, wbr_waddr} ;
273
        wire [7:0] wbr_whole_raddr = {wbr_addr_prefix, wbr_raddr} ;
274
 
275
        /*-----------------------------------------------------------------------------------------------------------
276
        Only 8 bits out of 16 are used in ram3 and ram6 - wires for referencing them
277
        -----------------------------------------------------------------------------------------------------------*/
278
        wire [15:0] dpram3_portB_output ;
279
        wire [15:0] dpram6_portA_output ;
280
 
281
        /*-----------------------------------------------------------------------------------------------------------
282
        Control out assignements from ram3 output
283
        -----------------------------------------------------------------------------------------------------------*/
284
        assign wbw_control_out = dpram3_portB_output[15:12] ;
285
        assign wbr_control_out = dpram6_portA_output[15:12] ;
286
 
287
        assign wbw_cbe_out = dpram3_portB_output[3:0] ;
288
        assign wbr_be_out  = dpram6_portA_output[3:0] ;
289
 
290
        wire wbw_read_enable = wbw_rallow || wbw_empty ;
291
        wire wbr_read_enable = wbr_rallow || wbr_empty ;
292
 
293
        // Block SelectRAM+ cells instantiation
294
        RAMB4_S16_S16 dpram16_1 (.ADDRA(wbw_whole_waddr), .DIA(wbw_addr_data_in[15:0]),
295
                                 .ENA(vcc), .RSTA(reset_in),
296
                                 .CLKA(wb_clock_in), .WEA(wbw_wallow),
297
                                 .DOA(),
298
                                 .ADDRB(wbw_whole_raddr), .DIB(16'h0000),
299
                                 .ENB(wbw_read_enable), .RSTB(reset_in),
300
                                 .CLKB(pci_clock_in), .WEB(gnd),
301
                                 .DOB(wbw_addr_data_out[15:0])) ;
302
 
303
        RAMB4_S16_S16 dpram16_2 (.ADDRA(wbw_whole_waddr), .DIA(wbw_addr_data_in[31:16]),
304
                                 .ENA(vcc), .RSTA(reset_in),
305
                                 .CLKA(wb_clock_in), .WEA(wbw_wallow),
306
                                 .DOA(),
307
                                 .ADDRB(wbw_whole_raddr), .DIB(16'h0000),
308
                                 .ENB(wbw_read_enable), .RSTB(reset_in),
309
                                 .CLKB(pci_clock_in), .WEB(gnd),
310
                                 .DOB(wbw_addr_data_out[31:16])) ;
311
 
312
        RAMB4_S16_S16 dpram16_3 (.ADDRA(wbw_whole_waddr), .DIA({wbw_control_in, 8'h00, wbw_cbe_in}),
313
                                 .ENA(vcc), .RSTA(reset_in),
314
                                 .CLKA(wb_clock_in), .WEA(wbw_wallow),
315
                                 .DOA(),
316
                                 .ADDRB(wbw_whole_raddr), .DIB(16'h0000),
317
                                 .ENB(wbw_read_enable), .RSTB(reset_in),
318
                                 .CLKB(pci_clock_in), .WEB(gnd),
319
                                 .DOB(dpram3_portB_output)) ;
320
 
321
        RAMB4_S16_S16 dpram16_4 (.ADDRA(wbr_whole_raddr), .DIA(16'h0000),
322
                                 .ENA(wbr_read_enable), .RSTA(reset_in),
323
                                 .CLKA(wb_clock_in), .WEA(gnd),
324
                                 .DOA(wbr_data_out[15:0]),
325
                                 .ADDRB(wbr_whole_waddr), .DIB(wbr_data_in[15:0]),
326
                                 .ENB(vcc), .RSTB(reset_in),
327
                                 .CLKB(pci_clock_in), .WEB(wbr_wallow),
328
                                 .DOB()) ;
329
 
330
        RAMB4_S16_S16 dpram16_5 (.ADDRA(wbr_whole_raddr), .DIA(16'h0000),
331
                                 .ENA(wbr_read_enable), .RSTA(reset_in),
332
                                 .CLKA(wb_clock_in), .WEA(gnd),
333
                                 .DOA(wbr_data_out[31:16]),
334
                                 .ADDRB(wbr_whole_waddr), .DIB(wbr_data_in[31:16]),
335
                                 .ENB(vcc), .RSTB(reset_in),
336
                                 .CLKB(pci_clock_in), .WEB(wbr_wallow),
337
                                 .DOB()) ;
338
 
339
        RAMB4_S16_S16 dpram16_6 (.ADDRA(wbr_whole_raddr), .DIA(16'h0000),
340
                                 .ENA(wbr_read_enable), .RSTA(reset_in),
341
                                 .CLKA(wb_clock_in), .WEA(gnd),
342
                                 .DOA(dpram6_portA_output),
343
                                 .ADDRB(wbr_whole_waddr), .DIB({wbr_control_in, 8'h00, wbr_be_in}),
344
                                 .ENB(vcc), .RSTB(reset_in),
345
                                 .CLKB(pci_clock_in), .WEB(wbr_wallow),
346
                                 .DOB()) ;
347
 
348
    `else // SMALL FPGAs
349
 
350
        /*-----------------------------------------------------------------------------------------------------------
351
        Small FPGAs
352
        WBW_FIFO and WBR_FIFO address prefixes - used for extending read and write addresses because of varible
353
        FIFO depth and fixed SelectRAM+ size. Addresses are always paded, because of RAM sharing between FIFOs
354
        WBW addresses are zero padded on the left, WBR addresses are padded
355
        with ones on the left
356
        -----------------------------------------------------------------------------------------------------------*/
357
        wire [(7 - WBW_ADDR_LENGTH):0] wbw_addr_prefix = {( 8 - WBW_ADDR_LENGTH){1'b0}} ;
358
        wire [(7 - WBR_ADDR_LENGTH):0] wbr_addr_prefix = {( 8 - WBR_ADDR_LENGTH){1'b1}} ;
359
 
360
        /*-----------------------------------------------------------------------------------------------------------
361
        Only 8 bits out of 16 are used in ram3 - wires for referencing them
362
        -----------------------------------------------------------------------------------------------------------*/
363
        wire [15:0] dpram3_portA_output ;
364
        wire [15:0] dpram3_portB_output ;
365
 
366
        /*-----------------------------------------------------------------------------------------------------------
367
        Control out assignements from ram3 output
368
        -----------------------------------------------------------------------------------------------------------*/
369
        assign wbw_control_out = dpram3_portB_output[15:12] ;
370
        assign wbr_control_out = dpram3_portA_output[15:12] ;
371
 
372
        assign wbw_cbe_out = dpram3_portB_output[3:0] ;
373
        assign wbr_be_out  = dpram3_portA_output[3:0] ;
374
 
375
        /*-----------------------------------------------------------------------------------------------------------
376
        Logic used for extending port's enable input for one clock cycle to allow address and date change from
377
        WISHBONE write fifo's write address and data back to WISHBONE read fifo's address and data ( turnaround cycle )
378
        -----------------------------------------------------------------------------------------------------------*/
379
        reg wbw_write_performed ;
380
        always@(posedge wb_clock_in or posedge reset_in)
381
        begin
382
            if (reset_in)
383
                wbw_write_performed <= #`FF_DELAY 1'b0 ;
384
            else
385
                wbw_write_performed <= #`FF_DELAY wbw_wallow ;
386
        end
387
 
388
        /*-----------------------------------------------------------------------------------------------------------
389
        Logic used for extending port's enable input for one clock cycle to allow address and date change from
390
        WISHBONE read fifo's write address and data back to WISHBONE write fifo's address and data ( turnaround cycle )
391
        -----------------------------------------------------------------------------------------------------------*/
392
        reg wbr_write_performed ;
393
        always@(posedge pci_clock_in or posedge reset_in)
394
        begin
395
            if (reset_in)
396
                wbr_write_performed <= #`FF_DELAY 1'b0 ;
397
            else
398
                wbr_write_performed <= #`FF_DELAY wbr_wallow ;
399
        end
400
 
401
        /*-----------------------------------------------------------------------------------------------------------
402
        Additional register storing actual WBW read address. It must be applied to port B during turnaround cycle
403
        -----------------------------------------------------------------------------------------------------------*/
404
        reg [(WBW_ADDR_LENGTH - 1):0] wbw_raddr_0 ;
405
 
406
        always@(posedge pci_clock_in or posedge wbw_clear)
407
        begin
408
            if (wbw_clear)
409
                wbw_raddr_0 <= #`FF_DELAY {WBW_ADDR_LENGTH{1'b0}} ;
410
            else
411
                if(wbw_rallow)
412
                    wbw_raddr_0 <= #`FF_DELAY wbw_raddr ;
413
        end
414
 
415
        wire [(WBW_ADDR_LENGTH - 1):0] wbw_raddr_calc = wbr_write_performed ? wbw_raddr_0 : wbw_raddr ;
416
 
417
        /*-----------------------------------------------------------------------------------------------------------
418
        Additional register storing actual WBR read address. It must be applied to port A during turnaround cycle
419
        -----------------------------------------------------------------------------------------------------------*/
420
        reg [(WBR_ADDR_LENGTH - 1):0] wbr_raddr_0 ;
421
 
422
        always@(posedge wb_clock_in or posedge wbr_clear)
423
        begin
424
            if(wbr_clear)
425
                wbr_raddr_0 <= #`FF_DELAY {WBR_ADDR_LENGTH{1'b0}} ;
426
            else
427
                if(wbr_rallow)
428
                    wbr_raddr_0 <= #`FF_DELAY wbr_raddr ;
429
        end
430
 
431
        wire [(WBR_ADDR_LENGTH - 1):0] wbr_raddr_calc = wbw_write_performed ? wbr_raddr_0 : wbr_raddr ;
432
 
433
        /*-----------------------------------------------------------------------------------------------------------
434
        Port A and B enables
435
        -----------------------------------------------------------------------------------------------------------*/
436
        wire portA_enable = wbw_wallow || wbr_rallow || wbr_empty || wbw_write_performed ;
437
        wire portB_enable = wbr_wallow || wbw_rallow || wbw_empty || wbr_write_performed ;
438
 
439
        /*-----------------------------------------------------------------------------------------------------------
440
        Port A address generation for block SelectRam+ in SpartanII or Virtex
441
        Port A is clocked by WISHBONE clock, DIA is input for wbw_fifo, DOA is output for wbr_fifo. Address is multiplexed
442
        between two values.
443
        Address multiplexing:
444
        wbw_wenable == 1 => ADDRA = wbw_waddr (write pointer of WBW_FIFO)
445
        else                ADDRA = wbr_raddr (read pointer of WBR_FIFO)
446
        -----------------------------------------------------------------------------------------------------------*/
447
        wire [7:0] portA_addr = wbw_wallow ? {wbw_addr_prefix, wbw_waddr} : {wbr_addr_prefix, wbr_raddr_calc} ;
448
 
449
        /*-----------------------------------------------------------------------------------------------------------
450
        Port B address generation for block SelectRam+ in SpartanII or Virtex
451
        Port B is clocked by PCI clock, DIB is input for wbr_fifo, DOB is output for wbw_fifo. Address is multiplexed
452
        between two values.
453
        Address multiplexing:
454
        wbr_wenable == 1 => ADDRB = wbr_waddr (write pointer of WBR_FIFO)
455
        else                ADDRB = wbw_raddr (read pointer of WBW_FIFO)
456
        -----------------------------------------------------------------------------------------------------------*/
457
        wire [7:0] portB_addr = wbr_wallow ? {wbr_addr_prefix, wbr_waddr} : {wbw_addr_prefix, wbw_raddr_calc} ;
458
 
459
        // Block SelectRAM+ cells instantiation
460
        RAMB4_S16_S16 dpram16_1 (.ADDRA(portA_addr), .DIA(wbw_addr_data_in[15:0]),
461
                                 .ENA(portA_enable), .RSTA(reset_in),
462
                                 .CLKA(wb_clock_in), .WEA(wbw_wallow),
463
                                 .DOA(wbr_data_out[15:0]),
464
                                 .ADDRB(portB_addr), .DIB(wbr_data_in[15:0]),
465
                                 .ENB(portB_enable), .RSTB(reset_in),
466
                                 .CLKB(pci_clock_in), .WEB(wbr_wallow),
467
                                 .DOB(wbw_addr_data_out[15:0])) ;
468
 
469
        RAMB4_S16_S16 dpram16_2 (.ADDRA(portA_addr), .DIA(wbw_addr_data_in[31:16]),
470
                                 .ENA(portA_enable), .RSTA(reset_in),
471
                                 .CLKA(wb_clock_in), .WEA(wbw_wallow),
472
                                 .DOA(wbr_data_out[31:16]),
473
                                 .ADDRB(portB_addr), .DIB(wbr_data_in[31:16]),
474
                                 .ENB(portB_enable), .RSTB(reset_in),
475
                                 .CLKB(pci_clock_in), .WEB(wbr_wallow),
476
                                 .DOB(wbw_addr_data_out[31:16])) ;
477
 
478
        RAMB4_S16_S16 dpram16_3 (.ADDRA(portA_addr), .DIA({wbw_control_in, 8'h00, wbw_cbe_in}),
479
                                 .ENA(portA_enable), .RSTA(reset_in),
480
                                 .CLKA(wb_clock_in), .WEA(wbw_wallow),
481
                                 .DOA(dpram3_portA_output),
482
                                 .ADDRB(portB_addr), .DIB({wbr_control_in, 8'h00, wbr_be_in}),
483
                                 .ENB(portB_enable), .RSTB(reset_in),
484
                                 .CLKB(pci_clock_in), .WEB(wbr_wallow),
485
                                 .DOB(dpram3_portB_output)) ;
486
    `endif
487
 
488
 
489
 
490
 
491
 
492
`else
493
    wire [39:0] wbw_ram_data_out ;
494
    wire [39:0] wbw_ram_data_in = {wbw_control_in, wbw_cbe_in, wbw_addr_data_in} ;
495
    wire [39:0] wbr_ram_data_in = {wbr_control_in, wbr_be_in, wbr_data_in} ;
496
    wire [39:0] wbr_ram_data_out ;
497
    assign wbw_control_out   = wbw_ram_data_out[39:36] ;
498
    assign wbw_cbe_out       = wbw_ram_data_out[35:32] ;
499
    assign wbw_addr_data_out = wbw_ram_data_out [31:0] ;
500
 
501
    assign wbr_control_out   = wbr_ram_data_out[39:36] ;
502
    assign wbr_be_out        = wbr_ram_data_out[35:32] ;
503
    assign wbr_data_out      = wbr_ram_data_out [31:0] ;
504
 
505
    `ifdef SYNCHRONOUS
506
    /*-----------------------------------------------------------------------------------------------------------
507
    ASIC memory primitives will be added here in the near future - currently there is only some generic,
508
    behavioral dual port ram here
509
    -----------------------------------------------------------------------------------------------------------*/
510
 
511
    wire wbw_read_enable = wbw_rallow || wbw_empty ;
512
    wire wbr_read_enable = wbr_rallow || wbr_empty ;
513
 
514
    DP_SRAM #(WBW_ADDR_LENGTH, WBW_DEPTH) wbw_ram (.reset_in(reset_in), .wclock_in(wb_clock_in), .rclock_in(pci_clock_in), .data_in(wbw_ram_data_in),
515
                    .raddr_in(wbw_raddr), .waddr_in(wbw_waddr), .data_out(wbw_ram_data_out), .renable_in(wbw_read_enable), .wenable_in(wbw_wallow));
516
 
517
    DP_SRAM #(WBR_ADDR_LENGTH, WBR_DEPTH) wbr_ram (.reset_in(reset_in), .wclock_in(pci_clock_in), .rclock_in(wb_clock_in), .data_in(wbr_ram_data_in),
518
                    .raddr_in(wbr_raddr), .waddr_in(wbr_waddr), .data_out(wbr_ram_data_out), .renable_in(wbr_read_enable), .wenable_in(wbr_wallow));
519
 
520
    `else //ASYNCHRONOUS RAM
521
        DP_ASYNC_RAM #(WBW_ADDR_LENGTH, WBW_DEPTH) wbw_ram (.reset_in(reset_in), .wclock_in(wb_clock_in), .data_in(wbw_ram_data_in),
522
                    .raddr_in(wbw_raddr), .waddr_in(wbw_waddr), .data_out(wbw_ram_data_out), .wenable_in(wbw_wallow));
523
 
524
        DP_ASYNC_RAM #(WBR_ADDR_LENGTH, WBR_DEPTH) wbr_ram (.reset_in(reset_in), .wclock_in(pci_clock_in), .data_in(wbr_ram_data_in),
525
                    .raddr_in(wbr_raddr), .waddr_in(wbr_waddr), .data_out(wbr_ram_data_out), .wenable_in(wbr_wallow));
526
    `endif
527
`endif
528
 
529
/*-----------------------------------------------------------------------------------------------------------
530
Instantiation of two control logic modules - one for WBW_FIFO and one for WBR_FIFO
531
-----------------------------------------------------------------------------------------------------------*/
532
FIFO_CONTROL #(WBW_ADDR_LENGTH) wbw_fifo_ctrl
533
              (.rclock_in(pci_clock_in), .wclock_in(wb_clock_in), .renable_in(wbw_renable_in),
534
               .wenable_in(wbw_wenable_in), .reset_in(reset_in), .flush_in(wbw_flush_in),
535
               .almost_full_out(wbw_almost_full_out), .full_out(wbw_full_out),
536
               .almost_empty_out(wbw_almost_empty_out), .empty_out(wbw_empty),
537
               .waddr_out(wbw_waddr), .raddr_out(wbw_raddr),
538
               .rallow_out(wbw_rallow), .wallow_out(wbw_wallow));
539
 
540
FIFO_CONTROL #(WBR_ADDR_LENGTH) wbr_fifo_ctrl
541
              (.rclock_in(wb_clock_in), .wclock_in(pci_clock_in), .renable_in(wbr_renable_in),
542
               .wenable_in(wbr_wenable_in), .reset_in(reset_in), .flush_in(wbr_flush_in),
543
               .almost_full_out(wbr_almost_full_out), .full_out(wbr_full_out),
544
               .almost_empty_out(wbr_almost_empty_out), .empty_out(wbr_empty),
545
               .waddr_out(wbr_waddr), .raddr_out(wbr_raddr),
546
               .rallow_out(wbr_rallow), .wallow_out(wbr_wallow));
547
 
548
 
549
// in and out transaction counters
550
always@(posedge wb_clock_in or posedge wbw_clear)
551
begin
552
    if (wbw_clear)
553
        wbw_inTransactionCount <= #`FF_DELAY {WBW_ADDR_LENGTH{1'b0}} ;
554
    else
555
        if (wbw_last_in && wbw_wallow)
556
            wbw_inTransactionCount <= #`FF_DELAY wbw_inTransactionCount + 1'b1 ;
557
end
558
 
559
always@(posedge pci_clock_in or posedge wbw_clear)
560
begin
561
    if (wbw_clear)
562
        wbw_outTransactionCount <= #`FF_DELAY {WBW_ADDR_LENGTH{1'b0}} ;
563
    else
564
        if (wbw_last_out)
565
            wbw_outTransactionCount <= #`FF_DELAY wbw_outTransactionCount + 1'b1 ;
566
end
567
 
568
always@(posedge pci_clock_in or posedge wbr_clear)
569
begin
570
    if (wbr_clear)
571
        wbr_inTransactionCount <= #`FF_DELAY 1'b0 ;
572
    else
573
        if (wbr_last_in && wbr_wallow)
574
            wbr_inTransactionCount <= #`FF_DELAY ~wbr_inTransactionCount ;
575
end
576
 
577
always@(posedge wb_clock_in or posedge wbr_clear)
578
begin
579
    if (wbr_clear)
580
        wbr_outTransactionCount <= #`FF_DELAY 1'b0 ;
581
    else
582
        if (wbr_last_out)
583
            wbr_outTransactionCount <= #`FF_DELAY ~wbr_outTransactionCount ;
584
end
585
 
586
assign wbw_transaction_ready_out  = !(wbw_inTransactionCount == wbw_outTransactionCount)   ;
587
assign wbr_transaction_ready_out  = !(wbr_inTransactionCount == wbr_outTransactionCount) ;
588
 
589
endmodule
590
 

powered by: WebSVN 2.1.0

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