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

Subversion Repositories can

[/] [can/] [trunk/] [rtl/] [verilog/] [can_fifo.v] - Blame information for rev 155

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  can_fifo.v                                                  ////
4
////                                                              ////
5
////                                                              ////
6
////  This file is part of the CAN Protocol Controller            ////
7
////  http://www.opencores.org/projects/can/                      ////
8
////                                                              ////
9
////                                                              ////
10
////  Author(s):                                                  ////
11
////       Igor Mohor                                             ////
12
////       igorm@opencores.org                                    ////
13
////                                                              ////
14
////                                                              ////
15
////  All additional information is available in the README.txt   ////
16
////  file.                                                       ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20 137 mohor
//// Copyright (C) 2002, 2003, 2004 Authors                       ////
21 11 mohor
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 2.1 of the License, or (at your option) any   ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE.  See the GNU Lesser General Public License for more ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.opencores.org/lgpl.shtml                     ////
42
////                                                              ////
43 28 mohor
//// The CAN protocol is developed by Robert Bosch GmbH and       ////
44
//// protected by patents. Anybody who wants to implement this    ////
45
//// CAN IP core on silicon has to obtain a CAN protocol license  ////
46
//// from Bosch.                                                  ////
47
////                                                              ////
48 11 mohor
//////////////////////////////////////////////////////////////////////
49
//
50
// CVS Revision History
51
//
52
// $Log: not supported by cvs2svn $
53 155 igorm
// Revision 1.27  2004/11/18 12:39:34  igorm
54
// Fixes for compatibility after the SW reset.
55
//
56 152 igorm
// Revision 1.26  2004/02/08 14:30:57  mohor
57
// Header changed.
58
//
59 137 mohor
// Revision 1.25  2003/10/23 16:52:17  mohor
60
// Active high/low problem when Altera devices are used. Bug fixed by
61
// Rojhalat Ibrahim.
62
//
63 134 mohor
// Revision 1.24  2003/10/17 05:55:20  markom
64
// mbist signals updated according to newest convention
65
//
66 130 markom
// Revision 1.23  2003/09/05 12:46:41  mohor
67
// ALTERA_RAM supported.
68
//
69 124 mohor
// Revision 1.22  2003/08/20 09:59:16  mohor
70
// Artisan RAM fixed (when not using BIST).
71
//
72 118 mohor
// Revision 1.21  2003/08/14 16:04:52  simons
73
// Artisan ram instances added.
74
//
75 115 simons
// Revision 1.20  2003/07/16 14:00:45  mohor
76
// Fixed according to the linter.
77
//
78 109 mohor
// Revision 1.19  2003/07/03 09:30:44  mohor
79
// PCI_BIST replaced with CAN_BIST.
80
//
81 99 mohor
// Revision 1.18  2003/06/27 22:14:23  simons
82
// Overrun fifo implemented with FFs, because it is not possible to create such a memory.
83
//
84 97 simons
// Revision 1.17  2003/06/27 20:56:15  simons
85
// Virtual silicon ram instances added.
86
//
87 95 simons
// Revision 1.16  2003/06/18 23:03:44  mohor
88
// Typo fixed.
89
//
90 85 mohor
// Revision 1.15  2003/06/11 09:37:05  mohor
91
// overrun and length_info fifos are initialized at the end of reset.
92
//
93 73 mohor
// Revision 1.14  2003/03/05 15:02:30  mohor
94
// Xilinx RAM added.
95
//
96 51 mohor
// Revision 1.13  2003/03/01 22:53:33  mohor
97
// Actel APA ram supported.
98
//
99 48 mohor
// Revision 1.12  2003/02/19 14:44:03  mohor
100
// CAN core finished. Host interface added. Registers finished.
101
// Synchronization to the wishbone finished.
102
//
103 39 mohor
// Revision 1.11  2003/02/14 20:17:01  mohor
104
// Several registers added. Not finished, yet.
105
//
106 35 mohor
// Revision 1.10  2003/02/11 00:56:06  mohor
107
// Wishbone interface added.
108
//
109 31 mohor
// Revision 1.9  2003/02/09 02:24:33  mohor
110
// Bosch license warning added. Error counters finished. Overload frames
111
// still need to be fixed.
112
//
113 28 mohor
// Revision 1.8  2003/01/31 01:13:38  mohor
114
// backup.
115
//
116 24 mohor
// Revision 1.7  2003/01/17 17:44:31  mohor
117
// Fifo corrected to be synthesizable.
118
//
119 23 mohor
// Revision 1.6  2003/01/15 13:16:47  mohor
120 31 mohor
// When a frame with "remote request" is received, no data is stored
121
// to fifo, just the frame information (identifier, ...). Data length
122
// that is stored is the received data length and not the actual data
123
// length that is stored to fifo.
124 23 mohor
//
125 18 mohor
// Revision 1.5  2003/01/14 17:25:09  mohor
126
// Addresses corrected to decimal values (previously hex).
127
//
128 17 mohor
// Revision 1.4  2003/01/14 12:19:35  mohor
129
// rx_fifo is now working.
130
//
131 16 mohor
// Revision 1.3  2003/01/09 21:54:45  mohor
132
// rx fifo added. Not 100 % verified, yet.
133
//
134 14 mohor
// Revision 1.2  2003/01/09 14:46:58  mohor
135
// Temporary files (backup).
136
//
137 13 mohor
// Revision 1.1  2003/01/08 02:10:55  mohor
138
// Acceptance filter added.
139 11 mohor
//
140
//
141
//
142 13 mohor
//
143 11 mohor
 
