Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / dmu / rtl / dmu_imu_eqs_fsm.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: dmu_imu_eqs_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_imu_eqs_fsm (
36
37 // Clock and Reset
38
39 clk,
40 rst_l,
41
42 // Over Flow Error Signal Inputs
43
44 set_over_err,
45
46 // SW CSR State Update Access Interface
47
48 sw_wr,
49 sw_set_addr_sel,
50 sw_clr_addr_sel,
51 sw_wr_data,
52
53 //EQ State Status Signal
54
55 eq_state
56
57 );
58
59
60//############################################################################
61// PORT DECLARATIONS
62//############################################################################
63
64 //------------------------------------------------------------------------
65 // Clock and Reset Signals
66 //------------------------------------------------------------------------
67
68 input clk;
69 input rst_l;
70
71
72 //------------------------------------------------------------------------
73 // Over Flow Error Signal Inputs
74 //------------------------------------------------------------------------
75 input set_over_err;
76
77
78 //------------------------------------------------------------------------
79 // SW CSR State Update Access Interface
80 //------------------------------------------------------------------------
81
82 input sw_wr;
83 input sw_set_addr_sel;
84 input sw_clr_addr_sel;
85 input [1:0] sw_wr_data;
86
87
88 //------------------------------------------------------------------------
89 // EQ State Status Signal
90 //------------------------------------------------------------------------
91
92 output [2:0] eq_state;
93
94
95//############################################################################
96// PARAMETERS
97//############################################################################
98
99 //------------------------------------------------------------------------
100 // Parameters for the Value of the FSM States
101 //------------------------------------------------------------------------
102 parameter IDLE = 3'b001;
103 parameter ACTIVE = 3'b010;
104 parameter ERROR = 3'b100;
105
106
107//############################################################################
108// SIGNAL DECLARATIONS
109//############################################################################
110
111 //------------------------
112 // Wires
113 //------------------------
114 wire go_sw_en_eq;
115 wire go_sw_dis_eq;
116 wire go_sw_e2i_eq;
117
118
119 //-------------------------
120 // Regs that are NOT flops
121 //-------------------------
122 reg [2:0] n_state;
123
124
125 //------------------------
126 // Regs that are flops
127 //------------------------
128 reg [2:0] state;
129
130
131//############################################################################
132// ZERO IN CHECKERS
133//############################################################################
134 //---------------------------------------------------------------------
135 // State Machine Checkers
136 //---------------------------------------------------------------------
137 //0in state_transition -var state -val IDLE -next ACTIVE
138 //0in state_transition -var state -val ACTIVE -next ERROR IDLE
139 //0in state_transition -var state -val ERROR -next IDLE
140
141
142
143//############################################################################
144// COMBINATIONAL LOGIC
145//############################################################################
146
147 //---------------------------------------------------------------------
148 // The signals for SW PIOs
149 //---------------------------------------------------------------------
150
151 //------------------------
152 // Enable the EQ
153 //------------------------
154 assign go_sw_en_eq = sw_set_addr_sel & sw_wr & sw_wr_data[0];
155
156 //------------------------
157 // Diasable the EQ
158 //------------------------
159 assign go_sw_dis_eq = sw_clr_addr_sel & sw_wr & sw_wr_data[0];
160
161 //------------------------
162 // Take from Error to Idle
163 //------------------------
164 assign go_sw_e2i_eq = sw_clr_addr_sel & sw_wr & sw_wr_data[1];
165
166
167 //------------------------
168 // Assign the Output
169 //------------------------
170
171 assign eq_state = state;
172
173
174//############################################################################
175// SEQUENTIAL LOGIC
176//############################################################################
177
178//-----------------------------------------------------------------------
179// Next State Logic, Assign next state to current state
180//-----------------------------------------------------------------------
181
182always @ (posedge clk)
183 if (!rst_l)
184 state <= IDLE;
185 else
186 state <= n_state;
187
188//-----------------------------------------------------------------------
189// FSM Combination Logic
190//-----------------------------------------------------------------------
191
192always @ (state or go_sw_en_eq or go_sw_e2i_eq or go_sw_dis_eq or set_over_err)
193 case (state) // synopsys parallel_case
194
195
196 //********************************************************
197 //
198 // IDLE STATE
199 //
200 // - Wait here until the SW has enabled the EQ
201 //
202 //********************************************************
203
204 IDLE : begin
205
206 if (go_sw_en_eq) // SW PIO Enables event queue
207 n_state = ACTIVE;
208 else
209 n_state = IDLE;
210
211 end
212
213 //********************************************************
214 //
215 // ACTIVE STATE
216 //
217 // - Wait here until:
218 // - Receive a HW or SW overflow error
219 // - goto ERROR
220 // - SW disbales the EQ
221 // - goto IDLE
222 //
223 //********************************************************
224
225 ACTIVE : begin
226
227 if (set_over_err) // Overflow Error
228 n_state = ERROR;
229
230 else if (go_sw_dis_eq) // SW PIO disables event queue
231 n_state = IDLE;
232
233 else
234 n_state = ACTIVE;
235 end
236
237 //********************************************************
238 //
239 // ERROR STATE
240 //
241 // - Wait here until the SW has puts the EQ back to IDLE
242 //
243 //********************************************************
244
245 ERROR : begin
246 if (go_sw_e2i_eq) // SW Puts back into IDLE
247 n_state = IDLE;
248
249 else
250 n_state = ERROR;
251
252 end
253
254 //********************************************************
255 //
256 // DEFAULT STATE
257 //
258 // - Go to IDLE
259 //********************************************************
260
261 default:
262
263 begin
264 n_state = IDLE; //0in < fire -message "Illegal State Reached in module fire_dlc_imu_eqs_fsm.v"
265
266 end
267
268
269 endcase
270
271endmodule