Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / dmu / rtl / dmu_clu_crm_psbctlfsm.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: dmu_clu_crm_psbctlfsm.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_clu_crm_psbctlfsm
36 (
37 // clock/reset
38 clk,
39 rst_l,
40
41 // fsm inputs
42 start_psb_op,
43 psb_op_typ,
44 ps2cl_e_gnt,
45
46 // fsm outputs
47 done_psb_op,
48 done_psb_rd,
49 cl2ps_e_req,
50 cl2ps_e_cmd_type,
51
52 // debug port
53 psbctlfsm_state,
54
55 // idle checker port
56 psbctlfsm_idle
57 );
58
59 // synopsys sync_set_reset "rst_l"
60
61 // >>>>>>>>>>>>>>>>>>>>>>>>> Parameter Declarations <<<<<<<<<<<<<<<<<<<<<<<<<
62
63 // --------------------------------------------------------
64 // State Number
65 // --------------------------------------------------------
66
67 parameter STATE_NUM = 5;
68
69 // --------------------------------------------------------
70 // State Declarations
71 // --------------------------------------------------------
72
73 parameter // summit enum cur_enum
74 IDLE = 0,
75 DMA_PSBRDCLR = 1,
76 DMA_PSBRDCLR_WAIT = 2,
77 PIO_PSBWR = 3,
78 PIO_PSBWR_WAIT = 4;
79
80 // --------------------------------------------------------
81 // PSB Interface
82 // --------------------------------------------------------
83
84 parameter PSB_PIO_WR = 4'b1100,
85 PSB_DMA_RDCLR = 4'b0011;
86
87 // >>>>>>>>>>>>>>>>>>>>>>>>> Port Declarations <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
88
89 // --------------------------------------------------------
90 // Clock/Reset Signals
91 // --------------------------------------------------------
92
93 input clk;
94 input rst_l;
95
96 // --------------------------------------------------------
97 // FSM Inputs
98 // --------------------------------------------------------
99
100 input start_psb_op;
101 input [1:0] psb_op_typ;
102 input ps2cl_e_gnt;
103
104 // --------------------------------------------------------
105 // FSM Outputs
106 // --------------------------------------------------------
107
108 output done_psb_op;
109 output done_psb_rd;
110 output cl2ps_e_req;
111 output [(`FIRE_DLC_PSR_CMD_TYPE_WDTH - 1):0] cl2ps_e_cmd_type;
112
113 // debug port
114 output [4:0] psbctlfsm_state;
115
116 // idle checker port
117 output psbctlfsm_idle;
118
119 // >>>>>>>>>>>>>>>>>>>>>>>>> Data Type Declarations <<<<<<<<<<<<<<<<<<<<<<<<<
120
121 // ~~~~~~~~~~~~~~~~~~~~~~~~~ REGISTERS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122
123 // ********** Flops **********
124
125 reg [(STATE_NUM - 1):0] cur_state;
126 reg cl2ps_e_req;
127 reg [(`FIRE_DLC_PSR_CMD_TYPE_WDTH - 1):0] cl2ps_e_cmd_type;
128
129 // ********** Non-Flops ******
130
131 reg [(STATE_NUM - 1):0] nxt_state;
132
133 // >>>>>>>>>>>>>>>>>>>>>>>>> 0-in Checkers <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
134
135 /* 0in rack
136 -req cl2ps_e_req
137 -ack ps2cl_e_gnt
138 -min 1
139 -req_until_ack
140 -new_req_after_ack
141 -no_simultaneous_req_ack
142 */
143
144 // 0in one_hot -var cur_state
145
146 /* 0in state
147 -var cur_state
148 -val (5'b1 << IDLE)
149 -next (5'b1 << IDLE)
150 (5'b1 << DMA_PSBRDCLR)
151 (5'b1 << PIO_PSBWR)
152 -match_by_cycle
153 */
154
155 /* 0in state
156 -var cur_state
157 -val (5'b1 << DMA_PSBRDCLR)
158 -next (5'b1 << DMA_PSBRDCLR_WAIT)
159 -match_by_cycle
160 */
161
162 /* 0in state
163 -var cur_state
164 -val (5'b1 << DMA_PSBRDCLR_WAIT)
165 -next (5'b1 << DMA_PSBRDCLR_WAIT)
166 (5'b1 << IDLE)
167 (5'b1 << DMA_PSBRDCLR)
168 (5'b1 << PIO_PSBWR)
169 -match_by_cycle
170 */
171
172 /* 0in state
173 -var cur_state
174 -val (5'b1 << PIO_PSBWR)
175 -next (5'b1 << PIO_PSBWR_WAIT)
176 -match_by_cycle
177 */
178
179 /* 0in state
180 -var cur_state
181 -val (5'b1 << PIO_PSBWR_WAIT)
182 -next (5'b1 << PIO_PSBWR_WAIT)
183 (5'b1 << IDLE)
184 (5'b1 << DMA_PSBRDCLR)
185 (5'b1 << PIO_PSBWR)
186 -match_by_cycle
187 */
188
189 // >>>>>>>>>>>>>>>>>>>>>>>>> RTL Model <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
190
191 // --------------------------------------------------------
192 // IDLE Checker
193 // --------------------------------------------------------
194
195 assign psbctlfsm_idle = cur_state[IDLE];
196
197 // --------------------------------------------------------
198 // Debug Port Logic
199 // --------------------------------------------------------
200
201 assign psbctlfsm_state = cur_state;
202
203 // --------------------------------------------------------
204 // FSM Next State
205 // --------------------------------------------------------
206
207 // next state assignment
208 always @(cur_state or start_psb_op or psb_op_typ or ps2cl_e_gnt)
209 begin
210
211 // initialization
212 nxt_state = {STATE_NUM{1'b0}};
213
214 case (1'b1) // synopsys parallel_case
215
216 // 0in < case -full
217
218 ///////////////////////////////////////////////////////////////////////
219
220 // IDLE State
221 cur_state[IDLE] :
222 casez ({start_psb_op, psb_op_typ})
223
224 // 0in < case -parallel -full
225
226 3'b0_zz : nxt_state[IDLE] = 1'b1;
227 3'b1_10 : nxt_state[DMA_PSBRDCLR] = 1'b1;
228 3'b1_01 : nxt_state[PIO_PSBWR] = 1'b1;
229 endcase
230
231 ///////////////////////////////////////////////////////////////////////
232
233 // ---------- DMA READ/CLEAR --------------------------------
234
235 // PSB READ/CLEAR State
236 cur_state[DMA_PSBRDCLR] :
237 nxt_state[DMA_PSBRDCLR_WAIT] = 1'b1;
238
239 // PSB READ/CLEAR WAIT State
240 cur_state[DMA_PSBRDCLR_WAIT] :
241 casez ({ps2cl_e_gnt, start_psb_op, psb_op_typ})
242
243 // 0in < case -parallel -full
244
245 4'b0_z_zz : nxt_state[DMA_PSBRDCLR_WAIT] = 1'b1;
246 4'b1_0_zz : nxt_state[IDLE] = 1'b1;
247 4'b1_1_10 : nxt_state[DMA_PSBRDCLR] = 1'b1;
248 4'b1_1_01 : nxt_state[PIO_PSBWR] = 1'b1;
249 endcase
250
251 ///////////////////////////////////////////////////////////////////////
252
253 // ---------- PIO READ --------------------------------------
254
255 // PSB WRITE State
256 cur_state[PIO_PSBWR] :
257 nxt_state[PIO_PSBWR_WAIT] = 1'b1;
258
259 // PSB WRITE WAIT State
260 cur_state[PIO_PSBWR_WAIT] :
261 casez ({ps2cl_e_gnt, start_psb_op, psb_op_typ})
262
263 // 0in < case -parallel -full
264
265 4'b0_z_zz : nxt_state[PIO_PSBWR_WAIT] = 1'b1;
266 4'b1_0_zz : nxt_state[IDLE] = 1'b1;
267 4'b1_1_10 : nxt_state[DMA_PSBRDCLR] = 1'b1;
268 4'b1_1_01 : nxt_state[PIO_PSBWR] = 1'b1;
269 endcase
270
271 ///////////////////////////////////////////////////////////////////////
272
273 endcase
274 end
275
276 // --------------------------------------------------------
277 // FSM Current State
278 // --------------------------------------------------------
279
280 // summit state_vector cur_state enum cur_enum
281
282 // current state assignment
283 always @(posedge clk)
284 if (~rst_l)
285 begin
286 cur_state <= {STATE_NUM{1'b0}};
287 cur_state[IDLE] <= 1'b1;
288 end
289 else
290 cur_state <= nxt_state;
291
292 // --------------------------------------------------------
293 // FSM Output Gen
294 // --------------------------------------------------------
295
296 // ----- psb access status ---------------------------------
297
298 // psb access op (rd/wr) done
299 assign done_psb_op = (ps2cl_e_gnt & (cur_state[DMA_PSBRDCLR_WAIT] |
300 cur_state[PIO_PSBWR_WAIT]));
301
302 // psb rd done
303 assign done_psb_rd = ps2cl_e_gnt & cur_state[DMA_PSBRDCLR_WAIT];
304
305 // ----- psb interface control -----------------------------
306
307 // psb request
308 always @(posedge clk)
309 if (~rst_l)
310 cl2ps_e_req <= 1'b0;
311 else
312 if (~nxt_state[IDLE])
313 cl2ps_e_req <= 1'b1;
314 else
315 cl2ps_e_req <= 1'b0;
316
317 // psb access command type
318 always @(posedge clk)
319 if (~rst_l) begin
320 cl2ps_e_cmd_type <= `FIRE_DLC_PSR_CMD_TYPE_WDTH'b0; // reset
321 end
322 else if (nxt_state[PIO_PSBWR])
323 cl2ps_e_cmd_type <= PSB_PIO_WR; // pio : psb wr operation
324 else if (nxt_state[DMA_PSBRDCLR])
325 cl2ps_e_cmd_type <= PSB_DMA_RDCLR; // dma : psb rd/clr operation
326
327endmodule // dmu_clu_crm_psbctlfsm