144
// synopsys translate_off
145
`include "timescale.v"
146
// synopsys translate_on
147
`include "can_defines.v"
148
 
149
module can_fifo
150
(
151
  clk,
152
  rst,
153
 
154
  wr,
155
 
156
  data_in,
157 14 mohor
  addr,
158 11 mohor
  data_out,
159 48 mohor
  fifo_selected,
160 11 mohor
 
161
  reset_mode,
162 14 mohor
  release_buffer,
163 35 mohor
  extended_mode,
164
  overrun,
165 39 mohor
  info_empty,
166
  info_cnt
167 13 mohor
 
168 95 simons
`ifdef CAN_BIST
169
  ,
170 130 markom
  mbist_si_i,
171
  mbist_so_o,
172
  mbist_ctrl_i
173 95 simons
`endif
174 11 mohor
);
175
 
176
parameter Tp = 1;
177
 
178
input         clk;
179
input         rst;
180
input         wr;
181
input   [7:0] data_in;
182 109 mohor
input   [5:0] addr;
183 11 mohor
input         reset_mode;
184
input         release_buffer;
185 14 mohor
input         extended_mode;
186 48 mohor
input         fifo_selected;
187 11 mohor
 
188 13 mohor
output  [7:0] data_out;
189 35 mohor
output        overrun;
190
output        info_empty;
191 39 mohor
output  [6:0] info_cnt;
192 11 mohor
 
193 95 simons
`ifdef CAN_BIST
194 130 markom
input         mbist_si_i;
195
output        mbist_so_o;
196
input [`CAN_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;       // bist chain shift control
197
wire          mbist_s_0;
198 95 simons
`endif
199
 
200 124 mohor
`ifdef ALTERA_RAM
201
`else
202 48 mohor
`ifdef ACTEL_APA_RAM
203
`else
204 51 mohor
`ifdef XILINX_RAM
205
`else
206 115 simons
`ifdef ARTISAN_RAM
207
  reg           overrun_info[0:63];
208
`else
209 95 simons
`ifdef VIRTUALSILICON_RAM
210 97 simons
  reg           overrun_info[0:63];
211 95 simons
`else
212 48 mohor
  reg     [7:0] fifo [0:63];
213
  reg     [3:0] length_fifo[0:63];
214
  reg           overrun_info[0:63];
215
`endif
216 51 mohor
`endif
217 95 simons
`endif
218 115 simons
`endif
219 124 mohor
`endif
220 11 mohor
 
