Line 53... |
Line 53... |
localparam stTX_EOP_EXT= 24'h010000; //End of packet with extension
|
localparam stTX_EOP_EXT= 24'h010000; //End of packet with extension
|
localparam stTX_EXT_1 = 24'h020000; //Extend 1 cycle to align the COMMA to Even Code group
|
localparam stTX_EXT_1 = 24'h020000; //Extend 1 cycle to align the COMMA to Even Code group
|
localparam stEPD2_NOEXT= 24'h040000; //Second Cycle of EPD, transmitting /R/
|
localparam stEPD2_NOEXT= 24'h040000; //Second Cycle of EPD, transmitting /R/
|
localparam stEPD3 = 24'h080000; //Third Cycle of EPD, transmitting /R/
|
localparam stEPD3 = 24'h080000; //Third Cycle of EPD, transmitting /R/
|
localparam stCARR_EXT = 24'h100000; //Carrier extension
|
localparam stCARR_EXT = 24'h100000; //Carrier extension
|
localparam stALIGN_ERR = 24'h200000; //Repeater's state, we don't use this, go straight to START ERR
|
//localparam stALIGN_ERR = 24'h200000; //Repeater's state, we don't use this, go straight to START ERR
|
localparam stSTART_ERR = 24'h400000; //Repeater's state
|
localparam stSTART_ERR = 24'h200000; //Repeater's state
|
localparam stTX_ERR = 24'h800000; //Repeater's state
|
localparam stTX_ERR = 24'h400000; //Repeater's state
|
|
|
|
|
reg [23:00] r24_State;
|
reg [22:00] r13_State;
|
reg [23:00] w24_NxtState;
|
reg [22:00] w24_NxtState;
|
|
|
|
|
wire w_XmitChange;
|
wire w_XmitChange;
|
reg [02:00] r3_LstXmit;
|
reg [02:00] r3_LstXmit;
|
reg r_TxEven;
|
reg r_TxEven;
|
Line 73... |
Line 73... |
wire w_FifoTxEn;
|
wire w_FifoTxEn;
|
wire w_FifoTxEr;
|
wire w_FifoTxEr;
|
wire [07:00] w8_FifoData;
|
wire [07:00] w8_FifoData;
|
wire w_UpdateXmitChange;
|
wire w_UpdateXmitChange;
|
wire w_ResetState;
|
wire w_ResetState;
|
wire r_ToTxData; //This signal used in txIDLE_DATA state to comeback to TXIDLE or TXDATA
|
reg r_ToTxData; //This signal used in txIDLE_DATA state to comeback to TXIDLE or TXDATA
|
wire w_Disparity;
|
wire w_Disparity;
|
wire [09:00] w10_FifoDin;
|
wire [09:00] w10_FifoDin;
|
wire [09:00] w10_FifoQ;
|
wire [09:00] w10_FifoQ;
|
wire w_FifoRd,w_FifoEmpty;
|
wire w_FifoRd,w_FifoEmpty;
|
reg [07:00] r8_TxData;
|
reg [07:00] r8_TxData;
|
|
|
assign w_XmitChange = (r3_LstXmit!=i3_Xmit)?1'b1:1'b0;
|
assign w_XmitChange = (r3_LstXmit!=i3_Xmit)?1'b1:1'b0;
|
assign w_TxOSIndicate = (r24_State==stCONFIG_C1A||r24_State==stCONFIG_C1B||r24_State==stCONFIG_C1C||
|
assign w_TxOSIndicate = (r13_State==stCONFIG_C1A||r13_State==stCONFIG_C1B||r13_State==stCONFIG_C1C||
|
r24_State==stCONFIG_C2A||r24_State==stCONFIG_C2B||r24_State==stCONFIG_C2C||
|
r13_State==stCONFIG_C2A||r13_State==stCONFIG_C2B||r13_State==stCONFIG_C2C||
|
r24_State==stTX_IDLE||r24_State==stTX_DATA)?1'b0:1'b1;
|
r13_State==stTX_IDLE||r13_State==stTX_DATA)?1'b0:1'b1;
|
//assign w_UpdateXmitChange =
|
//assign w_UpdateXmitChange =
|
//FIFO
|
//FIFO
|
assign w10_FifoDin = {i_TxEN,i_TxER,i8_TxD};
|
assign w10_FifoDin = {i_TxEN,i_TxER,i8_TxD};
|
assign w_FifoTxEn = w10_FifoQ[9] & (~w_FifoEmpty);
|
assign w_FifoTxEn = w10_FifoQ[9] & (~w_FifoEmpty);
|
assign w_FifoTxEr = w10_FifoQ[8] & (~w_FifoEmpty);
|
assign w_FifoTxEr = w10_FifoQ[8] & (~w_FifoEmpty);
|
Line 100... |
Line 100... |
.o_Full(),
|
.o_Full(),
|
.ov_Q(w10_FifoQ),
|
.ov_Q(w10_FifoQ),
|
.i_Clk(i_Clk),
|
.i_Clk(i_Clk),
|
.i_ARst_L(i_ARst_L));
|
.i_ARst_L(i_ARst_L));
|
//END FIFO
|
//END FIFO
|
assign w_FifoRd = ((w_FifoTxEn && (r24_State==stXMIT_DATA||r24_State==stTX_IDLE)))?1'b0:1'b1;
|
assign w_FifoRd = ((w_FifoTxEn && (r13_State==stXMIT_DATA||r13_State==stTX_IDLE)))?1'b0:1'b1;
|
|
|
always@(posedge i_Clk or negedge i_ARst_L)
|
always@(posedge i_Clk or negedge i_ARst_L)
|
if(i_ARst_L==1'b0) begin
|
if(i_ARst_L==1'b0) begin
|
r24_State <= stTX_TEST;
|
r13_State <= stTX_TEST;
|
r3_LstXmit <= 3'b000;
|
r3_LstXmit <= `cXmitIDLE;
|
r_TxEven <= 1'b0;
|
r_TxEven <= 1'b0;
|
|
o_TxEven <= 1'b1;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
if(w_UpdateXmitChange) r3_LstXmit <= i3_Xmit;
|
if(w_UpdateXmitChange) r3_LstXmit <= i3_Xmit;
|
r24_State <= w24_NxtState;
|
if(w_ResetState)
|
|
r13_State <= stTX_TEST;
|
|
else
|
|
r13_State <= w24_NxtState;
|
r_TxEven <= ~r_TxEven;
|
r_TxEven <= ~r_TxEven;
|
o_TxEven <= r_TxEven;
|
o_TxEven <= r_TxEven;
|
end
|
end
|
|
|
|
// always@(posedge i_Clk or posedge w_ResetState)
|
|
// if(w_ResetState)
|
|
// r13_State <= stTX_TEST;
|
|
// else
|
|
// r13_State <= w24_NxtState;
|
|
|
|
|
assign w_UpdateXmitChange = w_ResetState;
|
assign w_UpdateXmitChange = w_ResetState;
|
assign w_ResetState = (i_ARst_L==1'b0)||(w_XmitChange && (r_TxEven==1'b0) && w_TxOSIndicate);
|
assign w_ResetState = (i_ARst_L==1'b0)||(w_XmitChange && (o_TxEven==1'b0) && w_TxOSIndicate);
|
assign w_Disparity = i_CurrentParity;
|
assign w_Disparity = i_CurrentParity;
|
always@(*)
|
always@(*)
|
begin
|
begin
|
if(w_ResetState)
|
|
r24_State <= stTX_TEST;
|
// else
|
case(r24_State)
|
case(r13_State)
|
stTX_TEST : if(i3_Xmit==`cXmitCONFIG && r_TxEven==1'b0) w24_NxtState <= stCONFIG_C1A; else
|
stTX_TEST : if(i3_Xmit==`cXmitCONFIG && o_TxEven==1'b0) w24_NxtState <= stCONFIG_C1A; else
|
if(i3_Xmit==`cXmitIDLE || (i3_Xmit==`cXmitDATA && (w_FifoTxEn || w_FifoTxEr))) w24_NxtState <= stTX_IDLE; else
|
if((i3_Xmit==`cXmitIDLE &&(~o_TxEven)) || ((~o_TxEven) && i3_Xmit==`cXmitDATA && (w_FifoTxEn || w_FifoTxEr))) w24_NxtState <= stTX_IDLE; else
|
if(i3_Xmit==`cXmitDATA && (~w_FifoTxEn) && (~w_FifoTxEr)) w24_NxtState <= stXMIT_DATA;
|
if(i3_Xmit==`cXmitDATA && (~w_FifoTxEn) && (~w_FifoTxEr)) w24_NxtState <= stXMIT_DATA;
|
else w24_NxtState <= stTX_TEST;
|
else w24_NxtState <= stTX_TEST;
|
stCONFIG_C1A : w24_NxtState <= stCONFIG_C1B;
|
stCONFIG_C1A : w24_NxtState <= stCONFIG_C1B;
|
stCONFIG_C1B : w24_NxtState <= stCONFIG_C1C;
|
stCONFIG_C1B : w24_NxtState <= stCONFIG_C1C;
|
stCONFIG_C1C : w24_NxtState <= stCONFIG_C1D;
|
stCONFIG_C1C : w24_NxtState <= stCONFIG_C1D;
|
Line 217... |
Line 228... |
stCONFIG_C2C : o8_TxCodeGroupOut <= i16_ConfigReg[07:00];
|
stCONFIG_C2C : o8_TxCodeGroupOut <= i16_ConfigReg[07:00];
|
stCONFIG_C2D : o8_TxCodeGroupOut <= i16_ConfigReg[15:08];
|
stCONFIG_C2D : o8_TxCodeGroupOut <= i16_ConfigReg[15:08];
|
stTX_IDLE : begin
|
stTX_IDLE : begin
|
o8_TxCodeGroupOut <= `K28_5;
|
o8_TxCodeGroupOut <= `K28_5;
|
o_TxCodeCtrl <= 1'b1;
|
o_TxCodeCtrl <= 1'b1;
|
|
r_ToTxData <= 1'b0;
|
end
|
end
|
stIDLE_DATA : begin
|
stIDLE_DATA : begin
|
o8_TxCodeGroupOut <= (w_Disparity==1'b0)?`D5_6:`D16_2;//Disparity = 0 means positive
|
o8_TxCodeGroupOut <= (w_Disparity==1'b1)?`D5_6:`D16_2;//Disparity = 1 means positive
|
o_TxCodeCtrl <= 1'b0;
|
o_TxCodeCtrl <= 1'b0;
|
end
|
end
|
stXMIT_DATA : begin
|
stXMIT_DATA : begin
|
o8_TxCodeGroupOut <= `K28_5;
|
o8_TxCodeGroupOut <= `K28_5;
|
o_TxCodeCtrl <= 1'b1;
|
o_TxCodeCtrl <= 1'b1;
|
|
r_ToTxData <= 1'b1;
|
end
|
end
|
stTX_DATA : if(((~w_FifoTxEn) & w_FifoTxEr & w8_FifoData != 8'h0F)||(w_FifoTxEn & w_FifoTxEr))
|
stTX_DATA : if(((~w_FifoTxEn) & w_FifoTxEr & w8_FifoData != 8'h0F)||(w_FifoTxEn & w_FifoTxEr))
|
begin
|
begin
|
o8_TxCodeGroupOut <= `K30_7;
|
o8_TxCodeGroupOut <= `K30_7;
|
o_TxCodeCtrl <= 1'b1;
|
o_TxCodeCtrl <= 1'b1;
|
Line 302... |
Line 315... |
end
|
end
|
|
|
//synthesis translate_off
|
//synthesis translate_off
|
reg [239:0] r240_TxStateName;
|
reg [239:0] r240_TxStateName;
|
always@(*)
|
always@(*)
|
case(r24_State)
|
case(r13_State)
|
stTX_TEST : r240_TxStateName<="stTX_TEST ";
|
stTX_TEST : r240_TxStateName<="stTX_TEST ";
|
stCONFIG_C1A : r240_TxStateName<="stCONFIG_C1A";
|
stCONFIG_C1A : r240_TxStateName<="stCONFIG_C1A";
|
stCONFIG_C1B : r240_TxStateName<="stCONFIG_C1B";
|
stCONFIG_C1B : r240_TxStateName<="stCONFIG_C1B";
|
stCONFIG_C1C : r240_TxStateName<="stCONFIG_C1C";
|
stCONFIG_C1C : r240_TxStateName<="stCONFIG_C1C";
|
stCONFIG_C1D : r240_TxStateName<="stCONFIG_C1D";
|
stCONFIG_C1D : r240_TxStateName<="stCONFIG_C1D";
|
Line 324... |
Line 337... |
stTX_EOP_EXT : r240_TxStateName<="stTX_EOP_EXT";
|
stTX_EOP_EXT : r240_TxStateName<="stTX_EOP_EXT";
|
stTX_EXT_1 : r240_TxStateName<="stTX_EXT_1 ";
|
stTX_EXT_1 : r240_TxStateName<="stTX_EXT_1 ";
|
stEPD2_NOEXT : r240_TxStateName<="stEPD2_NOEXT";
|
stEPD2_NOEXT : r240_TxStateName<="stEPD2_NOEXT";
|
stEPD3 : r240_TxStateName<="stEPD3 ";
|
stEPD3 : r240_TxStateName<="stEPD3 ";
|
stCARR_EXT : r240_TxStateName<="stCARR_EXT ";
|
stCARR_EXT : r240_TxStateName<="stCARR_EXT ";
|
stALIGN_ERR : r240_TxStateName<="stALIGN_ERR";
|
//stALIGN_ERR : r240_TxStateName<="stALIGN_ERR";
|
stSTART_ERR : r240_TxStateName<="stSTART_ERR";
|
stSTART_ERR : r240_TxStateName<="stSTART_ERR";
|
stTX_ERR : r240_TxStateName<="stTX_ERR ";
|
stTX_ERR : r240_TxStateName<="stTX_ERR ";
|
endcase
|
endcase
|
//synthesis translate_on
|
//synthesis translate_on
|
endmodule
|
endmodule
|