1 |
2 |
jefflieu |
/*
|
2 |
|
|
Developed By Subtleware Corporation Pte Ltd 2011
|
3 |
|
|
File :
|
4 |
|
|
Description :
|
5 |
|
|
Remarks :
|
6 |
|
|
Revision :
|
7 |
|
|
Date Author Description
|
8 |
|
|
02/09/12 Jefflieu
|
9 |
|
|
*/
|
10 |
|
|
`include "SGMIIDefs.v"
|
11 |
|
|
|
12 |
|
|
module mReceive(
|
13 |
|
|
|
14 |
|
|
input [07:00] i8_RxCodeGroupIn,
|
15 |
|
|
input i_RxCodeInvalid,
|
16 |
|
|
input i_RxCodeCtrl,
|
17 |
|
|
input i_RxEven,
|
18 |
|
|
input i_IsComma,
|
19 |
|
|
input [02:00] i3_Xmit,
|
20 |
|
|
|
21 |
|
|
input i_OrderedSetValid,
|
22 |
|
|
input i_IsI1Set,
|
23 |
|
|
input i_IsI2Set,
|
24 |
|
|
input i_IsC1Set,
|
25 |
|
|
input i_IsC2Set,
|
26 |
|
|
input i_IsTSet,
|
27 |
|
|
input i_IsVSet,
|
28 |
|
|
input i_IsSSet,
|
29 |
|
|
input i_IsRSet,
|
30 |
|
|
|
31 |
|
|
input i_CheckEndKDK,
|
32 |
|
|
input i_CheckEndKD21_5D0_0,
|
33 |
|
|
input i_CheckEndKD2_2D0_0,
|
34 |
|
|
input i_CheckEndTRK,
|
35 |
|
|
input i_CheckEndTRR,
|
36 |
|
|
input i_CheckEndRRR,
|
37 |
|
|
input i_CheckEndRRK,
|
38 |
|
|
input i_CheckEndRRS,
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
output reg [15:00] o16_RxConfigReg,
|
42 |
|
|
output o_RUDIConfig,
|
43 |
|
|
output o_RUDIIdle,
|
44 |
|
|
output o_RUDIInvalid,
|
45 |
|
|
|
46 |
|
|
output reg o_RxDV,
|
47 |
|
|
output reg o_RxER,
|
48 |
|
|
output reg [07:00] o8_RxD,
|
49 |
|
|
output reg o_Invalid,
|
50 |
|
|
output reg o_Receiving,
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
input i_Clk,
|
54 |
|
|
input i_ARst_L
|
55 |
|
|
);
|
56 |
|
|
|
57 |
|
|
localparam stWAIT_FOR_K = 21'h000001,
|
58 |
|
|
stRX_K = 21'h000002,
|
59 |
|
|
stRX_CB = 21'h000004,
|
60 |
|
|
stRX_CC = 21'h000008,
|
61 |
|
|
stRX_CD = 21'h000010,
|
62 |
|
|
stRX_INVALID = 21'h000020,
|
63 |
|
|
stIDLE_D = 21'h000040,
|
64 |
15 |
jefflieu |
stFALSE_CARRIER = 21'h000080,
|
65 |
|
|
stSTART_OF_PKT = 21'h000100,
|
66 |
|
|
stEARLY_END = 21'h000200,
|
67 |
|
|
stTRI_RRI = 21'h000400,
|
68 |
|
|
stTRR_EXTEND = 21'h000800,
|
69 |
|
|
stPKT_BURST_RRS = 21'h001000,
|
70 |
|
|
stRX_DATA_ERR = 21'h002000,
|
71 |
|
|
stRX_DATA = 21'h004000,
|
72 |
|
|
stEARLY_END_EXT = 21'h008000,
|
73 |
|
|
stEXT_ERROR = 21'h010000;
|
74 |
2 |
jefflieu |
|
75 |
15 |
jefflieu |
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
reg [16:00] r17_State;
|
79 |
|
|
reg [16:00] r21_NxtState;
|
80 |
2 |
jefflieu |
|
81 |
|
|
wire wSUDIK28_5;
|
82 |
|
|
wire wSUDID21_5;
|
83 |
|
|
wire wSUDID2_2;
|
84 |
|
|
wire wCarrierDtect;//what is this
|
85 |
|
|
wire wSUDI;
|
86 |
|
|
|
87 |
|
|
wire w_IsC1Set;
|
88 |
|
|
wire w_IsC2Set;
|
89 |
|
|
wire w_IsI1Set;
|
90 |
|
|
wire w_IsI2Set;
|
91 |
|
|
wire w_IsRSet;
|
92 |
|
|
wire w_IsSSet;
|
93 |
|
|
wire w_IsTSet;
|
94 |
|
|
wire w_IsVSet;
|
95 |
|
|
|
96 |
|
|
//synthesis translate_off
|
97 |
|
|
reg [8*30-1:0] rvStateName;
|
98 |
|
|
always@(*)
|
99 |
|
|
begin
|
100 |
15 |
jefflieu |
case(r17_State)
|
101 |
2 |
jefflieu |
stWAIT_FOR_K : rvStateName <= "Wait For K";
|
102 |
|
|
stRX_K : rvStateName <= "RX K";
|
103 |
|
|
stRX_CB : rvStateName <= "RX CB";
|
104 |
|
|
stRX_CC : rvStateName <= "RX CC";
|
105 |
|
|
stRX_CD : rvStateName <= "RX CD";
|
106 |
|
|
stRX_INVALID : rvStateName <= "RX Invalid";
|
107 |
|
|
stIDLE_D : rvStateName <= "IDLE D";
|
108 |
15 |
jefflieu |
//stCARRIER_DTEC : rvStateName <= "CARRIER DETECT";
|
109 |
2 |
jefflieu |
stFALSE_CARRIER : rvStateName <= "FALSE CARRIER";
|
110 |
|
|
stSTART_OF_PKT : rvStateName <= "Start of Packet";
|
111 |
15 |
jefflieu |
//stRECEIVE : rvStateName <= "Receiving";
|
112 |
2 |
jefflieu |
stEARLY_END : rvStateName <= "Early End";
|
113 |
|
|
stTRI_RRI : rvStateName <= "TRI RRI";
|
114 |
|
|
stTRR_EXTEND : rvStateName <= "TRR Extend";
|
115 |
15 |
jefflieu |
//stEPD2_CHK_END : rvStateName <= "EPD2 Check End";
|
116 |
2 |
jefflieu |
stPKT_BURST_RRS : rvStateName <= "PKT BURST RRS";
|
117 |
|
|
stRX_DATA_ERR : rvStateName <= "RX DATA Error";
|
118 |
|
|
stRX_DATA : rvStateName <= "RX DATA";
|
119 |
|
|
stEARLY_END_EXT : rvStateName <= "Early End Ext";
|
120 |
|
|
stEXT_ERROR : rvStateName <= "Ext Error";
|
121 |
15 |
jefflieu |
//stLINK_FAILED : rvStateName <= "Link Failed";
|
122 |
2 |
jefflieu |
endcase
|
123 |
|
|
//$display("mReceive State: %s",rvStateName);
|
124 |
|
|
end
|
125 |
|
|
//synthesis translate_on
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
assign w_IsSSet = i_OrderedSetValid && i_IsRSet;
|
129 |
|
|
assign wSUDI = ~i_RxCodeInvalid;
|
130 |
|
|
assign wCarrierDtect = i_IsRSet|i_IsSSet|i_IsTSet|i_IsVSet;
|
131 |
|
|
|
132 |
|
|
always@(posedge i_Clk or negedge i_ARst_L)
|
133 |
|
|
if(i_ARst_L==1'b0) begin
|
134 |
15 |
jefflieu |
r17_State <= stWAIT_FOR_K;
|
135 |
2 |
jefflieu |
end else begin
|
136 |
15 |
jefflieu |
r17_State <= r21_NxtState;
|
137 |
2 |
jefflieu |
end
|
138 |
|
|
|
139 |
|
|
assign wSUDIK28_5 = (!i_RxCodeInvalid) && (i_RxCodeCtrl) && (i8_RxCodeGroupIn==`K28_5);
|
140 |
|
|
assign wSUDID21_5 = (!i_RxCodeInvalid) && (!i_RxCodeCtrl) && (i8_RxCodeGroupIn==`D21_5);
|
141 |
|
|
assign wSUDID2_2 = (!i_RxCodeInvalid) && (!i_RxCodeCtrl) && (i8_RxCodeGroupIn==`D2_2);
|
142 |
|
|
always@(*)
|
143 |
|
|
begin
|
144 |
15 |
jefflieu |
case(r17_State)
|
145 |
2 |
jefflieu |
stWAIT_FOR_K: if(i_IsComma && i_RxEven) r21_NxtState <= stRX_K; else r21_NxtState<=stWAIT_FOR_K;
|
146 |
|
|
stRX_K : if(wSUDID21_5||wSUDID2_2)
|
147 |
|
|
r21_NxtState <= stRX_CB; else
|
148 |
5 |
jefflieu |
if((!i_RxCodeInvalid) && (i_RxCodeCtrl) && i3_Xmit!=`cXmitDATA)
|
149 |
2 |
jefflieu |
r21_NxtState <= stRX_INVALID; else
|
150 |
|
|
if(((!i_RxCodeInvalid) && (!i_RxCodeCtrl) && i3_Xmit!=`cXmitDATA && i8_RxCodeGroupIn!=`D21_5 && i8_RxCodeGroupIn!=`D2_2)||
|
151 |
|
|
((!i_RxCodeInvalid) && i3_Xmit==`cXmitDATA && ((i8_RxCodeGroupIn!=`D21_5 && i8_RxCodeGroupIn!=`D2_2 && (!i_RxCodeCtrl))||i_RxCodeCtrl)))
|
152 |
|
|
r21_NxtState <= stIDLE_D; else
|
153 |
|
|
r21_NxtState <= stRX_K;
|
154 |
|
|
stRX_CB : if((!i_RxCodeInvalid) && (!i_RxCodeCtrl)) r21_NxtState <= stRX_CC; else r21_NxtState <= stRX_INVALID;
|
155 |
|
|
stRX_CC : if((!i_RxCodeInvalid) && (!i_RxCodeCtrl)) r21_NxtState <= stRX_CD; else r21_NxtState <= stRX_INVALID;
|
156 |
|
|
stRX_CD : if((!i_RxCodeInvalid) && (i_RxCodeCtrl) && i8_RxCodeGroupIn==`K28_5 && i_RxEven)
|
157 |
|
|
r21_NxtState <= stRX_K;
|
158 |
|
|
else
|
159 |
|
|
r21_NxtState <= stRX_INVALID;
|
160 |
|
|
|
161 |
|
|
stRX_INVALID: if(wSUDIK28_5 && i_RxEven)
|
162 |
|
|
r21_NxtState <= stRX_K;
|
163 |
|
|
else
|
164 |
|
|
r21_NxtState <= stWAIT_FOR_K;
|
165 |
|
|
|
166 |
|
|
stIDLE_D : if(!wSUDIK28_5 && (i3_Xmit!=`cXmitDATA))
|
167 |
|
|
r21_NxtState <= stRX_INVALID;
|
168 |
|
|
else if(!i_RxCodeInvalid && i3_Xmit==`cXmitDATA && i_IsSSet)
|
169 |
|
|
r21_NxtState <= stSTART_OF_PKT;
|
170 |
|
|
else if((!i_RxCodeInvalid && i3_Xmit==`cXmitDATA && (~wCarrierDtect)) || (wSUDIK28_5 && i_RxEven))
|
171 |
|
|
r21_NxtState <= stRX_K;
|
172 |
|
|
else
|
173 |
|
|
r21_NxtState <= stFALSE_CARRIER;
|
174 |
|
|
|
175 |
|
|
/*stCARRIER_DTEC: if(i_OrderedSetValid && i_IsSSet)
|
176 |
|
|
r21_NxtState <= stSTART_OF_PKT;
|
177 |
|
|
else
|
178 |
|
|
r21_NxtState <= stFALSE_CARRIER;*/
|
179 |
|
|
stFALSE_CARRIER : if(wSUDIK28_5 && i_RxEven) r21_NxtState <= stRX_K; else r21_NxtState <= stFALSE_CARRIER;
|
180 |
|
|
|
181 |
|
|
stSTART_OF_PKT : if(wSUDI)
|
182 |
|
|
begin
|
183 |
|
|
if(~i_RxCodeCtrl) r21_NxtState <= stRX_DATA; else
|
184 |
|
|
if((i_CheckEndKDK||i_CheckEndKD21_5D0_0||i_CheckEndKD2_2D0_0) &&i_RxEven)
|
185 |
|
|
r21_NxtState <= stEARLY_END; else
|
186 |
|
|
if(i_CheckEndTRK && i_RxEven) r21_NxtState <= stTRI_RRI; else
|
187 |
|
|
if(i_CheckEndTRR) r21_NxtState <= stTRR_EXTEND; else
|
188 |
|
|
if(i_CheckEndRRR) r21_NxtState <= stEARLY_END_EXT; else
|
189 |
|
|
r21_NxtState <= stRX_DATA_ERR;
|
190 |
|
|
end
|
191 |
|
|
else r21_NxtState <= stRX_DATA_ERR;
|
192 |
|
|
//stRECEIVE : //zero cycle state
|
193 |
|
|
stRX_DATA : if(wSUDI)
|
194 |
|
|
begin
|
195 |
|
|
if(~i_RxCodeCtrl) r21_NxtState <= stRX_DATA; else
|
196 |
|
|
if((i_CheckEndKDK||i_CheckEndKD21_5D0_0||i_CheckEndKD2_2D0_0) &&i_RxEven)
|
197 |
|
|
r21_NxtState <= stEARLY_END; else
|
198 |
|
|
if(i_CheckEndTRK && i_RxEven) r21_NxtState <= stTRI_RRI; else
|
199 |
|
|
if(i_CheckEndTRR) r21_NxtState <= stTRR_EXTEND; else
|
200 |
|
|
if(i_CheckEndRRR) r21_NxtState <= stEARLY_END_EXT; else
|
201 |
|
|
r21_NxtState <= stRX_DATA_ERR;
|
202 |
|
|
end
|
203 |
|
|
else r21_NxtState <= stRX_DATA_ERR;
|
204 |
|
|
stRX_DATA_ERR : if(wSUDI)
|
205 |
|
|
begin
|
206 |
|
|
if(~i_RxCodeCtrl) r21_NxtState <= stRX_DATA; else
|
207 |
|
|
if((i_CheckEndKDK||i_CheckEndKD21_5D0_0||i_CheckEndKD2_2D0_0) &&i_RxEven)
|
208 |
|
|
r21_NxtState <= stEARLY_END; else
|
209 |
|
|
if(i_CheckEndTRK && i_RxEven) r21_NxtState <= stTRI_RRI; else
|
210 |
|
|
if(i_CheckEndTRR) r21_NxtState <= stTRR_EXTEND; else
|
211 |
|
|
if(i_CheckEndRRR) r21_NxtState <= stEARLY_END_EXT; else
|
212 |
|
|
r21_NxtState <= stRX_DATA_ERR;
|
213 |
|
|
end
|
214 |
|
|
else r21_NxtState <= stRX_DATA_ERR;
|
215 |
|
|
stEARLY_END : if(wSUDID21_5||wSUDID2_2) r21_NxtState <= stRX_CB; else r21_NxtState <= stIDLE_D;
|
216 |
|
|
stTRI_RRI : if(wSUDIK28_5) r21_NxtState <= stRX_K; else r21_NxtState <= stTRI_RRI;
|
217 |
|
|
stTRR_EXTEND : if(i_CheckEndRRR) r21_NxtState <= stTRR_EXTEND; else
|
218 |
|
|
if(i_CheckEndRRK && i_RxEven) r21_NxtState <= stTRI_RRI; else
|
219 |
|
|
if(i_CheckEndRRS) r21_NxtState <= stPKT_BURST_RRS; else
|
220 |
|
|
if(i_IsVSet) r21_NxtState <= stEXT_ERROR; else
|
221 |
|
|
r21_NxtState <= stTRR_EXTEND;
|
222 |
|
|
stEARLY_END_EXT : if(i_CheckEndRRR) r21_NxtState <= stTRR_EXTEND; else
|
223 |
|
|
if(i_CheckEndRRK && i_RxEven) r21_NxtState <= stTRI_RRI; else
|
224 |
|
|
if(i_CheckEndRRS) r21_NxtState <= stPKT_BURST_RRS; else
|
225 |
|
|
if(i_IsVSet) r21_NxtState <= stEXT_ERROR; else
|
226 |
|
|
r21_NxtState <= stEARLY_END_EXT;
|
227 |
|
|
//This is zero cycle state
|
228 |
|
|
//stEPD2_CHK_END : if(i_CheckEndRRR) r21_NxtState <= stTRR_EXTEND; else
|
229 |
|
|
// if(i_CheckEndRRK && i_RxEven) r21_NxtState <= stTRI_RRI; else
|
230 |
|
|
// if(i_CheckEndRRS) r21_NxtState <= stPKT_BURST_RRS; else
|
231 |
|
|
// r21_NxtState <= stEXT_ERROR;
|
232 |
|
|
stPKT_BURST_RRS : if(i_IsSSet && i_OrderedSetValid && wSUDI) r21_NxtState <= stSTART_OF_PKT; else r21_NxtState <= stPKT_BURST_RRS;
|
233 |
|
|
stEXT_ERROR : if(i_IsSSet && i_OrderedSetValid && wSUDI) r21_NxtState <= stSTART_OF_PKT; else
|
234 |
|
|
if(wSUDIK28_5 && i_RxEven) r21_NxtState <= stRX_K; else
|
235 |
|
|
if(i_CheckEndRRR) r21_NxtState <= stTRR_EXTEND; else
|
236 |
|
|
if(i_CheckEndRRK && i_RxEven) r21_NxtState <= stTRI_RRI; else
|
237 |
|
|
if(i_CheckEndRRS) r21_NxtState <= stPKT_BURST_RRS; else
|
238 |
|
|
r21_NxtState <= stEXT_ERROR;
|
239 |
|
|
endcase
|
240 |
|
|
end
|
241 |
|
|
|
242 |
15 |
jefflieu |
assign o_RUDIConfig = (r17_State==stRX_CD )?1'b1:1'b0;
|
243 |
|
|
assign o_RUDIIdle = (r17_State==stIDLE_D )?1'b1:1'b0;
|
244 |
|
|
assign o_RUDIInvalid= (r17_State==stRX_INVALID && i3_Xmit==`cXmitCONFIG)?1'b1:1'b0;
|
245 |
2 |
jefflieu |
|
246 |
|
|
always@(posedge i_Clk or negedge i_ARst_L)
|
247 |
|
|
if(i_ARst_L==1'b0) begin
|
248 |
|
|
o_Receiving <= 1'b0;
|
249 |
|
|
o_RxDV <= 1'b0;
|
250 |
|
|
o_RxER <= 1'b0;
|
251 |
|
|
o8_RxD <= 8'h0;
|
252 |
|
|
o16_RxConfigReg <= 16'h00;
|
253 |
|
|
end else begin
|
254 |
|
|
|
255 |
|
|
case(r21_NxtState)
|
256 |
|
|
//stWAIT_FOR_K :
|
257 |
|
|
stRX_K : begin
|
258 |
|
|
o_Receiving <= 1'b0;
|
259 |
|
|
o_RxDV <= 1'b0;
|
260 |
|
|
o_RxER <= 1'b0;
|
261 |
|
|
end
|
262 |
|
|
//stRX_CB :
|
263 |
|
|
stRX_CC : o16_RxConfigReg[07:00] <= i8_RxCodeGroupIn;
|
264 |
|
|
stRX_CD : o16_RxConfigReg[15:08] <= i8_RxCodeGroupIn;
|
265 |
|
|
stRX_INVALID : if(i3_Xmit==`cXmitDATA) o_Receiving <= 1'b1;
|
266 |
|
|
stIDLE_D : begin
|
267 |
|
|
o_Receiving <= 1'b0;
|
268 |
|
|
o_RxDV <= 1'b0;
|
269 |
|
|
o_RxER <= 1'b0;
|
270 |
|
|
end
|
271 |
|
|
|
272 |
|
|
//stCARRIER_DTEC: o_Receiving <= 1'b1;
|
273 |
|
|
stFALSE_CARRIER : begin
|
274 |
|
|
o_RxER <= 1'b1;
|
275 |
|
|
o8_RxD <= 8'h0E;
|
276 |
|
|
end
|
277 |
|
|
stSTART_OF_PKT : begin
|
278 |
|
|
o_Receiving <= 1'b1;
|
279 |
|
|
o_RxDV <= 1'b1;
|
280 |
|
|
o_RxER <= 1'b0;
|
281 |
|
|
o8_RxD <= 8'h55;
|
282 |
|
|
end
|
283 |
|
|
//stRECEIVE :
|
284 |
|
|
stEARLY_END : o_RxER <= 1'b1;
|
285 |
|
|
stTRI_RRI : begin
|
286 |
|
|
o_Receiving <= 1'b0;
|
287 |
|
|
o_RxER <= 1'b0;
|
288 |
|
|
o_RxDV <= 1'b0;
|
289 |
|
|
end
|
290 |
|
|
stTRR_EXTEND : begin
|
291 |
|
|
o_RxER <= 1'b1;
|
292 |
|
|
o_RxDV <= 1'b0;
|
293 |
|
|
o8_RxD <= 8'h0F;
|
294 |
|
|
end
|
295 |
|
|
//stEPD2_CHK_END :
|
296 |
|
|
stPKT_BURST_RRS : begin
|
297 |
|
|
o_RxDV <= 1'b0;
|
298 |
|
|
o8_RxD <= 8'b0000_1111;
|
299 |
|
|
end
|
300 |
|
|
stRX_DATA_ERR : o_RxER <= 1'b1;
|
301 |
|
|
stRX_DATA : begin
|
302 |
|
|
o_RxER <= 1'b0;
|
303 |
|
|
o8_RxD <= i8_RxCodeGroupIn;
|
304 |
|
|
end
|
305 |
|
|
stEARLY_END_EXT : o_RxER <= 1'b1;
|
306 |
|
|
stEXT_ERROR : begin
|
307 |
|
|
o_RxDV <= 1'b0;
|
308 |
|
|
o8_RxD <= 8'b0001_1111;
|
309 |
|
|
end
|
310 |
15 |
jefflieu |
// stLINK_FAILED : begin
|
311 |
|
|
// if(o_Receiving==1'b1)
|
312 |
|
|
// begin
|
313 |
|
|
// o_Receiving <= 1'b0;
|
314 |
|
|
// o_RxER <= 1'b1;
|
315 |
|
|
// end else
|
316 |
|
|
// begin
|
317 |
|
|
// o_RxDV <= 1'b0;
|
318 |
|
|
// o_RxER <= 1'b0;
|
319 |
|
|
// end
|
320 |
|
|
// if(i3_Xmit!=`cXmitDATA) o_Invalid <= 1'b1;
|
321 |
|
|
// end
|
322 |
2 |
jefflieu |
endcase
|
323 |
|
|
end
|
324 |
|
|
|
325 |
|
|
endmodule
|