221
reg     [5:0] rd_pointer;
222
reg     [5:0] wr_pointer;
223 14 mohor
reg     [5:0] read_address;
224 16 mohor
reg     [5:0] wr_info_pointer;
225
reg     [5:0] rd_info_pointer;
226 13 mohor
reg           wr_q;
227
reg     [3:0] len_cnt;
228 16 mohor
reg     [6:0] fifo_cnt;
229 24 mohor
reg     [6:0] info_cnt;
230 16 mohor
reg           latch_overrun;
231 73 mohor
reg           initialize_memories;
232 11 mohor
 
233 48 mohor
wire    [3:0] length_info;
234 13 mohor
wire          write_length_info;
235 16 mohor
wire          fifo_empty;
236
wire          fifo_full;
237 24 mohor
wire          info_full;
238 11 mohor
 
239 13 mohor
assign write_length_info = (~wr) & wr_q;
240
 
241
// Delayed write signal
242
always @ (posedge clk or posedge rst)
243
begin
244
  if (rst)
245 109 mohor
    wr_q <=#Tp 1'b0;
246 13 mohor
  else if (reset_mode)
247 109 mohor
    wr_q <=#Tp 1'b0;
248 13 mohor
  else
249
    wr_q <=#Tp wr;
250
end
251
 
252
 
253
// length counter
254
always @ (posedge clk or posedge rst)
255
begin
256
  if (rst)
257 109 mohor
    len_cnt <= 4'h0;
258 13 mohor
  else if (reset_mode | write_length_info)
259 109 mohor
    len_cnt <=#Tp 4'h0;
260 16 mohor
  else if (wr & (~fifo_full))
261 13 mohor
    len_cnt <=#Tp len_cnt + 1'b1;
262
end
263
 
264
 
265
// wr_info_pointer
266
always @ (posedge clk or posedge rst)
267
begin
268
  if (rst)
269 109 mohor
    wr_info_pointer <= 6'h0;
270 73 mohor
  else if (write_length_info & (~info_full) | initialize_memories)
271
    wr_info_pointer <=#Tp wr_info_pointer + 1'b1;
272 13 mohor
  else if (reset_mode)
273 152 igorm
    wr_info_pointer <=#Tp rd_info_pointer;
274 13 mohor
end
275
 
276
 
277
 
278
// rd_info_pointer
279 11 mohor
always @ (posedge clk or posedge rst)
280
begin
281
  if (rst)
282 109 mohor
    rd_info_pointer <= 6'h0;
283 155 igorm
  else if (release_buffer & (~info_full))
284 13 mohor
    rd_info_pointer <=#Tp rd_info_pointer + 1'b1;
285 11 mohor
end
286
 
287
 
288
// rd_pointer
289
always @ (posedge clk or posedge rst)
290
begin
291
  if (rst)
292 109 mohor
    rd_pointer <= 5'h0;
293 16 mohor
  else if (release_buffer & (~fifo_empty))
294 109 mohor
    rd_pointer <=#Tp rd_pointer + {2'h0, length_info};
295 11 mohor
end
296
 
297
 
298
// wr_pointer
299
always @ (posedge clk or posedge rst)
300
begin
301
  if (rst)
302 109 mohor
    wr_pointer <= 5'h0;
303 152 igorm
  else if (reset_mode)
304
    wr_pointer <=#Tp rd_pointer;
305 16 mohor
  else if (wr & (~fifo_full))
306 13 mohor
    wr_pointer <=#Tp wr_pointer + 1'b1;
307 11 mohor
end
308
 
309
 
310 16 mohor
// latch_overrun
311
always @ (posedge clk or posedge rst)
312
begin
313
  if (rst)
314 109 mohor
    latch_overrun <= 1'b0;
315 16 mohor
  else if (reset_mode | write_length_info)
316 109 mohor
    latch_overrun <=#Tp 1'b0;
317 16 mohor
  else if (wr & fifo_full)
318
    latch_overrun <=#Tp 1'b1;
319
end
320
 
321
 
