Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / niu_smx_req_sii_cr.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: niu_smx_req_sii_cr.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
36module niu_smx_req_sii_cr(
37/*AUTOARG*/
38 // Outputs
39 ocr_avail, bcr_avail,
40 // Inputs
41 clk, reset_l,
42 sii_niu_oqdq, sii_niu_bqdq, o_enq, b_enq
43 );
44
45input clk;
46input reset_l;
47
48// sii if
49input sii_niu_oqdq;
50input sii_niu_bqdq;
51
52// arb if
53input o_enq;
54input b_enq;
55output ocr_avail;
56output bcr_avail;
57
58
59reg [4:0] order_cr;
60reg [4:0] bypass_cr;
61
62reg sii_niu_oqdq_r, sii_niu_bqdq_r;
63always @(posedge clk) begin
64 if(!reset_l) begin
65 sii_niu_oqdq_r<= `SMX_PD 1'b0;
66 sii_niu_bqdq_r<= `SMX_PD 1'b0;
67 end
68 else begin
69 sii_niu_oqdq_r<= `SMX_PD sii_niu_oqdq;
70 sii_niu_bqdq_r<= `SMX_PD sii_niu_bqdq;
71 end
72end
73
74wire o_deq= sii_niu_oqdq_r;
75wire b_deq= sii_niu_bqdq_r;
76
77wire inc_ocr_n= o_deq & ~o_enq;
78wire dec_ocr_n= ~o_deq & o_enq;
79
80wire inc_bcr_n= b_deq & ~b_enq;
81wire dec_bcr_n= ~b_deq & b_enq;
82
83
84 // clamp cr in case over
85wire [4:0] inc_order_cr_n= (order_cr==`SMX_SII_MAX_ORD_CR)? `SMX_SII_MAX_ORD_CR :
86 order_cr + 1'b1;
87wire [4:0] dec_order_cr_n= (order_cr==5'h0)? 5'h0 : order_cr - 1'b1;
88
89wire [4:0] inc_bypass_cr_n= (bypass_cr==`SMX_SII_MAX_BYP_CR)? `SMX_SII_MAX_BYP_CR :
90 bypass_cr + 1'b1;
91wire [4:0] dec_bypass_cr_n= (bypass_cr==5'h0)? 5'h0 : bypass_cr - 1'b1;
92
93always @(posedge clk) begin
94 if(!reset_l) begin
95 order_cr<= `SMX_PD `SMX_SII_MAX_ORD_CR;
96 bypass_cr<= `SMX_PD `SMX_SII_MAX_BYP_CR;
97 end
98 else begin
99 if(inc_ocr_n) order_cr<= `SMX_PD inc_order_cr_n;
100 else if(dec_ocr_n) order_cr<= `SMX_PD dec_order_cr_n;
101 if(inc_bcr_n) bypass_cr<= `SMX_PD inc_bypass_cr_n;
102 else if(dec_bcr_n) bypass_cr<= `SMX_PD dec_bypass_cr_n;
103 end
104end
105
106wire ocr_avail= |order_cr;
107wire bcr_avail= |bypass_cr;
108
109endmodule
110
111
112