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

Subversion Repositories usb_fpga_2_14

[/] [usb_fpga_2_14/] [trunk/] [examples/] [memfifo/] [fpga-2.13/] [memfifo.srcs/] [sources_1/] [ip/] [mig_7series_0/] [mig_7series_0/] [user_design/] [rtl/] [phy/] [mig_7series_v2_3_ddr_of_pre_fifo.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
//*****************************************************************************
2
// (c) Copyright 2008 - 2013 Xilinx, Inc. All rights reserved.
3
//
4
// This file contains confidential and proprietary information
5
// of Xilinx, Inc. and is protected under U.S. and
6
// international copyright and other intellectual property
7
// laws.
8
//
9
// DISCLAIMER
10
// This disclaimer is not a license and does not grant any
11
// rights to the materials distributed herewith. Except as
12
// otherwise provided in a valid license issued to you by
13
// Xilinx, and to the maximum extent permitted by applicable
14
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
15
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
16
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
17
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
18
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
19
// (2) Xilinx shall not be liable (whether in contract or tort,
20
// including negligence, or under any other theory of
21
// liability) for any loss or damage of any kind or nature
22
// related to, arising under or in connection with these
23
// materials, including for any direct, or any indirect,
24
// special, incidental, or consequential loss or damage
25
// (including loss of data, profits, goodwill, or any type of
26
// loss or damage suffered as a result of any action brought
27
// by a third party) even if such damage or loss was
28
// reasonably foreseeable or Xilinx had been advised of the
29
// possibility of the same.
30
//
31
// CRITICAL APPLICATIONS
32
// Xilinx products are not designed or intended to be fail-
33
// safe, or for use in any application requiring fail-safe
34
// performance, such as life-support or safety devices or
35
// systems, Class III medical devices, nuclear facilities,
36
// applications related to the deployment of airbags, or any
37
// other applications that could lead to death, personal
38
// injury, or severe property or environmental damage
39
// (individually and collectively, "Critical
40
// Applications"). Customer assumes the sole risk and
41
// liability of any use of Xilinx products in Critical
42
// Applications, subject only to applicable laws and
43
// regulations governing limitations on product liability.
44
//
45
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
46
// PART OF THIS FILE AT ALL TIMES.
47
//
48
//*****************************************************************************
49
//   ____  ____
50
//  /   /\/   /
51
// /___/  \  /    Vendor                : Xilinx
52
// \   \   \/     Version               : %version
53
//  \   \         Application           : MIG
54
//  /   /         Filename              : ddr_of_pre_fifo.v
55
// /___/   /\     Date Last Modified    : $date$
56
// \   \  /  \    Date Created          : Feb 08 2011
57
//  \___\/\___\
58
//
59
//Device            : 7 Series
60
//Design Name       : DDR3 SDRAM
61
//Purpose           : Extends the depth of a PHASER OUT_FIFO up to 4 entries
62
//Reference         :
63
//Revision History  :
64
//*****************************************************************************
65
 
66
/******************************************************************************
67
**$Id: ddr_of_pre_fifo.v,v 1.1 2011/06/02 08:35:07 mishra Exp $
68
**$Date: 2011/06/02 08:35:07 $
69
**$Author: mishra $
70
**$Revision: 1.1 $
71
**$Source: /devl/xcs/repo/env/Databases/ip/src2/O/mig_7series_v1_3/data/dlib/7series/ddr3_sdram/verilog/rtl/phy/ddr_of_pre_fifo.v,v $
72
******************************************************************************/
73
 
74
`timescale 1 ps / 1 ps
75
 
76
module mig_7series_v2_3_ddr_of_pre_fifo #
77
  (
78
   parameter TCQ   = 100,             // clk->out delay (sim only)
79
   parameter DEPTH = 4,               // # of entries
80
   parameter WIDTH = 32               // data bus width
81
   )
82
  (
83
   input              clk,            // clock
84
   input              rst,            // synchronous reset
85
   input              full_in,        // FULL flag from OUT_FIFO
86
   input              wr_en_in,       // write enable from controller
87
   input [WIDTH-1:0]  d_in,           // write data from controller
88
   output             wr_en_out,      // write enable to OUT_FIFO
89
   output [WIDTH-1:0] d_out,          // write data to OUT_FIFO
90
   output             afull           // almost full signal to controller
91
   );
92
 
93
  // # of bits used to represent read/write pointers
94
  localparam PTR_BITS
95
             = (DEPTH == 2) ? 1 :
96
               ((DEPTH == 3) || (DEPTH == 4)) ? 2 :
97
               (((DEPTH == 5) || (DEPTH == 6) ||
98
                 (DEPTH == 7) || (DEPTH == 8)) ? 3 :
99
                  DEPTH == 9 ? 4 : 'bx);
100
 
101
  // Set watermark. Always give the MC 5 cycles to engage flow control.
102
  localparam ALMOST_FULL_VALUE = DEPTH - 5;
103
 
104
  integer i;
105
 
106
  reg [WIDTH-1:0]    mem[0:DEPTH-1] ;
107
  reg [8:0]          my_empty /* synthesis syn_maxfan = 3 */;
108
  reg [5:0]          my_full /* synthesis syn_maxfan = 3 */;
109
  reg [PTR_BITS-1:0] rd_ptr /* synthesis syn_maxfan = 10 */;
110
  reg [PTR_BITS-1:0] wr_ptr /* synthesis syn_maxfan = 10 */;
111
  (* KEEP = "TRUE", max_fanout = 50 *) reg [PTR_BITS-1:0] rd_ptr_timing /* synthesis syn_maxfan = 10 */;
112
  (* KEEP = "TRUE", max_fanout = 50 *) reg [PTR_BITS-1:0] wr_ptr_timing /* synthesis syn_maxfan = 10 */;
113
  reg [PTR_BITS:0] entry_cnt;
114
  wire [PTR_BITS-1:0] nxt_rd_ptr;
115
  wire [PTR_BITS-1:0] nxt_wr_ptr;
116
  wire [WIDTH-1:0] mem_out;
117
  (* max_fanout = 50 *) wire wr_en;
118
 
119
  assign d_out = my_empty[0] ? d_in : mem_out;
120
  assign wr_en_out = !full_in && (!my_empty[1] || wr_en_in);
121
  assign wr_en = wr_en_in & ((!my_empty[3] & !full_in)|(!my_full[2] & full_in));
122
 
123
  always @ (posedge clk)
124
    if (wr_en)
125
      mem[wr_ptr] <= #TCQ d_in;
126
 
127
  assign mem_out = mem[rd_ptr];
128
 
129
  assign nxt_rd_ptr = (rd_ptr + 1'b1)%DEPTH;
130
 
131
  always @ (posedge clk)
132
  begin
133
    if (rst) begin
134
      rd_ptr <= 'b0;
135
      rd_ptr_timing <= 'b0;
136
    end
137
    else if ((!my_empty[4]) & (!full_in)) begin
138
      rd_ptr <= nxt_rd_ptr;
139
      rd_ptr_timing <= nxt_rd_ptr;
140
    end
141
  end
142
 
143
  always @ (posedge clk)
144
  begin
145
    if (rst)
146
      my_empty <= 9'h1ff;
147
    else begin
148
      if (my_empty[2] & !my_full[3] & full_in & wr_en_in)
149
        my_empty[3:0] <= 4'b0000;
150
      else if (!my_empty[2] & !my_full[3] & !full_in & !wr_en_in) begin
151
        my_empty[0] <= (nxt_rd_ptr == wr_ptr_timing);
152
        my_empty[1] <= (nxt_rd_ptr == wr_ptr_timing);
153
        my_empty[2] <= (nxt_rd_ptr == wr_ptr_timing);
154
        my_empty[3] <= (nxt_rd_ptr == wr_ptr_timing);
155
      end
156
      if (my_empty[8] & !my_full[5] & full_in & wr_en_in)
157
        my_empty[8:4] <= 5'b00000;
158
      else if (!my_empty[8] & !my_full[5] & !full_in & !wr_en_in) begin
159
        my_empty[4] <= (nxt_rd_ptr == wr_ptr_timing);
160
        my_empty[5] <= (nxt_rd_ptr == wr_ptr_timing);
161
        my_empty[6] <= (nxt_rd_ptr == wr_ptr_timing);
162
        my_empty[7] <= (nxt_rd_ptr == wr_ptr_timing);
163
        my_empty[8] <= (nxt_rd_ptr == wr_ptr_timing);
164
      end
165
    end
166
  end
167
 
168
  assign nxt_wr_ptr = (wr_ptr + 1'b1)%DEPTH;
169
 
170
  always @ (posedge clk)
171
  begin
172
    if (rst) begin
173
      wr_ptr <= 'b0;
174
      wr_ptr_timing <= 'b0;
175
    end
176
    else if ((wr_en_in) & ((!my_empty[5] & !full_in) | (!my_full[1] & full_in))) begin
177
      wr_ptr <= nxt_wr_ptr;
178
      wr_ptr_timing <= nxt_wr_ptr;
179
    end
180
  end
181
 
182
  always @ (posedge clk)
183
  begin
184
    if (rst)
185
      my_full <= 6'b000000;
186
    else if (!my_empty[6] & my_full[0] & !full_in & !wr_en_in)
187
      my_full <= 6'b000000;
188
    else if (!my_empty[6] & !my_full[0] & full_in & wr_en_in) begin
189
      my_full[0] <= (nxt_wr_ptr == rd_ptr_timing);
190
      my_full[1] <= (nxt_wr_ptr == rd_ptr_timing);
191
      my_full[2] <= (nxt_wr_ptr == rd_ptr_timing);
192
      my_full[3] <= (nxt_wr_ptr == rd_ptr_timing);
193
      my_full[4] <= (nxt_wr_ptr == rd_ptr_timing);
194
      my_full[5] <= (nxt_wr_ptr == rd_ptr_timing);
195
    end
196
  end
197
 
198
  always @ (posedge clk)
199
  begin
200
    if (rst)
201
      entry_cnt <= 'b0;
202
    else if (wr_en_in & full_in & !my_full[4])
203
      entry_cnt <= entry_cnt + 1'b1;
204
    else if (!wr_en_in & !full_in & !my_empty[7])
205
      entry_cnt <= entry_cnt - 1'b1;
206
  end
207
 
208
  assign afull = (entry_cnt >= ALMOST_FULL_VALUE);
209
 
210
endmodule

powered by: WebSVN 2.1.0

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