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.14/] [memfifo.srcs/] [sources_1/] [ip/] [mig_7series_0/] [mig_7series_0/] [user_design/] [rtl/] [phy/] [mig_7series_v2_3_ddr_if_post_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              : mig_7series_v1_x_ddr_if_post_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 IN_FIFO up to 4 entries
62
//Reference         :
63
//Revision History  :
64
//*****************************************************************************
65
 
66
`timescale 1 ps / 1 ps
67
 
68
module mig_7series_v2_3_ddr_if_post_fifo #
69
  (
70
   parameter TCQ   = 100,             // clk->out delay (sim only)
71
   parameter DEPTH = 4,               // # of entries
72
   parameter WIDTH = 32               // data bus width
73
   )
74
  (
75
   input              clk,            // clock
76
   input              rst,            // synchronous reset
77
   input [3:0]        empty_in,
78
   input              rd_en_in,
79
   input [WIDTH-1:0]  d_in,           // write data from controller
80
   output             empty_out,
81
   output             byte_rd_en,
82
   output [WIDTH-1:0] d_out           // write data to OUT_FIFO
83
   );
84
 
85
  // # of bits used to represent read/write pointers
86
  localparam PTR_BITS
87
             = (DEPTH == 2) ? 1 :
88
               (((DEPTH == 3) || (DEPTH == 4)) ? 2 : 'bx);
89
 
90
  integer i;
91
 
92
  reg [WIDTH-1:0]    mem[0:DEPTH-1];
93
  (* max_fanout = 40 *) reg [4:0]          my_empty /* synthesis syn_maxfan = 3 */;
94
  (* max_fanout = 40 *) reg [1:0]          my_full /* synthesis syn_maxfan = 3 */;
95
  reg [PTR_BITS-1:0] rd_ptr /* synthesis syn_maxfan = 10 */;
96
  // Register duplication to reduce the fan out
97
  (* KEEP = "TRUE" *) reg [PTR_BITS-1:0] rd_ptr_timing /* synthesis syn_maxfan = 10 */;
98
  reg [PTR_BITS-1:0] wr_ptr /* synthesis syn_maxfan = 10 */;
99
  wire [WIDTH-1:0]   mem_out;
100
  (* max_fanout = 40 *) wire               wr_en /* synthesis syn_maxfan = 10 */;
101
 
102
  task updt_ptrs;
103
    input rd;
104
    input wr;
105
    reg [1:0] next_rd_ptr;
106
    reg [1:0] next_wr_ptr;
107
    begin
108
      next_rd_ptr = (rd_ptr + 1'b1)%DEPTH;
109
      next_wr_ptr = (wr_ptr + 1'b1)%DEPTH;
110
      casez ({rd, wr, my_empty[1], my_full[1]})
111
        4'b00zz: ; // No access, do nothing
112
        4'b0100: begin
113
          // Write when neither empty, nor full; check for full
114
          wr_ptr  <= #TCQ next_wr_ptr;
115
          my_full[0] <= #TCQ (next_wr_ptr == rd_ptr);
116
          my_full[1] <= #TCQ (next_wr_ptr == rd_ptr);
117
          //mem[wr_ptr] <= #TCQ d_in;
118
        end
119
        4'b0110: begin
120
          // Write when empty; no need to check for full
121
          wr_ptr   <= #TCQ next_wr_ptr;
122
          my_empty <= #TCQ 5'b00000;
123
          //mem[wr_ptr] <= #TCQ d_in;
124
        end
125
        4'b1000: begin
126
          // Read when neither empty, nor full; check for empty
127
          rd_ptr   <= #TCQ next_rd_ptr;
128
          rd_ptr_timing   <= #TCQ next_rd_ptr;
129
          my_empty[0] <= #TCQ (next_rd_ptr == wr_ptr);
130
          my_empty[1] <= #TCQ (next_rd_ptr == wr_ptr);
131
          my_empty[2] <= #TCQ (next_rd_ptr == wr_ptr);
132
          my_empty[3] <= #TCQ (next_rd_ptr == wr_ptr);
133
          my_empty[4] <= #TCQ (next_rd_ptr == wr_ptr);
134
        end
135
        4'b1001: begin
136
          // Read when full; no need to check for empty
137
          rd_ptr <= #TCQ next_rd_ptr;
138
          rd_ptr_timing <= #TCQ next_rd_ptr;
139
          my_full[0] <= #TCQ 1'b0;
140
          my_full[1] <= #TCQ 1'b0;
141
        end
142
        4'b1100, 4'b1101, 4'b1110: begin
143
          // Read and write when empty, full, or neither empty/full; no need 
144
          // to check for empty or full conditions
145
          rd_ptr <= #TCQ next_rd_ptr;
146
          rd_ptr_timing <= #TCQ next_rd_ptr;
147
          wr_ptr <= #TCQ next_wr_ptr;
148
          //mem[wr_ptr] <= #TCQ d_in;
149
        end
150
        4'b0101, 4'b1010: ;
151
          // Read when empty, Write when full; Keep all pointers the same
152
          // and don't change any of the flags (i.e. ignore the read/write). 
153
          // This might happen because a faulty DQS_FOUND calibration could 
154
          // result in excessive skew between when the various IN_FIFO's
155
          // first become not empty. In this case, the data going to each
156
          // post-FIFO/IN_FIFO should be read out and discarded
157
        // synthesis translate_off
158
        default: begin
159
          // Covers any other cases, in particular for simulation if
160
          // any signals are X's
161
          $display("ERR %m @%t: Bad access: rd:%b,wr:%b,empty:%b,full:%b",
162
                   $time, rd, wr, my_empty[1], my_full[1]);
163
          rd_ptr <=  #TCQ 2'bxx;
164
          rd_ptr_timing <=  #TCQ 2'bxx;
165
          wr_ptr <=  #TCQ 2'bxx;
166
        end
167
        // synthesis translate_on
168
      endcase
169
    end
170
  endtask
171
 
172
 
173
  assign d_out = my_empty[4] ? d_in : mem_out;//mem[rd_ptr];
174
  // The combined IN_FIFO + post FIFO is only "empty" when both are empty
175
  assign empty_out = empty_in[0] & my_empty[0];
176
  assign byte_rd_en = !empty_in[3] || !my_empty[3];
177
 
178
  always @(posedge clk)
179
    if (rst) begin
180
      my_empty <=  #TCQ 5'b11111;
181
      my_full  <=  #TCQ 2'b00;
182
      rd_ptr   <=  #TCQ 'b0;
183
      rd_ptr_timing   <=  #TCQ 'b0;
184
      wr_ptr   <=  #TCQ 'b0;
185
    end else begin
186
      // Special mode: If IN_FIFO has data, and controller is reading at
187
      // the same time, then operate post-FIFO in "passthrough" mode (i.e. 
188
      // don't update any of the read/write pointers, and route IN_FIFO
189
      // data to post-FIFO data)
190
      if (my_empty[1] && !my_full[1] && rd_en_in && !empty_in[1]) ;
191
      else
192
        // Otherwise, we're writing to FIFO when IN_FIFO is not empty,
193
        // and reading from the FIFO based on the rd_en_in signal (read
194
        // enable from controller). The functino updt_ptrs should catch
195
        // an illegal conditions. 
196
        updt_ptrs(rd_en_in, !empty_in[1]);
197
    end
198
 
199
 
200
  assign wr_en = (!empty_in[2] & ((!rd_en_in & !my_full[0]) |
201
                                  (rd_en_in & !my_empty[2])));
202
 
203
 
204
  always @ (posedge clk)
205
  begin
206
    if (wr_en)
207
      mem[wr_ptr] <= #TCQ d_in;
208
  end
209
 
210
  assign mem_out = mem[rd_ptr_timing];
211
 
212
endmodule

powered by: WebSVN 2.1.0

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