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

Subversion Repositories can

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

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

powered by: WebSVN 2.1.0

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