Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: dmu_common_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 ============================================ | |
35 | module dmu_common_ccc_fsm | |
36 | ( | |
37 | clk, | |
38 | rst_l, | |
39 | done_timeout_value, | |
40 | arb2fsm_valid, | |
41 | cdp2fsm_error, | |
42 | dep2fsm_acc_vio, | |
43 | dep2fsm_done, | |
44 | dep2fsm_mapped, | |
45 | dep2fsm_valid, | |
46 | ccc_idle, | |
47 | fsm2arb_done, | |
48 | fsm2cdp_stts, | |
49 | fsm2pkt_valid | |
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 | input [`FIRE_CSR_TOUT_BITS] done_timeout_value; | |
71 | ||
72 | input arb2fsm_valid; | |
73 | ||
74 | input cdp2fsm_error; | |
75 | ||
76 | input dep2fsm_acc_vio; | |
77 | input dep2fsm_done; | |
78 | input dep2fsm_mapped; | |
79 | input dep2fsm_valid; | |
80 | ||
81 | output ccc_idle; | |
82 | ||
83 | output fsm2arb_done; | |
84 | output [`FIRE_CSR_STTS_BITS] fsm2cdp_stts; | |
85 | output fsm2pkt_valid; | |
86 | ||
87 | // ---------------------------------------------------------------------------- | |
88 | // Variables | |
89 | // ---------------------------------------------------------------------------- | |
90 | reg ccc_idle; | |
91 | reg fsm2arb_done; | |
92 | reg [`FIRE_CSR_STTS_BITS] fsm2cdp_stts; | |
93 | reg fsm2pkt_valid; | |
94 | ||
95 | reg [2:0] state, nxt_state; | |
96 | reg [`FIRE_CSR_TOUT_BITS] timer, nxt_timer; | |
97 | ||
98 | // ---------------------------------------------------------------------------- | |
99 | // Zero In Checkers | |
100 | // ---------------------------------------------------------------------------- | |
101 | ||
102 | // ---------------------------------------------------------------------------- | |
103 | // Combinational | |
104 | // ---------------------------------------------------------------------------- | |
105 | ||
106 | // timeout | |
107 | wire timeout = ~|timer; | |
108 | ||
109 | // arb valid and map error | |
110 | wire arb_vld = arb2fsm_valid; | |
111 | wire map_err = cdp2fsm_error; | |
112 | ||
113 | // access violation, request valid, and response valid | |
114 | wire acc_vio = dep2fsm_valid & dep2fsm_mapped & dep2fsm_done & dep2fsm_acc_vio; | |
115 | wire map_vld = dep2fsm_valid & dep2fsm_mapped & ~dep2fsm_done & ~dep2fsm_acc_vio; | |
116 | wire req_vld = dep2fsm_valid & ~dep2fsm_mapped & ~dep2fsm_done & ~dep2fsm_acc_vio; | |
117 | wire rsp_vld = dep2fsm_valid & dep2fsm_mapped & dep2fsm_done & ~dep2fsm_acc_vio; | |
118 | ||
119 | // next state | |
120 | always @ (state or arb_vld or acc_vio or map_err or map_vld or | |
121 | req_vld or rsp_vld or timeout) begin | |
122 | case (state) // synopsys parallel_case | |
123 | IDLE : begin | |
124 | if (!arb_vld) nxt_state = IDLE; | |
125 | else if (map_err) nxt_state = MDTO; | |
126 | else nxt_state = RQST; | |
127 | end | |
128 | RQST : begin | |
129 | if (req_vld) nxt_state = WAIT; | |
130 | else nxt_state = RQST; | |
131 | end | |
132 | WAIT : begin | |
133 | if (map_vld) nxt_state = MAPD; | |
134 | else if (acc_vio) nxt_state = AVIO; | |
135 | else if (rsp_vld) nxt_state = DONE; | |
136 | else if (timeout) nxt_state = MDTO; | |
137 | else nxt_state = WAIT; | |
138 | end | |
139 | MAPD : begin | |
140 | if (rsp_vld) nxt_state = DONE; | |
141 | else if (timeout) nxt_state = MDTO; | |
142 | else nxt_state = MAPD; | |
143 | end | |
144 | DONE : nxt_state = SKIP; | |
145 | MDTO : nxt_state = SKIP; | |
146 | AVIO : nxt_state = SKIP; | |
147 | SKIP : nxt_state = IDLE; | |
148 | endcase | |
149 | end | |
150 | ||
151 | // state outputs | |
152 | always @ (state or timer or done_timeout_value) begin | |
153 | ccc_idle = 0; | |
154 | fsm2arb_done = 0; | |
155 | fsm2cdp_stts = `FIRE_CSR_HOST_DONE_STATUS_SUCCESS; | |
156 | fsm2pkt_valid = 0; | |
157 | nxt_timer = done_timeout_value; | |
158 | case (state) // synopsys parallel_case | |
159 | IDLE : begin | |
160 | ccc_idle = 1'b1; | |
161 | end | |
162 | RQST : begin | |
163 | fsm2pkt_valid = 1'b1; | |
164 | end | |
165 | WAIT : begin | |
166 | fsm2pkt_valid = 1'b1; | |
167 | nxt_timer = timer - 1; | |
168 | end | |
169 | MAPD : begin | |
170 | fsm2pkt_valid = 1'b1; | |
171 | nxt_timer = timer - 1; | |
172 | end | |
173 | DONE : begin | |
174 | fsm2arb_done = 1'b1; | |
175 | end | |
176 | MDTO : begin | |
177 | fsm2arb_done = 1'b1; | |
178 | fsm2cdp_stts = `FIRE_CSR_HOST_DONE_STATUS_MAP_DONE_TIMEOUT; | |
179 | end | |
180 | AVIO : begin | |
181 | fsm2arb_done = 1'b1; | |
182 | fsm2cdp_stts = `FIRE_CSR_HOST_DONE_STATUS_ACCESS_VIO; | |
183 | end | |
184 | SKIP : begin | |
185 | fsm2pkt_valid = 0; | |
186 | fsm2arb_done = 0; | |
187 | end | |
188 | endcase | |
189 | end | |
190 | ||
191 | // ---------------------------------------------------------------------------- | |
192 | // Sequential | |
193 | // ---------------------------------------------------------------------------- | |
194 | always @ (posedge clk) begin | |
195 | if (!rst_l) begin | |
196 | state <= IDLE; | |
197 | end | |
198 | else begin | |
199 | state <= nxt_state; | |
200 | end | |
201 | end | |
202 | ||
203 | always @ (posedge clk) begin | |
204 | timer <= nxt_timer; | |
205 | end | |
206 | ||
207 | endmodule // dmu_common_ccc_fsm |