322
// Counting data in fifo
323
always @ (posedge clk or posedge rst)
324
begin
325
  if (rst)
326 109 mohor
    fifo_cnt <= 7'h0;
327 152 igorm
  else if (reset_mode)
328
    fifo_cnt <=#Tp 7'h0;
329 16 mohor
  else if (wr & (~release_buffer) & (~fifo_full))
330
    fifo_cnt <=#Tp fifo_cnt + 1'b1;
331
  else if ((~wr) & release_buffer & (~fifo_empty))
332 109 mohor
    fifo_cnt <=#Tp fifo_cnt - {3'h0, length_info};
333 16 mohor
  else if (wr & release_buffer & (~fifo_full) & (~fifo_empty))
334 109 mohor
    fifo_cnt <=#Tp fifo_cnt - {3'h0, length_info} + 1'b1;
335 16 mohor
end
336
 
337 109 mohor
assign fifo_full = fifo_cnt == 7'd64;
338
assign fifo_empty = fifo_cnt == 7'd0;
339 16 mohor
 
340
 
341 48 mohor
// Counting data in length_fifo and overrun_info fifo
342 24 mohor
always @ (posedge clk or posedge rst)
343
begin
344
  if (rst)
345 109 mohor
    info_cnt <=#Tp 7'h0;
346
  else if (reset_mode)
347
    info_cnt <=#Tp 7'h0;
348 24 mohor
  else if (write_length_info ^ release_buffer)
349
    begin
350
      if (release_buffer & (~info_empty))
351
        info_cnt <=#Tp info_cnt - 1'b1;
352
      else if (write_length_info & (~info_full))
353
        info_cnt <=#Tp info_cnt + 1'b1;
354
    end
355
end
356
 
357 109 mohor
assign info_full = info_cnt == 7'd64;
358
assign info_empty = info_cnt == 7'd0;
359 16 mohor
 
360 24 mohor
 
361 14 mohor
// Selecting which address will be used for reading data from rx fifo
362
always @ (extended_mode or rd_pointer or addr)
363
begin
364
  if (extended_mode)      // extended mode
