Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / dmu / rtl / dmu_dsn_ccc_fsm.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: dmu_dsn_ccc_fsm.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 dmu_dsn_ccc_fsm
36 (
37 clk,
38 rst_l,
39 rd_req_vld,
40 wr_req_vld,
41 dep2fsm_acc_vio,
42 dep2fsm_done,
43 dep2fsm_valid,
44 ack_busy,
45 rd_ack_vld,
46 rd_nack_vld,
47 fsm2arb_done,
48 fsm2pkt_valid,
49 fsm2ctl_dbg_grp_b_1
50 );
51
52// ----------------------------------------------------------------------------
53// Parameters
54// ----------------------------------------------------------------------------
55 parameter IDLE = 3'b000, // state machine states
56 RQST = 3'b001,
57 WAIT = 3'b010,
58// MAPD = 3'b011,
59 DONE = 3'b110,
60 AVIO = 3'b100,
61 MDTO = 3'b101,
62 SKIP = 3'b111;
63
64// ----------------------------------------------------------------------------
65// Ports
66// ----------------------------------------------------------------------------
67 input clk;
68 input rst_l;
69
70
71 input rd_req_vld;
72 input wr_req_vld;
73
74
75 input dep2fsm_acc_vio;
76 input dep2fsm_done;
77 input dep2fsm_valid;
78 input ack_busy;
79
80
81 output fsm2arb_done;
82 output rd_ack_vld;
83 output rd_nack_vld;
84 output fsm2pkt_valid;
85 output [4:0] fsm2ctl_dbg_grp_b_1;
86
87// ----------------------------------------------------------------------------
88// Variables
89// ----------------------------------------------------------------------------
90 reg fsm2arb_done;
91 reg fsm2cdp_stts;
92 reg fsm2pkt_valid;
93
94 reg [2:0] state, nxt_state;
95 reg [`FIRE_CSR_TOUT_BITS] timer, nxt_timer;
96
97// ----------------------------------------------------------------------------
98// Zero In Checkers
99// ----------------------------------------------------------------------------
100
101// csr_ring_fsm
102 //0in state_transition -var state -val IDLE -next IDLE MDTO RQST
103 //0in state_transition -var state -val RQST -next WAIT RQST
104 //0in state_transition -var state -val WAIT -next AVIO DONE MDTO WAIT
105 //0in state_transition -var state -val DONE -next SKIP
106 //0in state_transition -var state -val MDTO -next SKIP
107 //0in state_transition -var state -val AVIO -next SKIP
108 //0in state_transition -var state -val SKIP -next IDLE
109
110
111
112// ----------------------------------------------------------------------------
113// Combinational
114// ----------------------------------------------------------------------------
115
116// timeout
117 wire timeout = ~|timer;
118
119// arb valid and map error
120 wire arb_vld = (rd_req_vld | wr_req_vld) && ~ack_busy;
121 wire map_err = 1'b0;
122
123// access violation, request valid, and response valid
124 wire acc_vio = dep2fsm_valid & dep2fsm_done & dep2fsm_acc_vio;
125//BP 3-17-04 req_vld should be 1 at the beginning of the csr ring transfer, right????
126 wire req_vld = dep2fsm_valid & ~dep2fsm_done & ~dep2fsm_acc_vio;
127 wire rsp_vld = dep2fsm_valid & dep2fsm_done & ~dep2fsm_acc_vio;
128//BP 5-07-04
129 wire rd_ack_vld = fsm2arb_done & ~fsm2cdp_stts & rd_req_vld;
130 wire rd_nack_vld = fsm2arb_done & fsm2cdp_stts & rd_req_vld;
131// next state
132 always @ (state or arb_vld or acc_vio or map_err or
133 req_vld or rsp_vld or timeout) begin
134 nxt_state = IDLE;
135 case (state) // synopsys parallel_case
136 IDLE : begin
137 if (!arb_vld) nxt_state = IDLE;
138 else if (map_err) nxt_state = MDTO;
139 else nxt_state = RQST;
140 end
141 RQST : begin
142 if (req_vld) nxt_state = WAIT;
143 else nxt_state = RQST;
144 end
145 WAIT : begin
146 if (acc_vio) nxt_state = AVIO;
147 else if (rsp_vld) nxt_state = DONE;
148 else if (timeout) nxt_state = MDTO;
149 else nxt_state = WAIT;
150 end
151 DONE : nxt_state = SKIP;
152 MDTO : nxt_state = SKIP;
153 AVIO : nxt_state = SKIP;
154 SKIP : nxt_state = IDLE;
155 default: begin
156 nxt_state = 3'b000; //0in < fire -message " got x's in dsn_ccc_fsm"
157 end
158 endcase
159 end
160
161// state outputs
162 always @ (state or timer ) begin
163 fsm2arb_done = 1'b0;
164 fsm2cdp_stts = 1'b0;
165 fsm2pkt_valid = 1'b0;
166 nxt_timer = 8'b11100000;
167 case (state) // synopsys parallel_case
168 IDLE : begin
169 end
170 RQST : begin
171 fsm2pkt_valid = 1'b1;
172 end
173 WAIT : begin
174 fsm2pkt_valid = 1'b1;
175 nxt_timer = timer - 8'b00000001;
176 end
177 DONE : begin
178 fsm2arb_done = 1'b1;
179 end
180 MDTO : begin
181 fsm2arb_done = 1'b1;
182 fsm2cdp_stts = 1'b1;
183 end
184 AVIO : begin
185 fsm2arb_done = 1'b1;
186 fsm2cdp_stts = 1'b1;
187 end
188 SKIP : begin
189 fsm2pkt_valid = 1'b0;
190 fsm2arb_done = 1'b0;
191 end
192 default: begin
193 fsm2arb_done = 1'b0;
194 fsm2pkt_valid = 1'b0;
195 fsm2cdp_stts = 1'b0;
196 nxt_timer = 8'b00000000;
197 end
198 endcase
199 end
200
201// ----------------------------------------------------------------------------
202// Sequential
203// ----------------------------------------------------------------------------
204 always @ (posedge clk) begin
205 if (!rst_l) begin
206 state <= IDLE;
207 end
208 else begin
209 state <= nxt_state;
210 end
211 end
212
213 always @ (posedge clk)
214 if (!rst_l) begin
215 timer <= 8'b0;
216 end
217 else begin
218 timer <= nxt_timer;
219 end
220
221// ----------------------------------------------------------------------------
222// debug-- debug signals for debug group b sub_sel 1
223// ----------------------------------------------------------------------------
224assign fsm2ctl_dbg_grp_b_1[4:0] = {arb_vld,req_vld,acc_vio,rsp_vld,timeout};
225
226endmodule // dmu_dsn_ccc_fsm