Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / fflp_hdr_fifo.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: fflp_hdr_fifo.v
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35/**********************************************************************/
36/*project name: NIU */
37/*module name: fflp_hdr_fifo */
38/*description: contains the data storage for hdr fields and packet */
39/* status. */
40/* */
41/*parent module in: */
42/*child modules in: none */
43/*interface modules: */
44/*author name: Jeanne Cai */
45/*date created: 03-17-04 */
46/* */
47/* Copyright (c) 2004, Sun Microsystems, Inc. */
48/* Sun Proprietary and Confidential */
49/* */
50/*modifications: */
51/* */
52module fflp_hdr_fifo
53 (
54 clk,
55 reset,
56 dout,
57 hdr_fifo_empty,
58 hdr_fifo_full,
59 din,
60 wen,
61 ren
62 );
63
64parameter dwidth = 16;
65
66input clk;
67input reset;
68input [dwidth-1:0] din;
69input wen; //increments wptr and writes in din
70input ren; //increments rptr
71
72output [dwidth-1:0] dout;
73output hdr_fifo_empty;
74output hdr_fifo_full;
75
76
77wire[dwidth-1:0] dout;
78
79reg[dwidth-1:0] data_mem[0:3];
80reg[2:0] wptr;
81reg[2:0] rptr;
82
83wire[1:0] wptr1 = wptr[1:0];
84wire[1:0] rptr1 = rptr[1:0];
85
86wire hdr_fifo_full = (wptr[2] != rptr[2]) & (wptr1 == rptr1);
87wire hdr_fifo_empty = (wptr[2] == rptr[2]) & (wptr1 == rptr1);
88
89always @(posedge clk)
90if (wen)
91 data_mem[wptr1] <= din;
92
93assign dout = data_mem[rptr1];
94
95always @(posedge clk)
96if (reset)
97 wptr <= 3'b0;
98else if (wen)
99 wptr <= wptr + 3'd1;
100else
101 wptr <= wptr;
102
103always @(posedge clk)
104if (reset)
105 rptr <= 3'b0;
106else if (ren)
107 rptr <= rptr + 3'd1;
108else
109 rptr <= rptr;
110
111
112endmodule