365 109 mohor
    read_address = rd_pointer + (addr - 6'd16);
366 14 mohor
  else                    // normal mode
367 109 mohor
    read_address = rd_pointer + (addr - 6'd20);
368 14 mohor
end
369 11 mohor
 
370
 
371 73 mohor
always @ (posedge clk or posedge rst)
372
begin
373
  if (rst)
374 109 mohor
    initialize_memories <= 1'b1;
375 73 mohor
  else if (&wr_info_pointer)
376
    initialize_memories <=#Tp 1'b0;
377
end
378 14 mohor
 
379 73 mohor
 
380 124 mohor
`ifdef ALTERA_RAM
381
//  altera_ram_64x8_sync fifo
382
  lpm_ram_dp fifo
383
  (
384
    .q         (data_out),
385
    .rdclock   (clk),
386
    .wrclock   (clk),
387
    .data      (data_in),
388 134 mohor
    .wren      (wr & (~fifo_full)),
389
    .rden      (fifo_selected),
390 124 mohor
    .wraddress (wr_pointer),
391
    .rdaddress (read_address)
392
  );
393
  defparam fifo.lpm_width = 8;
394
  defparam fifo.lpm_widthad = 6;
395 134 mohor
  defparam fifo.lpm_numwords = 64;
396 124 mohor
 
397
 
398
//  altera_ram_64x4_sync info_fifo
399
  lpm_ram_dp info_fifo
400
  (
401
    .q         (length_info),
402
    .rdclock   (clk),
403
    .wrclock   (clk),
404
    .data      (len_cnt & {4{~initialize_memories}}),
405 134 mohor
    .wren      (write_length_info & (~info_full) | initialize_memories),
406 124 mohor
    .wraddress (wr_info_pointer),
407
    .rdaddress (rd_info_pointer)
408
  );
409
  defparam info_fifo.lpm_width = 4;
410
  defparam info_fifo.lpm_widthad = 6;
411 134 mohor
  defparam info_fifo.lpm_numwords = 64;
412 124 mohor
 
413
 
414
//  altera_ram_64x1_sync overrun_fifo
415
  lpm_ram_dp overrun_fifo
416
  (
417
    .q         (overrun),
418
    .rdclock   (clk),
419
    .wrclock   (clk),
420
    .data      ((latch_overrun | (wr & fifo_full)) & (~initialize_memories)),
421 134 mohor
    .wren      (write_length_info & (~info_full) | initialize_memories),
422 124 mohor
    .wraddress (wr_info_pointer),
423
    .rdaddress (rd_info_pointer)
424
  );
425
  defparam overrun_fifo.lpm_width = 1;
426
  defparam overrun_fifo.lpm_widthad = 6;
427 134 mohor
  defparam overrun_fifo.lpm_numwords = 64;
428 124 mohor
 
429
`else
430 48 mohor
`ifdef ACTEL_APA_RAM
431
  actel_ram_64x8_sync fifo
432
  (
433
    .DO      (data_out),
434
    .RCLOCK  (clk),
435
    .WCLOCK  (clk),
436
    .DI      (data_in),
437
    .PO      (),                       // parity not used
438
    .WRB     (~(wr & (~fifo_full))),
439
    .RDB     (~fifo_selected),
440
    .WADDR   (wr_pointer),
441
    .RADDR   (read_address)
442
  );
443 14 mohor
 
444
 
445 48 mohor
  actel_ram_64x4_sync info_fifo
446
  (
447
    .DO      (length_info),
448
    .RCLOCK  (clk),
449
    .WCLOCK  (clk),
450 73 mohor
    .DI      (len_cnt & {4{~initialize_memories}}),
451 48 mohor
    .PO      (),                       // parity not used
452 73 mohor
    .WRB     (~(write_length_info & (~info_full) | initialize_memories)),
453 48 mohor
    .RDB     (1'b0),                   // always enabled
454
    .WADDR   (wr_info_pointer),
455
    .RADDR   (rd_info_pointer)
456
  );
457 14 mohor
 
458
 
459 48 mohor
  actel_ram_64x1_sync overrun_fifo
460
  (
461
    .DO      (overrun),
462
    .RCLOCK  (clk),
463
    .WCLOCK  (clk),
464 73 mohor
    .DI      ((latch_overrun | (wr & fifo_full)) & (~initialize_memories)),
465 48 mohor
    .PO      (),                       // parity not used
466 73 mohor
    .WRB     (~(write_length_info & (~info_full) | initialize_memories)),
467 48 mohor
    .RDB     (1'b0),                   // always enabled
468
    .WADDR   (wr_info_pointer),
469
    .RADDR   (rd_info_pointer)
470
  );
471
`else
472 51 mohor
`ifdef XILINX_RAM
473
 
474
  RAMB4_S8_S8 fifo
475
  (
476
    .DOA(),
477
    .DOB(data_out),
478
    .ADDRA({3'h0, wr_pointer}),
479
    .CLKA(clk),
480
    .DIA(data_in),
481
    .ENA(1'b1),
482
    .RSTA(1'b0),
483
    .WEA(wr & (~fifo_full)),
484
    .ADDRB({3'h0, read_address}),
485
    .CLKB(clk),
486
    .DIB(8'h0),
487
    .ENB(1'b1),
488
    .RSTB(1'b0),
489
    .WEB(1'b0)
490
  );
491
 
492
 
493
  RAMB4_S4_S4 info_fifo
494
  (
495
    .DOA(),
496
    .DOB(length_info),
497
    .ADDRA({4'h0, wr_info_pointer}),
498
    .CLKA(clk),
499 73 mohor
    .DIA(len_cnt & {4{~initialize_memories}}),
500 51 mohor
    .ENA(1'b1),
501
    .RSTA(1'b0),
502 73 mohor
    .WEA(write_length_info & (~info_full) | initialize_memories),
503 51 mohor
    .ADDRB({4'h0, rd_info_pointer}),
504
    .CLKB(clk),
505
    .DIB(4'h0),
506
    .ENB(1'b1),
507
    .RSTB(1'b0),
508
    .WEB(1'b0)
509
  );
510
 
511
 
512
  RAMB4_S1_S1 overrun_fifo
513
  (
514
    .DOA(),
515
    .DOB(overrun),
516
    .ADDRA({6'h0, wr_info_pointer}),
517
    .CLKA(clk),
518 73 mohor
    .DIA((latch_overrun | (wr & fifo_full)) & (~initialize_memories)),
519 51 mohor
    .ENA(1'b1),
520
    .RSTA(1'b0),
521 73 mohor
    .WEA(write_length_info & (~info_full) | initialize_memories),
522 51 mohor
    .ADDRB({6'h0, rd_info_pointer}),
523
    .CLKB(clk),
524
    .DIB(1'h0),
525
    .ENB(1'b1),
526
    .RSTB(1'b0),
527
    .WEB(1'b0)
528
  );
529
 
530
 
531
`else
532 95 simons
`ifdef VIRTUALSILICON_RAM
533
 
534 99 mohor
`ifdef CAN_BIST
535 95 simons
    vs_hdtp_64x8_bist fifo
536
`else
537
    vs_hdtp_64x8 fifo
538
`endif
539
    (
540
        .RCK        (clk),
541
        .WCK        (clk),
542
        .RADR       (read_address),
543
        .WADR       (wr_pointer),
544
        .DI         (data_in),
545
        .DOUT       (data_out),
546
        .REN        (~fifo_selected),
547
        .WEN        (~(wr & (~fifo_full)))
548 99 mohor
    `ifdef CAN_BIST
549 95 simons
        ,
550
        // debug chain signals
551 130 markom
        .mbist_si_i   (mbist_si_i),
552
        .mbist_so_o   (mbist_s_0),
553
        .mbist_ctrl_i   (mbist_ctrl_i)
554 95 simons
    `endif
555
    );
556
 
557 99 mohor
`ifdef CAN_BIST
558 95 simons
    vs_hdtp_64x4_bist info_fifo
559
`else
560
    vs_hdtp_64x4 info_fifo
561
`endif
562
    (
563
        .RCK        (clk),
564
        .WCK        (clk),
565
        .RADR       (rd_info_pointer),
566
        .WADR       (wr_info_pointer),
567
        .DI         (len_cnt & {4{~initialize_memories}}),
568
        .DOUT       (length_info),
569
        .REN        (1'b0),
570
        .WEN        (~(write_length_info & (~info_full) | initialize_memories))
571 99 mohor
    `ifdef CAN_BIST
572 95 simons
        ,
573
        // debug chain signals
574 130 markom
        .mbist_si_i   (mbist_s_0),
575
        .mbist_so_o   (mbist_so_o),
576
        .mbist_ctrl_i   (mbist_ctrl_i)
577 95 simons
    `endif
578
    );
579
 
580 97 simons
    // overrun_info
581
    always @ (posedge clk)
582
    begin
583
      if (write_length_info & (~info_full) | initialize_memories)
584
        overrun_info[wr_info_pointer] <=#Tp (latch_overrun | (wr & fifo_full)) & (~initialize_memories);
585
    end
586
 
587
 
588
    // reading overrun
589
    assign overrun = overrun_info[rd_info_pointer];
590
 
591 95 simons
`else
592 115 simons
`ifdef ARTISAN_RAM
593
 
594
`ifdef CAN_BIST
595
    art_hstp_64x8_bist fifo
596
    (
597
        .CLKR       (clk),
598
        .CLKW       (clk),
599
        .AR         (read_address),
600
        .AW         (wr_pointer),
601
        .D          (data_in),
602
        .Q          (data_out),
603
        .REN        (~fifo_selected),
604
        .WEN        (~(wr & (~fifo_full))),
605 130 markom
        .mbist_si_i   (mbist_si_i),
606
        .mbist_so_o   (mbist_s_0),
607
        .mbist_ctrl_i   (mbist_ctrl_i)
608 115 simons
    );
609
    art_hstp_64x4_bist info_fifo
610
    (
611
        .CLKR       (clk),
612
        .CLKW       (clk),
613
        .AR         (rd_info_pointer),
614
        .AW         (wr_info_pointer),
615
        .D          (len_cnt & {4{~initialize_memories}}),
616
        .Q          (length_info),
617
        .REN        (1'b0),
618
        .WEN        (~(write_length_info & (~info_full) | initialize_memories)),
619 130 markom
        .mbist_si_i   (mbist_s_0),
620
        .mbist_so_o   (mbist_so_o),
621
        .mbist_ctrl_i   (mbist_ctrl_i)
622 115 simons
    );
623
`else
624
    art_hsdp_64x8 fifo
625
    (
626
        .CENA       (1'b0),
627
        .CENB       (1'b0),
628
        .CLKA       (clk),
629
        .CLKB       (clk),
630
        .AA         (read_address),
631
        .AB         (wr_pointer),
632
        .DA         (8'h00),
633
        .DB         (data_in),
634
        .QA         (data_out),
635
        .QB         (),
636 118 mohor
        .OENA       (~fifo_selected),
637
        .OENB       (1'b1),
638 115 simons
        .WENA       (1'b1),
639 118 mohor
        .WENB       (~(wr & (~fifo_full)))
640 115 simons
    );
641
    art_hsdp_64x4 info_fifo
642
    (
643
        .CENA       (1'b0),
644
        .CENB       (1'b0),
645
        .CLKA       (clk),
646
        .CLKB       (clk),
647
        .AA         (rd_info_pointer),
648
        .AB         (wr_info_pointer),
649
        .DA         (4'h0),
650
        .DB         (len_cnt & {4{~initialize_memories}}),
651
        .QA         (length_info),
652
        .QB         (),
653 118 mohor
        .OENA       (1'b0),
654
        .OENB       (1'b1),
655
        .WENA       (1'b1),
656 115 simons
        .WENB       (~(write_length_info & (~info_full) | initialize_memories))
657
    );
658
`endif
659
 
660
    // overrun_info
661
    always @ (posedge clk)
662
    begin
663
      if (write_length_info & (~info_full) | initialize_memories)
664
        overrun_info[wr_info_pointer] <=#Tp (latch_overrun | (wr & fifo_full)) & (~initialize_memories);
665
    end
666
 
667
 
668
    // reading overrun
669
    assign overrun = overrun_info[rd_info_pointer];
670
 
671
`else
672 48 mohor
  // writing data to fifo
673
  always @ (posedge clk)
674
  begin
675
    if (wr & (~fifo_full))
676
      fifo[wr_pointer] <=#Tp data_in;
677
  end
678
 
679
  // reading from fifo
680
  assign data_out = fifo[read_address];
681
 
682
 
683
  // writing length_fifo
684
  always @ (posedge clk)
685
  begin
686 85 mohor
    if (write_length_info & (~info_full) | initialize_memories)
687 73 mohor
      length_fifo[wr_info_pointer] <=#Tp len_cnt & {4{~initialize_memories}};
688 48 mohor
  end
689
 
690 73 mohor
 
691 48 mohor
  // reading length_fifo
692
  assign length_info = length_fifo[rd_info_pointer];
693
 
694
  // overrun_info
695
  always @ (posedge clk)
696
  begin
697 73 mohor
    if (write_length_info & (~info_full) | initialize_memories)
698
      overrun_info[wr_info_pointer] <=#Tp (latch_overrun | (wr & fifo_full)) & (~initialize_memories);
699 48 mohor
  end
700
 
701
 
702
  // reading overrun
703
  assign overrun = overrun_info[rd_info_pointer];
704
 
705
 
706
`endif
707 51 mohor
`endif
708 95 simons
`endif
709 115 simons
`endif
710 124 mohor
`endif
711 48 mohor
 
712
 
713
 
714
 
715
 
716 11 mohor
endmodule

powered by: WebSVN 2.1.0

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