Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / xrlm_sm.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: xrlm_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 : xrlm_sm.v
40 * Author Name : John Lo
41 * Description : xgmii receive link manager state machine.
42 * Parent Module: rx_xmac
43 * Child Module:
44 * Interface Mod: many.
45 * Date Created : 5/9/00
46 *
47 * Copyright (c) 2002, Sun Microsystems, Inc.
48 * Sun Proprietary and Confidential
49 *
50 * Modification :
51 *
52 * Synthesis Notes:
53 *
54 *************************************************************************/
55
56module xrlm_sm (
57 rx_clk,
58 rx_reset,
59 rx_enable_rxclk,
60 rx_data_valid_gmux,
61 rx_data_valid_gmux_lead,//rx_1st_word_time == rx_data_valid_gmux_lead
62 da_match_err,
63 rxfifo_full_rxclk,
64 rxfifo_afull_rxclk,
65 max_pkt_size_limit,
66 err_chk_dis,
67 link_fault,
68// outputs
69 valid_data,
70 set_err_time,
71 eop,
72 rx_ok,
73 err_cond,
74 xrlm_state
75 );
76
77
78 input rx_clk;
79 input rx_reset;
80 input rx_enable_rxclk;
81 input rx_data_valid_gmux;
82 input rx_data_valid_gmux_lead;//rx_1st_word_time == rx_data_valid_gmux_lead
83 input da_match_err;
84 input rxfifo_full_rxclk;
85 input rxfifo_afull_rxclk;
86 input max_pkt_size_limit;
87 input err_chk_dis;
88 input link_fault;
89// outputs
90 output valid_data;
91 output set_err_time;
92 output eop;
93 output rx_ok;
94 output err_cond;
95 output xrlm_state;
96
97 reg valid_data;
98 reg set_err_time;
99 reg eop;
100 reg nx_xrlm_state;
101 wire xrlm_state;
102 wire rx_ok,err_cond;
103 // rx_1st_word_time == rx_data_valid_gmux_lead
104 assign rx_ok = rx_data_valid_gmux_lead & !da_match_err & ~link_fault &
105 ~(rxfifo_afull_rxclk | rxfifo_full_rxclk) & rx_enable_rxclk;
106
107 // There is no min_pkt_size_err,crc_err. Since rlm_sm won't be able
108 // to see them in time.
109 assign err_cond = link_fault | rxfifo_afull_rxclk | (~err_chk_dis & ( max_pkt_size_limit));
110
111
112 parameter IDLE = 1'h0,
113 RX_BODY = 1'h1;
114
115// com part
116always @ (xrlm_state or
117 rx_ok or rx_data_valid_gmux or
118 err_cond )
119 begin
120 nx_xrlm_state= IDLE;
121 valid_data = 1'b0;
122 set_err_time = 1'b0;
123 eop = 1'b0;
124
125 casex(xrlm_state) // synopsys parallel_case full_case
126 IDLE:
127 if (rx_ok)
128 begin
129 nx_xrlm_state= RX_BODY;
130 valid_data = 1;
131 end // if (rx_ok)
132 else
133 begin
134 nx_xrlm_state= xrlm_state;
135 valid_data = 0;
136 end // else: !if(rx_ok)
137
138 RX_BODY:
139 begin
140 valid_data = 1;
141 if (err_cond)
142 begin
143 nx_xrlm_state= IDLE;
144 set_err_time = 1;
145 eop = 1;
146 valid_data = 0;
147 end // if (err_cond)
148 else if (~rx_data_valid_gmux)
149 begin
150 nx_xrlm_state= IDLE;
151 eop = 1;
152 valid_data = 0;
153 end // if (~rx_data_valid_gmux)
154 else
155 begin
156 nx_xrlm_state= RX_BODY;
157 valid_data = 1;
158 end // else: !if(~rx_data_valid_gmux)
159 end // case: RX_BODY
160
161 default:
162 begin
163 nx_xrlm_state= IDLE;
164 valid_data = 1'b0;
165 set_err_time = 1'b0;
166 eop = 1'b0;
167 // synopsys translate_off
168 $display("( Warning: xrlm_state in unknown state.)");
169 // synopsys translate_on
170 end // case: default
171 endcase // casex(xrlm_state)
172 end // always @ (xrlm_state or...
173
174
175
176// seq part
177RegRst #(1) xrlm_state_RegRst(.din(nx_xrlm_state),
178 .clk(rx_clk),
179 .reset(rx_reset),
180 .qout(xrlm_state));
181
182endmodule // xrlm_sm
183
184