Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / lfs_sm.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: lfs_sm.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/*%W% %G%*/
36
37/*************************************************************************
38 *
39 * File Name : lfs_sm.v
40 * Author Name : John Lo
41 * Description : link fault signaling state machine.
42 * Parent Module: lfs
43 * Child Module:
44 * Interface Mod:
45 * Date Created : 7/24/01
46 *
47 * Copyright (c) 2003, Sun Microsystems, Inc.
48 * Sun Proprietary and Confidential
49 *
50 * Modification :
51 *
52 * Synthesis Notes:
53 *
54 *************************************************************************/
55
56`include "xmac.h"
57
58module lfs_sm (
59rx_clk,
60rx_reset,
61lfs_disable_rxclk,
62fault_sequence,
63col_cnt_limit,
64diff_seq_type,
65seq_cnt_less_3,
66rst_col_cnt,
67rst_seq_cnt,
68link_fault,
69col_cnt_en,
70load_fault_type,
71lfs_state // dynamic signal
72 );
73 input rx_clk;
74 input rx_reset;
75 input lfs_disable_rxclk;
76 input fault_sequence;
77 input col_cnt_limit;
78 input diff_seq_type;
79 input seq_cnt_less_3;
80// outputs
81 output rst_col_cnt;
82 output rst_seq_cnt;
83 output link_fault;
84 output col_cnt_en;
85 output load_fault_type;
86 output [1:0] lfs_state; // dynamic signal
87
88// internal signals
89 reg [1:0] nx_lfs_state;
90 reg rst_col_cnt;
91 reg rst_seq_cnt;
92 reg load_fault_type;
93 wire link_fault;
94
95/* ----------------------- lfs_sm -------------------------------------- */
96/* 1. to tx_xmac to generate idle (if rf is detected) or RF if (lf is
97 * detected.
98 * 2. xmac_slv to generate status bit for interrupt gen.
99 * 3. to bring xrlm_sm and sop_sm to initial state.
100 * 4. "link fault" can happen any time. It should generate a crc error
101 * if it happened in the middle a packet. It resets sop_sm and xrlm_sm.
102 * It stops sending data to rx_xmac by reseting sop_sm. It goes to
103 * tx_xmac to generate RF if LF is detected and gnerates IDLE if RF is
104 * detected.
105 */
106
107 parameter INIT = 2'b00,
108 COUNT = 2'b01,
109 FAULT = 2'b10;
110
111// com part
112always @ (lfs_state or fault_sequence or
113 col_cnt_limit or diff_seq_type or seq_cnt_less_3 )
114 begin
115 nx_lfs_state = INIT;
116 rst_col_cnt = 0;
117 rst_seq_cnt = 0;
118 load_fault_type= 1;
119 casex(lfs_state) // synopsys parallel_case full_case
120 INIT:
121 if (fault_sequence)
122 begin
123 nx_lfs_state = COUNT;
124 end
125 else
126 begin
127 nx_lfs_state= lfs_state; // stay
128 rst_col_cnt = 1;
129 rst_seq_cnt = 1;
130 end // else: !if(fault_sequence)
131
132 COUNT:
133 casex({fault_sequence,col_cnt_limit,diff_seq_type,seq_cnt_less_3})
134 4'b00xx: nx_lfs_state = lfs_state; // stay to count ok window.
135 4'b01xx: nx_lfs_state = INIT; // link ok
136 4'b1x00:begin
137 nx_lfs_state = FAULT; // same seq_type, >= 3
138 load_fault_type= 1;
139 end
140 4'b1x01: nx_lfs_state = lfs_state; // same seq_type, < 3, stay
141 4'b1x1x: nx_lfs_state = lfs_state; // diff seq_type, stay
142 default:begin
143 nx_lfs_state = INIT;
144 // synopsys translate_off
145 $display("( ERROR: lfs_state in unknown (COUNT) state.)");
146 // synopsys translate_on
147 end // case: default
148 endcase
149
150
151 FAULT:
152 casex ({fault_sequence,col_cnt_limit,diff_seq_type})
153 3'b00x: nx_lfs_state = lfs_state; // stay to count ok window.
154 3'b01x: nx_lfs_state = INIT; // link ok
155 3'b1x0: nx_lfs_state = lfs_state; // stay
156 3'b1x1: nx_lfs_state = COUNT;
157 default:begin
158 nx_lfs_state = INIT;
159 // synopsys translate_off
160 $display("( ERROR: lfs_state in unknown (FAULT) state.)");
161 // synopsys translate_on
162 end
163 endcase
164
165 default:
166 begin
167 nx_lfs_state= INIT;
168 // synopsys translate_off
169 $display("( ERROR: lfs_state in unknown state.)");
170 // synopsys translate_on
171 end
172 endcase // casex(lfs_state)
173 end
174
175
176 // seq part
177RegRst #(2) lfs_state_RegRst(.din(nx_lfs_state),
178 .clk(rx_clk),
179 .reset(rx_reset | lfs_disable_rxclk),
180 .qout(lfs_state));
181
182 assign link_fault = lfs_state == FAULT;
183 assign col_cnt_en = lfs_state != INIT;
184
185endmodule // lfs_sm
186
187
188
189
190/************************************************************************
191 * col_cnt: A count of the number of columns received not containing
192 * a fault_sequence. This counter incre-ments at RX_CLK rate
193 * (on both the rising and falling clock transitions) unless
194 * reset.
195 *
196 * fault_sequence:
197 * A new column received on RXC<3:0> and RXD<31:0> comprising a
198 * Sequence ordered_set of four bytes and consisting of a
199 * Sequence control character in lane 0 and a seq_type in
200 * lanes 1, 2, and 3 indicating either Local Fault or
201 * Remote Fault.
202 *
203 * last_seq_type:
204 * The seq_type of the previous Sequence ordered_set received
205 * Values:
206 * Local Fault; 0x00 in lane 1, 0x00 in lane 2, 0x01 in lane 3.
207 * Remote Fault; 0x00 in lane 1, 0x00 in lane 2, 0x02 in lane 3.
208 *
209 * link_fault:
210 * An indicator of the fault status.
211 * Values: OK; No fault.
212 * Local Fault; fault detected by the PHY.
213 * Remote Fault; fault detection signaled by the remote
214 * RS.
215 *
216 * rx_reset:
217 * Condition that is true until such time as the power supply for
218 * the device that contains the RS has reached the operating
219 * region.
220 * Values: FALSE: The device is completely powered and has not
221 * been reset (default).
222 * TRUE: The device has not been completely powered or has been
223 * reset.
224 * seq_cnt:
225 * A count of the number of received Sequence ordered_sets of
226 * the same type.
227 *
228 * seq_type:
229 * The value received in the current Sequence ordered_set
230 * Values:
231 * Local Fault; 0x00 in lane 1, 0x00 in lane 2, 0x01 in lane 3.
232 * Remote Fault; 0x00 in lane 1, 0x00 in lane 2, 0x02 in lane 3.
233 *
234 *
235 * The link fault signaling state machine specifies the RS monitoring
236 * of RXC<3:0> and RXD<31:0> for Sequence ordered_sets. The variable
237 * link_fault is set to indicate the value of a received Sequence
238 * ordered_set when the following conditions have been met:
239 * a) Four fault_sequences containing the same fault value have been
240 * received
241 * b) Without receiving any fault_sequence within a period of 128 columns
242 * The variable link_fault is set to OK following any interval of 128
243 * columns not containing a Remote Fault or Local Fault Sequence
244 * ordered_set.
245 *
246 ************************************************************************/
247
248
249