Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / pcie_common / rtl / pcie_common_dcb.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: pcie_common_dcb.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 ============================================
35module pcie_common_dcb
36 (
37 csr_byp_ring_out, // bypass ring out
38 csr_ext_ring_out, // extended ring out
39 clk, // clock
40 rst_l, // reset
41 byp_src, // bypass source bus
42 csr_byp_ring_in, // bypass ring in
43 csr_ext_ring_in // extended ring in
44 );
45
46// ----------------------------------------------------------------------------
47// Parameters
48// ----------------------------------------------------------------------------
49 parameter IDLE = 3'b000, // state machine states
50 ERMS = 3'b100,
51 ERLS = 3'b101,
52 BRMS = 3'b110,
53 BRLS = 3'b111;
54
55// ----------------------------------------------------------------------------
56// Ports
57// ----------------------------------------------------------------------------
58 output [`FIRE_CSR_RING_BITS] csr_byp_ring_out;
59 output [`FIRE_CSR_RING_BITS] csr_ext_ring_out;
60
61 input clk;
62 input rst_l;
63 input [`FIRE_CSR_SRCB_BITS] byp_src;
64 input [`FIRE_CSR_RING_BITS] csr_byp_ring_in;
65 input [`FIRE_CSR_RING_BITS] csr_ext_ring_in;
66
67// ----------------------------------------------------------------------------
68// Variables
69// ----------------------------------------------------------------------------
70 wire [`FIRE_CSR_RING_BITS] csr_byp_ring_out, nxt_byp_ring;
71 wire [`FIRE_CSR_RING_BITS] csr_ext_ring_out, nxt_ext_ring;
72 wire [`FIRE_CSR_CMND_BITS] cmd;
73 wire [`FIRE_CSR_SRCB_BITS] src;
74
75 reg [`FIRE_CSR_RING_BITS] byp_ring;
76 reg [`FIRE_CSR_RING_BITS] ext_ring;
77 reg [2:0] state, nxt_state;
78 reg sel;
79
80// ----------------------------------------------------------------------------
81// Zero In Checkers
82// ----------------------------------------------------------------------------
83
84 // 0in known_driven -var state -active rst_l
85 // 0in state_transition -var state -val IDLE -next ERMS BRMS
86 // 0in state_transition -var state -val ERMS -next ERLS
87 // 0in state_transition -var state -val ERLS -next IDLE
88 // 0in state_transition -var state -val BRMS -next BRLS
89 // 0in state_transition -var state -val BRLS -next IDLE
90
91// ----------------------------------------------------------------------------
92// Combinational
93// ----------------------------------------------------------------------------
94
95// outputs
96 assign csr_byp_ring_out = byp_ring;
97 assign csr_ext_ring_out = ext_ring;
98
99// valid, command, and source bus
100 assign cmd = csr_byp_ring_in[`FIRE_CSR_RING_CMND_BITS];
101 assign src = csr_byp_ring_in[`FIRE_CSR_RING_SRCB_BITS];
102
103// bypass source
104 wire vld = |cmd;
105 wire byp = (src == byp_src);
106
107// next state
108 always @ (state or vld or byp) begin
109 case (state) // synopsys parallel_case
110 IDLE : begin
111 case ({vld, byp}) // synopsys parallel_case
112 2'b00 : nxt_state = IDLE;
113 2'b01 : nxt_state = IDLE;
114 2'b10 : nxt_state = ERMS;
115 2'b11 : nxt_state = BRMS;
116 endcase
117 end
118 ERMS : nxt_state = ERLS;
119 ERLS : nxt_state = IDLE;
120 BRMS : nxt_state = BRLS;
121 BRLS : nxt_state = IDLE;
122 default : nxt_state = IDLE;
123 endcase
124 end
125
126// state outputs
127 always @ (state or byp) begin
128 case (state) // synopsys parallel_case
129 IDLE : begin
130 if (byp) sel = 1'b0;
131 else sel = 1'b1;
132 end
133 ERMS : sel = 1'b1;
134 ERLS : sel = 1'b1;
135 BRMS : sel = 1'b0;
136 BRLS : sel = 1'b0;
137 default : sel = 1'b0;
138 endcase
139 end
140
141 assign nxt_byp_ring = sel ? csr_ext_ring_in : csr_byp_ring_in;
142 assign nxt_ext_ring = sel ? csr_byp_ring_in : 0;
143
144// ----------------------------------------------------------------------------
145// Sequential
146// ----------------------------------------------------------------------------
147 always @ (posedge clk) begin
148 if (!rst_l) begin
149 state <= IDLE;
150 end
151 else begin
152 state <= nxt_state;
153 end
154 end
155
156 always @ (posedge clk)
157 if (!rst_l) begin
158 byp_ring <= 32'b0;
159 ext_ring <= 32'b0;
160 end
161 else begin
162 byp_ring <= nxt_byp_ring;
163 ext_ring <= nxt_ext_ring;
164 end
165
166endmodule // pcie_common_dcb